Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dhtnet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
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
dhtnet
Commits
a9ef2a5e
Commit
a9ef2a5e
authored
Nov 5, 2023
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
ConnectionManager: remove pending callback after success
Change-Id: I03cf7bead8bcf5760d035e32a82ec3412ef6fea9
parent
f8b33b2f
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/connectionmanager.cpp
+16
-9
16 additions, 9 deletions
src/connectionmanager.cpp
with
16 additions
and
9 deletions
src/connectionmanager.cpp
+
16
−
9
View file @
a9ef2a5e
...
@@ -472,6 +472,7 @@ public:
...
@@ -472,6 +472,7 @@ public:
* @param deviceId to identify the linked ConnectCallback
* @param deviceId to identify the linked ConnectCallback
*/
*/
void
sendChannelRequest
(
const
std
::
weak_ptr
<
DeviceInfo
>&
dinfo
,
void
sendChannelRequest
(
const
std
::
weak_ptr
<
DeviceInfo
>&
dinfo
,
const
std
::
weak_ptr
<
ConnectionInfo
>&
cinfo
,
const
std
::
shared_ptr
<
MultiplexedSocket
>&
sock
,
const
std
::
shared_ptr
<
MultiplexedSocket
>&
sock
,
const
std
::
string
&
name
,
const
std
::
string
&
name
,
const
dht
::
Value
::
Id
&
vid
);
const
dht
::
Value
::
Id
&
vid
);
...
@@ -898,7 +899,7 @@ ConnectionManager::Impl::connectDevice(const std::shared_ptr<dht::crypto::Certif
...
@@ -898,7 +899,7 @@ ConnectionManager::Impl::connectDevice(const std::shared_ptr<dht::crypto::Certif
lk
.
unlock
();
lk
.
unlock
();
if
(
sthis
->
config_
->
logger
)
if
(
sthis
->
config_
->
logger
)
sthis
->
config_
->
logger
->
debug
(
"[device {}] Peer already connected. Add a new channel"
,
deviceId
);
sthis
->
config_
->
logger
->
debug
(
"[device {}] Peer already connected. Add a new channel"
,
deviceId
);
sthis
->
sendChannelRequest
(
di
,
sock
,
name
,
vid
);
sthis
->
sendChannelRequest
(
di
,
info
,
sock
,
name
,
vid
);
return
;
return
;
}
}
}
}
...
@@ -1035,7 +1036,8 @@ ConnectionManager::Impl::connectDevice(const std::shared_ptr<dht::crypto::Certif
...
@@ -1035,7 +1036,8 @@ ConnectionManager::Impl::connectDevice(const std::shared_ptr<dht::crypto::Certif
}
}
void
void
ConnectionManager
::
Impl
::
sendChannelRequest
(
const
std
::
weak_ptr
<
DeviceInfo
>&
dinfo
,
ConnectionManager
::
Impl
::
sendChannelRequest
(
const
std
::
weak_ptr
<
DeviceInfo
>&
dinfow
,
const
std
::
weak_ptr
<
ConnectionInfo
>&
cinfow
,
const
std
::
shared_ptr
<
MultiplexedSocket
>&
sock
,
const
std
::
shared_ptr
<
MultiplexedSocket
>&
sock
,
const
std
::
string
&
name
,
const
std
::
string
&
name
,
const
dht
::
Value
::
Id
&
vid
)
const
dht
::
Value
::
Id
&
vid
)
...
@@ -1044,18 +1046,23 @@ ConnectionManager::Impl::sendChannelRequest(const std::weak_ptr<DeviceInfo>& din
...
@@ -1044,18 +1046,23 @@ ConnectionManager::Impl::sendChannelRequest(const std::weak_ptr<DeviceInfo>& din
if
(
!
channelSock
)
{
if
(
!
channelSock
)
{
if
(
config_
->
logger
)
if
(
config_
->
logger
)
config_
->
logger
->
error
(
"sendChannelRequest failed - cannot create channel"
);
config_
->
logger
->
error
(
"sendChannelRequest failed - cannot create channel"
);
if
(
auto
info
=
dinfo
.
lock
())
if
(
auto
info
=
dinfo
w
.
lock
())
info
->
executePendingOperations
(
vid
,
nullptr
);
info
->
executePendingOperations
(
vid
,
nullptr
);
return
;
return
;
}
}
channelSock
->
onShutdown
([
dinfo
,
name
,
vid
]
{
channelSock
->
onShutdown
([
dinfo
w
,
name
,
vid
]
{
if
(
auto
info
=
dinfo
.
lock
())
if
(
auto
info
=
dinfo
w
.
lock
())
info
->
executePendingOperations
(
vid
,
nullptr
);
info
->
executePendingOperations
(
vid
,
nullptr
);
});
});
channelSock
->
onReady
(
channelSock
->
onReady
(
[
dinfo
,
wSock
=
std
::
weak_ptr
(
channelSock
),
name
,
vid
](
bool
accepted
)
{
[
dinfow
,
cinfow
,
wSock
=
std
::
weak_ptr
(
channelSock
),
name
,
vid
](
bool
accepted
)
{
if
(
auto
info
=
dinfo
.
lock
())
if
(
auto
dinfo
=
dinfow
.
lock
())
{
info
->
executePendingOperations
(
vid
,
accepted
?
wSock
.
lock
()
:
nullptr
,
accepted
);
dinfo
->
executePendingOperations
(
vid
,
accepted
?
wSock
.
lock
()
:
nullptr
,
accepted
);
if
(
auto
cinfo
=
cinfow
.
lock
())
{
std
::
lock_guard
<
std
::
mutex
>
lk
(
cinfo
->
mutex_
);
cinfo
->
cbIds_
.
erase
(
vid
);
}
}
});
});
ChannelRequest
val
;
ChannelRequest
val
;
...
@@ -1219,7 +1226,7 @@ ConnectionManager::Impl::onTlsNegotiationDone(const std::shared_ptr<DeviceInfo>&
...
@@ -1219,7 +1226,7 @@ ConnectionManager::Impl::onTlsNegotiationDone(const std::shared_ptr<DeviceInfo>&
if
(
config_
->
logger
)
if
(
config_
->
logger
)
config_
->
logger
->
debug
(
"[device {}] Send request on TLS socket for channel {}"
,
config_
->
logger
->
debug
(
"[device {}] Send request on TLS socket for channel {}"
,
deviceId
,
name
);
deviceId
,
name
);
sendChannelRequest
(
dinfo
,
info
->
socket_
,
name
,
id
);
sendChannelRequest
(
dinfo
,
info
,
info
->
socket_
,
name
,
id
);
}
}
}
}
}
}
...
...
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
sign in
to comment