Commit 7893a6ac authored by Pieter Hintjens's avatar Pieter Hintjens

Problem: zmq poller API is not CLASS conformant

Solution: change zmq_poller_close(p) to zmq_poller_destroy(&p)
parent f8b9ca5f
...@@ -434,8 +434,8 @@ typedef struct zmq_poller_event_t ...@@ -434,8 +434,8 @@ typedef struct zmq_poller_event_t
short events; short events;
} zmq_poller_event_t; } zmq_poller_event_t;
ZMQ_EXPORT void *zmq_poller_new (); ZMQ_EXPORT void *zmq_poller_new (void);
ZMQ_EXPORT int zmq_poller_close (void *poller); ZMQ_EXPORT int zmq_poller_destroy (void **poller_p);
ZMQ_EXPORT int zmq_poller_add (void *poller, void *socket, void *user_data, short events); ZMQ_EXPORT int zmq_poller_add (void *poller, void *socket, void *user_data, short events);
ZMQ_EXPORT int zmq_poller_modify (void *poller, void *socket, short events); ZMQ_EXPORT int zmq_poller_modify (void *poller, void *socket, short events);
ZMQ_EXPORT int zmq_poller_remove (void *poller, void *socket); ZMQ_EXPORT int zmq_poller_remove (void *poller, void *socket);
...@@ -458,7 +458,7 @@ ZMQ_EXPORT int zmq_poller_remove_fd (void *poller, int fd); ...@@ -458,7 +458,7 @@ ZMQ_EXPORT int zmq_poller_remove_fd (void *poller, int fd);
typedef void (zmq_timer_fn)(int timer_id, void *arg); typedef void (zmq_timer_fn)(int timer_id, void *arg);
ZMQ_EXPORT void *zmq_timers_new (void); ZMQ_EXPORT void *zmq_timers_new (void);
ZMQ_EXPORT int zmq_timers_destroy (void **timers); ZMQ_EXPORT int zmq_timers_destroy (void **timers_p);
ZMQ_EXPORT int zmq_timers_add (void *timers, size_t interval, zmq_timer_fn handler, void *arg); ZMQ_EXPORT int zmq_timers_add (void *timers, size_t interval, zmq_timer_fn handler, void *arg);
ZMQ_EXPORT int zmq_timers_cancel (void *timers, int timer_id); ZMQ_EXPORT int zmq_timers_cancel (void *timers, int timer_id);
ZMQ_EXPORT int zmq_timers_set_interval (void *timers, int timer_id, size_t interval); ZMQ_EXPORT int zmq_timers_set_interval (void *timers, int timer_id, size_t interval);
......
...@@ -1045,21 +1045,23 @@ int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_) ...@@ -1045,21 +1045,23 @@ int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_)
// The poller functionality // The poller functionality
void* zmq_poller_new () void *zmq_poller_new (void)
{ {
zmq::socket_poller_t *poller = new (std::nothrow) zmq::socket_poller_t; zmq::socket_poller_t *poller = new (std::nothrow) zmq::socket_poller_t;
alloc_assert (poller); alloc_assert (poller);
return poller; return poller;
} }
int zmq_poller_close (void *poller_) int zmq_poller_destroy (void **poller_p_)
{ {
if (!poller_ || !((zmq::socket_poller_t*)poller_)->check_tag ()) { void *poller = *poller_p_;
if (!poller || !((zmq::socket_poller_t*) poller)->check_tag ()) {
errno = EFAULT; errno = EFAULT;
return -1; return -1;
} }
delete ((zmq::socket_poller_t*)poller_); delete ((zmq::socket_poller_t*) poller);
*poller_p_ = NULL;
return 0; return 0;
} }
......
...@@ -134,7 +134,7 @@ int main (void) ...@@ -134,7 +134,7 @@ int main (void)
assert (event.events == ZMQ_POLLOUT); assert (event.events == ZMQ_POLLOUT);
// Destory poller, sockets and ctx // Destory poller, sockets and ctx
rc = zmq_poller_close (poller); rc = zmq_poller_destroy (&poller);
assert (rc == 0); assert (rc == 0);
rc = zmq_close (sink); rc = zmq_close (sink);
assert (rc == 0); assert (rc == 0);
......
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