Fix epollfd validity checks when compiling with wepoll (#3855)

This commit is contained in:
Yevgen Pogribnyi 2023-01-24 09:02:47 +02:00 committed by GitHub
parent c693b0b1b2
commit 85c68e7a81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -88,10 +88,11 @@ public:
{ {
#ifdef WEPOLL_H_ #ifdef WEPOLL_H_
if (_eventfd >= 0) eventfd(_port, _eventfd); if (_eventfd >= 0) eventfd(_port, _eventfd);
if (_epollfd) close(_epollfd);
#else #else
if (_eventfd > 0) close(_eventfd.exchange(0)); if (_eventfd > 0) close(_eventfd.exchange(0));
#endif
if (_epollfd >= 0) close(_epollfd); if (_epollfd >= 0) close(_epollfd);
#endif
} }
void add(const Socket& socket, int mode) void add(const Socket& socket, int mode)
@ -146,7 +147,11 @@ public:
close(_epollfd); close(_epollfd);
_socketMap.clear(); _socketMap.clear();
_epollfd = epoll_create(1); _epollfd = epoll_create(1);
#ifdef WEPOLL_H_
if (!_epollfd) SocketImpl::error();
#else
if (_epollfd < 0) SocketImpl::error(); if (_epollfd < 0) SocketImpl::error();
#endif
} }
#ifdef WEPOLL_H_ #ifdef WEPOLL_H_
eventfd(_port, _eventfd); eventfd(_port, _eventfd);

View File

@ -646,7 +646,12 @@ bool SocketImpl::poll(const Poco::Timespan& timeout, int mode)
#else #else
int epollfd = epoll_create(1); int epollfd = epoll_create(1);
#endif #endif
#ifdef WEPOLL_H_
if (!epollfd)
#else
if (epollfd < 0) if (epollfd < 0)
#endif
{ {
error("Can't create epoll queue"); error("Can't create epoll queue");
} }