Fixed networking flush algorithm for the file transfer
This commit is contained in:
@@ -67,6 +67,26 @@ void LocalFileTransfer::disconnect_client(const std::shared_ptr<FileClient> &cli
|
||||
#undef del_ev_noblock
|
||||
}
|
||||
|
||||
void LocalFileTransfer::test_disconnecting_state(const std::shared_ptr<FileClient> &client) {
|
||||
if(client->state != FileClient::STATE_DISCONNECTING)
|
||||
return;
|
||||
|
||||
{
|
||||
std::lock_guard db_lock{client->disk_buffer.mutex};
|
||||
std::lock_guard nb_lock{client->network_buffer.mutex};
|
||||
|
||||
if(client->disk_buffer.bytes > 0)
|
||||
return;
|
||||
|
||||
if(client->network_buffer.bytes > 0)
|
||||
return;
|
||||
}
|
||||
|
||||
debugMessage(LOG_FT, "{} Disk and network buffers are flushed.", client->log_prefix());
|
||||
std::unique_lock s_lock{client->state_mutex};
|
||||
this->disconnect_client(client, s_lock, false);
|
||||
}
|
||||
|
||||
void LocalFileTransfer::dispatch_loop_client_worker(void *ptr_transfer) {
|
||||
auto provider = reinterpret_cast<LocalFileTransfer*>(ptr_transfer);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user