File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#include " Client.hpp"
22
3+ #include < cerrno>
4+
35using namespace std ;
46
57Client::Client (Filedescriptor_t ClientFD, char * BufferAddress) :
@@ -20,7 +22,11 @@ Client::~Client()
2022
2123ssize_t Client::receiveData ()
2224{
23- ssize_t RcvBytes = read (_ClientFD, _ReceiveBuffer, SOCKET_RECEIVE_BUFFER_SIZE );
25+ ssize_t RcvBytes;
26+ do {
27+ RcvBytes = read (_ClientFD, _ReceiveBuffer, SOCKET_RECEIVE_BUFFER_SIZE );
28+ } while (RcvBytes == -1 && errno == EINTR );
29+
2430 DBG (220 , " RcvBytes:" << RcvBytes << " ClientFD:" << _ClientFD);
2531
2632 if (RcvBytes > 0 ) {
Original file line number Diff line number Diff line change 11#include " ClientHandler.hpp"
22
3+ #include < cerrno>
34#include < memory>
45
56using namespace std ;
@@ -83,9 +84,18 @@ void ClientHandler::readClientData(const uint16_t FDCount)
8384
8485 if (Clients.contains (ReadFD)) {
8586 const auto RecvStatus = Clients[ReadFD]->receiveData ();
87+ const int RecvErrno = errno;
8688 if (RecvStatus == 0 ) {
8789 Clients.erase (ReadFD);
8890 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);
8999 }
90100 }
91101 }
You can’t perform that action at this time.
0 commit comments