From 87be1e353efd2589f495be4e0716f8ab7da2f87e Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 27 Sep 2022 23:56:17 +0200 Subject: [PATCH] fixed bug in friendserver randomly dropping some incoming packets --- retroshare-friendserver/src/network.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/retroshare-friendserver/src/network.cc b/retroshare-friendserver/src/network.cc index a607a89c2..b5d9e076a 100644 --- a/retroshare-friendserver/src/network.cc +++ b/retroshare-friendserver/src/network.cc @@ -26,6 +26,7 @@ #include #include #include +#include #include "util/rsnet.h" #include "util/rsprint.h" @@ -45,6 +46,9 @@ FsNetworkInterface::FsNetworkInterface(const std::string& listening_address,uint mClintListn = 0; mClintListn = socket(AF_INET, SOCK_STREAM, 0); // creating socket + int flags=1; + setsockopt(mClintListn,SOL_SOCKET,TCP_NODELAY,(char*)&flags,sizeof(flags)); + unix_fcntl_nonblock(mClintListn); struct sockaddr_in ipOfServer; @@ -104,7 +108,7 @@ void FsNetworkInterface::threadTick() RS_STACK_MUTEX(mFsNiMtx); for(auto& it:mConnections) - if(it.second.bio->isactive()) + if(it.second.bio->isactive() || it.second.bio->moretoread(0)) it.second.pqi_thread->tick(); else to_close.push_back(it.first); @@ -147,6 +151,9 @@ bool FsNetworkInterface::checkForNewConnections() // Make the socket non blocking so that we can read from it and return if nothing comes + int flags=1; + setsockopt(clintConnt,SOL_SOCKET,TCP_NODELAY,(char*)&flags,sizeof(flags)); + unix_fcntl_nonblock(clintConnt); // Create connection info