File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ Client::~Client()
2222
2323ssize_t Client::receiveData ()
2424{
25+ ssize_t TotalRcvBytes = 0 ;
26+
2527 for (;;) {
2628 const ssize_t RcvBytes = read (_ClientFD, _ReceiveBuffer, SOCKET_RECEIVE_BUFFER_SIZE );
2729 const int ReadErrno = errno;
@@ -30,6 +32,7 @@ ssize_t Client::receiveData()
3032
3133 if (RcvBytes > 0 ) {
3234 appendBuffer (_ReceiveBuffer, RcvBytes);
35+ TotalRcvBytes += RcvBytes;
3336 continue ;
3437 }
3538
@@ -41,6 +44,13 @@ ssize_t Client::receiveData()
4144 continue ;
4245 }
4346
47+ if (
48+ (ReadErrno == EAGAIN || ReadErrno == EWOULDBLOCK ) &&
49+ TotalRcvBytes > 0
50+ ) {
51+ return TotalRcvBytes;
52+ }
53+
4454 errno = ReadErrno;
4555 return -1 ;
4656 }
Original file line number Diff line number Diff line change @@ -84,18 +84,19 @@ void ClientHandler::readClientData(const uint16_t FDCount)
8484
8585 if (Clients.contains (ReadFD)) {
8686 const auto RecvStatus = Clients[ReadFD]->receiveData ();
87- const int RecvErrno = errno;
8887 if (RecvStatus == 0 ) {
8988 Clients.erase (ReadFD);
9089 close (ReadFD);
91- } else if (
92- RecvStatus < 0 &&
93- RecvErrno != EAGAIN &&
94- RecvErrno != EWOULDBLOCK &&
95- RecvErrno != EINTR
96- ) {
97- Clients.erase (ReadFD);
98- close (ReadFD);
90+ } else if (RecvStatus < 0 ) {
91+ const int RecvErrno = errno;
92+ if (
93+ RecvErrno != EAGAIN &&
94+ RecvErrno != EWOULDBLOCK &&
95+ RecvErrno != EINTR
96+ ) {
97+ Clients.erase (ReadFD);
98+ close (ReadFD);
99+ }
99100 }
100101 }
101102 }
You can’t perform that action at this time.
0 commit comments