Fixed networking flush algorithm for the file transfer

This commit is contained in:
WolverinDEV
2020-06-11 13:08:45 +02:00
parent 6e1323cc23
commit cbb0bd6864
5 changed files with 136 additions and 129 deletions
@@ -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);