Current Implementation
In ClientHandler.cpp on client connection close or other error conditions other than EWOULDBLOCK, EAGAIN , currently a vector<ClientFD_t> EraseFDs; is used to save client filedescriptors for closing after data processing.
Problem
The vector type causes problems when multiple push_back(ClientFD) happen. The current processing in the erase loop only erases the first element if two same vector elements exist leaving the same filedescriptor inside the vector. On the next erase loop iteration, the filedescriptor with its ID could have been re-assigned for a new client and immediately gets closed where it should not.
Solution
Replace the std::vector with a std::set and replace push_back() with insert().
Current Implementation
In
ClientHandler.cppon client connection close or other error conditions other than EWOULDBLOCK, EAGAIN , currently avector<ClientFD_t> EraseFDs;is used to save client filedescriptors for closing after data processing.Problem
The
vectortype causes problems when multiplepush_back(ClientFD)happen. The current processing in the erase loop only erases the first element if two same vector elements exist leaving the same filedescriptor inside the vector. On the next erase loop iteration, the filedescriptor with its ID could have been re-assigned for a new client and immediately gets closed where it should not.Solution
Replace the
std::vectorwith astd::setand replacepush_back()withinsert().