Skip to content

Duplicate EraseFDs Entries Can Cause Wrong Filedescriptor close() behaviour #21

Description

@clauspruefer

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().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions