Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
opendht
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
opendht
Commits
15da5023
Commit
15da5023
authored
6 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
dhtrunner: make peer discovery port static constexpr
parent
b7a9a52f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/opendht/dhtrunner.h
+0
-2
0 additions, 2 deletions
include/opendht/dhtrunner.h
src/dhtrunner.cpp
+11
-14
11 additions, 14 deletions
src/dhtrunner.cpp
with
11 additions
and
16 deletions
include/opendht/dhtrunner.h
+
0
−
2
View file @
15da5023
...
...
@@ -541,8 +541,6 @@ private:
/** PeerDiscovery Parameters */
std
::
unique_ptr
<
PeerDiscovery
>
peerDiscovery4_
;
std
::
unique_ptr
<
PeerDiscovery
>
peerDiscovery6_
;
const
in_port_t
port_multicast
=
8888
;
};
}
This diff is collapsed.
Click to expand it.
src/dhtrunner.cpp
+
11
−
14
View file @
15da5023
...
...
@@ -31,6 +31,7 @@ namespace dht {
constexpr
std
::
chrono
::
seconds
DhtRunner
::
BOOTSTRAP_PERIOD
;
static
constexpr
size_t
RX_QUEUE_MAX_SIZE
=
1024
*
16
;
static
constexpr
in_port_t
PEER_DISCOVERY_PORT
=
8888
;
struct
DhtRunner
::
Listener
{
size_t
tokenClassicDht
{
0
};
...
...
@@ -45,6 +46,7 @@ DhtRunner::DhtRunner() : dht_()
#ifdef OPENDHT_PROXY_CLIENT
,
dht_via_proxy_
()
#endif //OPENDHT_PROXY_CLIENT
,
peerDiscovery4_
(),
peerDiscovery6_
()
{
#ifdef _WIN32
WSADATA
wsd
;
...
...
@@ -137,12 +139,12 @@ DhtRunner::run(const SockAddr& local4, const SockAddr& local6, const DhtRunner::
if
(
config
.
peer_discovery
or
config
.
peer_publish
)
{
try
{
peerDiscovery4_
.
reset
(
new
PeerDiscovery
(
AF_INET
,
port_multicast
));
peerDiscovery4_
.
reset
(
new
PeerDiscovery
(
AF_INET
,
PEER_DISCOVERY_PORT
));
}
catch
(
const
std
::
exception
&
e
){
std
::
cerr
<<
"Can't start peer discovery (IPv4): "
<<
e
.
what
()
<<
std
::
endl
;
}
try
{
peerDiscovery6_
.
reset
(
new
PeerDiscovery
(
AF_INET6
,
port_multicast
));
peerDiscovery6_
.
reset
(
new
PeerDiscovery
(
AF_INET6
,
PEER_DISCOVERY_PORT
));
}
catch
(
const
std
::
exception
&
e
)
{
std
::
cerr
<<
"Can't start peer discovery (IPv6): "
<<
e
.
what
()
<<
std
::
endl
;
}
...
...
@@ -150,13 +152,11 @@ DhtRunner::run(const SockAddr& local4, const SockAddr& local6, const DhtRunner::
if
(
config
.
peer_discovery
)
{
using
sig
=
void
(
DhtRunner
::*
)(
const
InfoHash
&
,
const
SockAddr
&
);
if
(
peerDiscovery4_
)
peerDiscovery4_
->
startDiscovery
(
std
::
bind
(
static_cast
<
sig
>
(
&
DhtRunner
::
bootstrap
),
this
,
peerDiscovery4_
->
startDiscovery
(
std
::
bind
(
static_cast
<
sig
>
(
&
DhtRunner
::
bootstrap
),
this
,
std
::
placeholders
::
_1
,
std
::
placeholders
::
_2
));
if
(
peerDiscovery6_
)
peerDiscovery6_
->
startDiscovery
(
std
::
bind
(
static_cast
<
sig
>
(
&
DhtRunner
::
bootstrap
),
this
,
peerDiscovery6_
->
startDiscovery
(
std
::
bind
(
static_cast
<
sig
>
(
&
DhtRunner
::
bootstrap
),
this
,
std
::
placeholders
::
_1
,
std
::
placeholders
::
_2
));
}
if
(
config
.
peer_publish
)
{
...
...
@@ -187,10 +187,8 @@ DhtRunner::join()
running
=
false
;
cv
.
notify_all
();
bootstrap_cv
.
notify_all
();
if
(
peerDiscovery4_
)
peerDiscovery4_
->
stop
();
if
(
peerDiscovery6_
)
peerDiscovery6_
->
stop
();
if
(
peerDiscovery4_
)
peerDiscovery4_
->
stop
();
if
(
peerDiscovery6_
)
peerDiscovery6_
->
stop
();
if
(
dht_thread
.
joinable
())
dht_thread
.
join
();
...
...
@@ -198,10 +196,9 @@ DhtRunner::join()
bootstrap_thread
.
join
();
if
(
rcv_thread
.
joinable
())
rcv_thread
.
join
();
if
(
peerDiscovery4_
)
peerDiscovery4_
->
join
();
if
(
peerDiscovery6_
)
peerDiscovery6_
->
join
();
if
(
peerDiscovery4_
)
peerDiscovery4_
->
join
();
if
(
peerDiscovery6_
)
peerDiscovery6_
->
join
();
{
std
::
lock_guard
<
std
::
mutex
>
lck
(
storage_mtx
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment