[zeromq-dev] czmq: zloop_poller for stdin - ambiguity

Pieter Hintjens ph at imatix.com
Thu Mar 13 23:21:58 CET 2014


I merged your patch, nice. :)

I'd never thought of using stdin with ZeroMQ sockets, it's a neat mix.

On Thu, Mar 13, 2014 at 10:39 PM, Michael Haberler <mail17 at mah.priv.at> wrote:
>
> Am 13.03.2014 um 22:24 schrieb Pieter Hintjens <ph at imatix.com>:
>
>> I think removing the check is fine. If socket=NULL and fd=0 is a valid
>> combination, the code shouldn't treat it as an error. In any case this
>> isn't documented behavior in any way, so you are free to change it.
>
>
> thanks, PR sent
>
> here is the bonus gist conditional on this patch:  using libreadline in zloop
>
>   https://gist.github.com/mhaberler/9537478
>
> - Michael
>
>
>> On Thu, Mar 13, 2014 at 9:09 PM, Michael Haberler <mail17 at mah.priv.at> wrote:
>>> trying to use zloop for reading with libreadline on stdin, while handling other events
>>>
>>> this doesnt work because fd 0 is considered invalid in zloop.c:328 ; if I disable the check that works just fine
>>>
>>> I see two ways to resolve the situation:
>>>
>>> - consider a zmq_pollitem with socket=NULL and fd=0 as valid, to mean: poll on fd 0
>>> - explicitly set an invalid fd to -1, which is an API change
>>>
>>> I would prefer the first option - please advise
>>>
>>> - Michael
>>>
>>>
>>> int
>>> zloop_poller (zloop_t *self, zmq_pollitem_t *item, zloop_fn handler, void *arg)
>>> {
>>>    assert (self);
>>>
>>>    // suggestion: remove this test:
>>>    if (!item->socket && !item->fd)
>>>        return -1;
>>> _______________________________________________
>>> zeromq-dev mailing list
>>> zeromq-dev at lists.zeromq.org
>>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>> _______________________________________________
>> zeromq-dev mailing list
>> zeromq-dev at lists.zeromq.org
>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev



More information about the zeromq-dev mailing list