Skip Menu |

This queue is for tickets about the ZeroMQ CPAN distribution.

Report information
The Basics
Id: 62851
Status: resolved
Priority: 0/
Queue: ZeroMQ

People
Owner: Nobody in particular
Requestors: me [...] swizard.info
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.02_02
Fixed in: (no value)



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;
From: me [...] swizard.info
On Mon Nov 08 12:52:55 2010, swizard wrote: Show quoted text
> 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.
Sorry, the patch was invalid (I forgot that "If both socket and fd are set in a single zmq_pollitem_t, the ØMQ socket referenced by socket shall take precedence and the value of fd shall be ignored"). Please check the correct one attached.
Subject: perl_zeromq.xs.patch2
Download perl_zeromq.xs.patch2
application/octet-stream 2.5k

Message body not shown because it is not plain text.

RT didn't forward me this message, so I just noticed it. with zmq 2.1.0 you can do getsockopt(... ZMQ_FD) to grab the file descriptor for a given socket. would this be enough for you, or do you want PollItem? Since I was just experimenting with PollItem, I thought you didn't really need it if you can get the underlying FD. let me know, and I can put it back with your patch. On 2010-11月-08 月 14:21:19, swizard wrote: Show quoted text
> On Mon Nov 08 12:52:55 2010, swizard wrote:
> > 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.
> > Sorry, the patch was invalid (I forgot that "If both socket and fd are > set in a single zmq_pollitem_t, the ØMQ socket referenced by socket > shall take precedence and the value of fd shall be ignored"). > > Please check the correct one attached.
From: me [...] swizard.info
On Tue Dec 28 18:26:04 2010, DMAKI wrote: Show quoted text
> RT didn't forward me this message, so I just noticed it. > with zmq 2.1.0 you can do getsockopt(... ZMQ_FD) to grab the file > descriptor for a > given socket. would this be enough for you, or do you want PollItem? > Since I was just experimenting with PollItem, I thought you didn't > really need it > if you can get the underlying FD.
No, I just need to poll both zeromq socket and ordinary system socket. It is useful i.e. when I need to receive zmq messages and some data from some file descriptors (pipes, network sockets) at the same time. So for regular file descriptors I can use select(2), poll(2), kqueue, etc, but for zeromq I have to use zmq_poll. Luckily PollItem supports ordinary sockets, but ZeroMQ::PollItem lacks this feature. Show quoted text
> > let me know, and I can put it back with your patch. > > On 2010-11月-08 月 14:21:19, swizard wrote:
> > On Mon Nov 08 12:52:55 2010, swizard wrote:
> > > 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.
> > > > Sorry, the patch was invalid (I forgot that "If both socket and fd
> are
> > set in a single zmq_pollitem_t, the ØMQ socket referenced by socket > > shall take precedence and the value of fd shall be ignored"). > > > > Please check the correct one attached.
>
k, I'll put it back in. I should be able to find some time to work on this during the holidays.
Please checkout 0.02_05 and zmq_poll(), and see if it does what you need.
From: me [...] swizard.info
On Sun Jan 02 10:29:07 2011, DMAKI wrote: Show quoted text
> Please checkout 0.02_05 and zmq_poll(), and see if it does what you need.
Looks like it works for me, thank you
closing ticket!