mirror of
https://github.com/Cuprate/cuprate.git
synced 2024-12-22 19:49:28 +00:00
P2P: fix connection disconnect on Client
drop (#298)
Some checks failed
CI / fmt (push) Has been cancelled
CI / typo (push) Has been cancelled
CI / ci (macos-latest, stable, bash) (push) Has been cancelled
CI / ci (ubuntu-latest, stable, bash) (push) Has been cancelled
CI / ci (windows-latest, stable-x86_64-pc-windows-gnu, msys2 {0}) (push) Has been cancelled
Doc / build (push) Has been cancelled
Doc / deploy (push) Has been cancelled
Some checks failed
CI / fmt (push) Has been cancelled
CI / typo (push) Has been cancelled
CI / ci (macos-latest, stable, bash) (push) Has been cancelled
CI / ci (ubuntu-latest, stable, bash) (push) Has been cancelled
CI / ci (windows-latest, stable-x86_64-pc-windows-gnu, msys2 {0}) (push) Has been cancelled
Doc / build (push) Has been cancelled
Doc / deploy (push) Has been cancelled
fix connection disconnect on `Client` drop
This commit is contained in:
parent
88605b081f
commit
a072d44a0d
1 changed files with 5 additions and 2 deletions
|
@ -45,6 +45,9 @@ where
|
||||||
CSync: CoreSyncSvc,
|
CSync: CoreSyncSvc,
|
||||||
PSync: PeerSyncSvc<N>,
|
PSync: PeerSyncSvc<N>,
|
||||||
{
|
{
|
||||||
|
let connection_tx_weak = connection_tx.downgrade();
|
||||||
|
drop(connection_tx);
|
||||||
|
|
||||||
// Instead of tracking the time from last message from the peer and sending a timed sync if this value is too high,
|
// Instead of tracking the time from last message from the peer and sending a timed sync if this value is too high,
|
||||||
// we just send a timed sync every [TIMEOUT_INTERVAL] seconds.
|
// we just send a timed sync every [TIMEOUT_INTERVAL] seconds.
|
||||||
let mut interval = interval(TIMEOUT_INTERVAL);
|
let mut interval = interval(TIMEOUT_INTERVAL);
|
||||||
|
@ -59,10 +62,10 @@ where
|
||||||
|
|
||||||
tracing::trace!("timeout monitor tick.");
|
tracing::trace!("timeout monitor tick.");
|
||||||
|
|
||||||
if connection_tx.is_closed() {
|
let Some(connection_tx) = connection_tx_weak.upgrade() else {
|
||||||
tracing::debug!("Closing timeout monitor, connection disconnected.");
|
tracing::debug!("Closing timeout monitor, connection disconnected.");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
};
|
||||||
|
|
||||||
let Ok(permit) = Arc::clone(&semaphore).try_acquire_owned() else {
|
let Ok(permit) = Arc::clone(&semaphore).try_acquire_owned() else {
|
||||||
// If we can't get a permit the connection is currently waiting for a response, so no need to
|
// If we can't get a permit the connection is currently waiting for a response, so no need to
|
||||||
|
|
Loading…
Reference in a new issue