Skip to content

When using Windows, an exception "addEvent | select() can not watch fd bigger than 1024" was thrown when creating a TcpServer.  #228

Closed
@Hecravi-Sali

Description

git commit: 26d54bb

Log:
2024-05-16 11:28:29.071 W [tstj.exe] [15636-12384] EventPoller.cpp:144 addEvent | select() can not watch fd bigger than 1024
When starting, using a singleton, an exception was thrown when building a TcpServer in the constructor

ServerManager() {
    serverPtr = std::make_shared<toolkit::TcpServer>();
    ....
}

The exception was located in the EventPoller.cpp file

#else
        if (fd >= FD_SETSIZE) {
            WarnL << "select() can not watch fd bigger than " << FD_SETSIZE;
            return -1;
        }
        auto record = std::make_shared<Poll_Record>();
        record->fd = fd;
        record->event = event;
        record->call_back = std::move(cb);
        _event_map.emplace(fd, record);
        return 0;
#endif

How to solve this situation? The code was working normally before git commit: 43004be.

Thank you

git commit: 26d54bb

日志记录:
2024-05-16 11:28:29.071 W [tstj.exe] [15636-12384] EventPoller.cpp:144 addEvent | select() can not watch fd bigger than 1024
启动时,使用单例,在构造函数中构建了一个TcpServer

ServerManager() {
    serverPtr = std::make_shared<toolkit::TcpServer>();
    ....
}

时抛出异常,定位到EventPoller.cpp文件里

#else
        if (fd >= FD_SETSIZE) {
            WarnL << "select() can not watch fd bigger than " << FD_SETSIZE;
            return -1;
        }
        auto record = std::make_shared<Poll_Record>();
        record->fd = fd;
        record->event = event;
        record->call_back = std::move(cb);
        _event_map.emplace(fd, record);
        return 0;
#endif

这种情况该如何解决呢?在 git commit: 43004be 之前代码是正常工作的。

谢谢

TRANS_BY_GITHUB_AI_ASSISTANT

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions