Skip to content

Commit

Permalink
Segmentation at sock.close() at loop.timer zeromq#205
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Orekhov authored and Pavel Orekhov committed Jan 25, 2018
1 parent 818f9c3 commit 0b90458
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/zmqpp/poller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,15 @@ poller::~poller()
_fdindex.clear();
}

#if defined _WIN32
static const SOCKET invalid_fd = INVALID_SOCKET;
#else
static const int invalid_fd = -1;
#endif

void poller::add(socket& socket, short const event /* = POLL_IN */)
{
zmq_pollitem_t const item { socket, 0, event, 0 };
zmq_pollitem_t const item { socket, invalid_fd, event, 0 };

add(item);
}
Expand Down Expand Up @@ -96,16 +102,16 @@ void poller::reindex(size_t const index)

void poller::remove(socket_t const& socket)
{
zmq_pollitem_t const item{ socket, 0, 0, 0 };
zmq_pollitem_t const item{ socket, invalid_fd, 0, 0 };

remove(item);
}

void poller::remove(raw_socket_t const descriptor)
{
zmq_pollitem_t const item{ nullptr, descriptor, 0, 0 };

remove(item);
if (descriptor != invalid_fd)
remove(item);
}

void poller::remove(zmq_pollitem_t const& item)
Expand Down

0 comments on commit 0b90458

Please sign in to comment.