Subject: | ZeroMQ::PollItem does not support fds (only zmq sockets) |
Original zmq_poll supports ordinary file descriptors polling (field "fd"
in zmq_pollitem_t). Without this ability it is difficult build even
simple reactors upon zmq_poll call.
Please check the possible patch attached that should fix this.
Subject: | perl_zeromq.xs.patch |
--- ./xs/perl_zeromq.xs~ 2010-10-30 19:32:22.000000000 +0400
+++ ./xs/perl_zeromq.xs 2010-11-08 20:16:51.485068187 +0300
@@ -802,7 +802,8 @@
SV *
-PerlZMQ_PollItem_add( pollitem, socket, events, callback )
+PerlZMQ_PollItem_add( pollitem, socket, fd, events, callback )
PerlZMQ_PollItem *pollitem;
PerlZMQ_Socket *socket;
+ int fd;
int events;
SV *callback;
@@ -818,4 +819,5 @@
Newxz( pollitem->items[ pollitem->item_count ], 1, zmq_pollitem_t );
pollitem->items[ pollitem->item_count ]->socket = PerlZMQ_Socket_socket(socket);
+ pollitem->items[ pollitem->item_count ]->fd = fd;
pollitem->items[ pollitem->item_count ]->events = events;
pollitem->callbacks[ pollitem->item_count ] = SvREFCNT_inc(callback);
@@ -883,4 +885,5 @@
for( i = 0; i < pollitem->item_count && i < MAX_POLL_ITEMS; i++) {
to_poll_items[i].socket = pollitem->items[i]->socket;
+ to_poll_items[i].fd = pollitem->items[i]->fd;
to_poll_items[i].events = pollitem->items[i]->events;
to_poll_items[i].revents = 0;
Subject: | 005_poll.t.patch |
--- ./t/005_poll.t~ 2010-10-28 12:08:04.000000000 +0400
+++ ./t/005_poll.t 2010-11-08 20:19:50.604759098 +0300
@@ -13,5 +13,5 @@
isa_ok $item, 'ZeroMQ::PollItem';
{
- my $guard = $item->add( $sock, ZMQ_POLLIN, sub { ok "callback" } );
+ my $guard = $item->add( $sock, 0, ZMQ_POLLIN, sub { ok "callback" } );
is($item->size, 1);
}
@@ -31,5 +31,5 @@
$req->send("Test");
- my $guard; $guard = $pi->add( $rep, ZMQ_POLLIN, sub {
+ my $guard; $guard = $pi->add( $rep, 0, ZMQ_POLLIN, sub {
$callback++;
undef $guard;