File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 66#include " Handler.hxx"
77#include " Response.hxx"
88#include " translation/Protocol.hxx"
9+ #include " net/SocketError.hxx"
910#include " io/Logger.hxx"
1011
1112#include < sys/socket.h>
1213#include < unistd.h>
13- #include < errno.h>
1414#include < string.h>
1515
1616namespace Translation ::Server {
@@ -52,10 +52,12 @@ Connection::TryRead() noexcept
5252 }
5353
5454 if (nbytes < 0 ) {
55- if (errno == EAGAIN)
55+ const auto e = GetSocketError ();
56+ if (IsSocketErrorReceiveWouldBlock (e))
5657 return true ;
5758
58- LogConcat (2 , " ts" , " Failed to read from client: " , strerror (errno));
59+ LogConcat (2 , " ts" , " Failed to read from client: " ,
60+ (const char *)SocketErrorMessage{e});
5961 }
6062
6163 Destroy ();
@@ -142,12 +144,14 @@ Connection::TryWrite() noexcept
142144
143145 ssize_t nbytes = event.GetSocket ().WriteNoWait (output);
144146 if (nbytes < 0 ) {
145- if (errno == EAGAIN) [[likely]] {
147+ const auto e = GetSocketError ();
148+ if (IsSocketErrorSendWouldBlock (e)) [[likely]] {
146149 event.ScheduleWrite ();
147150 return true ;
148151 }
149152
150- LogConcat (2 , " ts" , " Failed to write to client: " , strerror (errno));
153+ LogConcat (2 , " ts" , " Failed to write to client: " ,
154+ (const char *)SocketErrorMessage{e});
151155 Destroy ();
152156 return false ;
153157 }
You can’t perform that action at this time.
0 commit comments