Commit 3e7072dd08829826b78c55b8857e3a5b1df784e6

Authored by Wiebe Cazemier
1 parent 537539a4

Yield write time when locked

Showing 1 changed file with 3 additions and 1 deletions
client.cpp
... ... @@ -116,7 +116,8 @@ void Client::writePingResp()
116 116  
117 117 bool Client::writeBufIntoFd()
118 118 {
119   - std::lock_guard<std::mutex> locker(writeBufMutex);
  119 + if (!writeBufMutex.try_lock())
  120 + return true;
120 121  
121 122 int n;
122 123 while ((n = write(fd, &writebuf[wri], getWriteBufBytesUsed())) != 0)
... ... @@ -142,6 +143,7 @@ bool Client::writeBufIntoFd()
142 143 setReadyForWriting(false);
143 144 }
144 145  
  146 + writeBufMutex.unlock();
145 147 return true;
146 148 }
147 149  
... ...