From 3e7072dd08829826b78c55b8857e3a5b1df784e6 Mon Sep 17 00:00:00 2001 From: Wiebe Cazemier Date: Thu, 17 Dec 2020 20:24:25 +0100 Subject: [PATCH] Yield write time when locked --- client.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client.cpp b/client.cpp index 5bfcfec..a51d1d6 100644 --- a/client.cpp +++ b/client.cpp @@ -116,7 +116,8 @@ void Client::writePingResp() bool Client::writeBufIntoFd() { - std::lock_guard locker(writeBufMutex); + if (!writeBufMutex.try_lock()) + return true; int n; while ((n = write(fd, &writebuf[wri], getWriteBufBytesUsed())) != 0) @@ -142,6 +143,7 @@ bool Client::writeBufIntoFd() setReadyForWriting(false); } + writeBufMutex.unlock(); return true; } -- libgit2 0.21.4