Skip to content

Commit 6215b9a

Browse files
authored
Assert fd >= 0 in updateChannel(). (an-tao#181)
1 parent 3b3df77 commit 6215b9a

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

trantor/net/inner/poller/EpollPoller.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ void EpollPoller::fillActiveChannels(int numEvents,
135135
void EpollPoller::updateChannel(Channel *channel)
136136
{
137137
assertInLoopThread();
138+
assert(channel->fd() >= 0);
139+
138140
const int index = channel->index();
139141
// LOG_TRACE << "fd = " << channel->fd()
140142
// << " events = " << channel->events() << " index = " << index;

trantor/net/inner/poller/KQueue.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ void KQueue::fillActiveChannels(int numEvents,
111111
void KQueue::updateChannel(Channel *channel)
112112
{
113113
assertInLoopThread();
114+
assert(channel->fd() >= 0);
115+
114116
const int index = channel->index();
115117
// LOG_TRACE << "fd = " << channel->fd()
116118
// << " events = " << channel->events() << " index = " << index;

trantor/net/inner/poller/PollPoller.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ void PollPoller::fillActiveChannels(int numEvents,
8989
void PollPoller::updateChannel(Channel* channel)
9090
{
9191
Poller::assertInLoopThread();
92+
assert(channel->fd() >= 0);
93+
9294
// LOG_TRACE << "fd = " << channel->fd() << " events = " <<
9395
// channel->events();
9496
if (channel->index() < 0)

0 commit comments

Comments
 (0)