Unverified Commit 9bee21b3 authored by Luca Boccassi's avatar Luca Boccassi Committed by GitHub

Merge pull request #3484 from jean-airoldie/poller_fd

 Problem: Cannot get thread safe socket fd 
parents 501f9d8d 05aadc4e
Permission to Relicense under MPLv2 or any other OSI approved license chosen by the current ZeroMQ BDFL
This is a statement by Jean Airoldie that grants permission to relicense its copyrights in the libzmq C++ library (ZeroMQ) under the Mozilla Public License v2 (MPLv2) or any other Open Source Initiative approved license chosen by the current ZeroMQ BDFL (Benevolent Dictator for Life).
A portion of the commits made by the Github handle "jean-airoldie", with commit author "jean-airoldie <25088801+jean-airoldie@users.noreply.github.com>", are copyright of Jean Airoldie. This document hereby grants the libzmq project team to relicense libzmq, including all past, present and future contributions of the author listed above.
Jean Airoldie 2019/04/27
......@@ -709,6 +709,7 @@ ZMQ_EXPORT int zmq_poller_wait_all (void *poller,
zmq_poller_event_t *events,
int n_events,
long timeout);
ZMQ_EXPORT int zmq_poller_fd (void *poller);
#if defined _WIN32
ZMQ_EXPORT int
......
......@@ -86,6 +86,17 @@ bool zmq::socket_poller_t::check_tag ()
return _tag == 0xCAFEBABE;
}
int zmq::socket_poller_t::signaler_fd ()
{
if (_signaler) {
return _signaler->get_fd ();
} else {
// Only thread-safe socket types are guaranteed to have a signaler.
errno = EINVAL;
return -1;
}
}
int zmq::socket_poller_t::add (socket_base_t *socket_,
void *user_data_,
short events_)
......
......@@ -75,6 +75,8 @@ class socket_poller_t
int add_fd (fd_t fd_, void *user_data_, short events_);
int modify_fd (fd_t fd_, short events_);
int remove_fd (fd_t fd_);
// Returns the signaler's fd if there is one, otherwise errors.
int signaler_fd ();
int wait (event_t *event_, int n_events_, long timeout_);
......
......@@ -1278,6 +1278,11 @@ int zmq_poller_wait_all (void *poller_,
return rc;
}
int zmq_poller_fd (void *poller_)
{
return static_cast<zmq::socket_poller_t *> (poller_)->signaler_fd ();
}
// Peer-specific state
int zmq_socket_get_peer_state (void *s_,
......
......@@ -105,6 +105,7 @@ int zmq_poller_wait_all (void *poller_,
zmq_poller_event_t *events_,
int n_events_,
long timeout_);
int zmq_poller_fd (void *poller_);
#if defined _WIN32
int zmq_poller_add_fd (void *poller_,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment