Skip to content

Commit 0b90458

Browse files
Pavel OrekhovPavel Orekhov
Pavel Orekhov
authored and
Pavel Orekhov
committed
Segmentation at sock.close() at loop.timer zeromq#205
1 parent 818f9c3 commit 0b90458

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/zmqpp/poller.cpp

+10-4
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,15 @@ poller::~poller()
3636
_fdindex.clear();
3737
}
3838

39+
#if defined _WIN32
40+
static const SOCKET invalid_fd = INVALID_SOCKET;
41+
#else
42+
static const int invalid_fd = -1;
43+
#endif
44+
3945
void poller::add(socket& socket, short const event /* = POLL_IN */)
4046
{
41-
zmq_pollitem_t const item { socket, 0, event, 0 };
47+
zmq_pollitem_t const item { socket, invalid_fd, event, 0 };
4248

4349
add(item);
4450
}
@@ -96,16 +102,16 @@ void poller::reindex(size_t const index)
96102

97103
void poller::remove(socket_t const& socket)
98104
{
99-
zmq_pollitem_t const item{ socket, 0, 0, 0 };
105+
zmq_pollitem_t const item{ socket, invalid_fd, 0, 0 };
100106

101107
remove(item);
102108
}
103109

104110
void poller::remove(raw_socket_t const descriptor)
105111
{
106112
zmq_pollitem_t const item{ nullptr, descriptor, 0, 0 };
107-
108-
remove(item);
113+
if (descriptor != invalid_fd)
114+
remove(item);
109115
}
110116

111117
void poller::remove(zmq_pollitem_t const& item)

0 commit comments

Comments
 (0)