[zeromq-dev] czmq v3.0.0: zsys_set_logsender, bind vs connect issue - tentative patch
Pieter Hintjens
ph at imatix.com
Thu May 21 09:11:21 CEST 2015
Yes, this will be in the V3 release.
On Thu, May 21, 2015 at 8:25 AM, Michael Haberler <mail17 at mah.priv.at> wrote:
>
>> Am 20.05.2015 um 15:24 schrieb Pieter Hintjens <ph at imatix.com>:
>>
>> Since we want zsock semantics, s_logsender should be a zsock_t, simply.
>
> ok, PR pending - works as expected now
>
> can I ask these two patches to be picked onto an eventual V3 release ?
>
> thanks, Michael
>
>
>>
>> On Wed, May 20, 2015 at 3:00 PM, Michael Haberler <mail17 at mah.priv.at> wrote:
>>>
>>>> Am 20.05.2015 um 14:12 schrieb Pieter Hintjens <ph at imatix.com>:
>>>>
>>>> Swapping bind/connect by default breaks the API contract. However we
>>>> could use the CZMQ bind/connect syntax, see zsock_attach().
>>>
>>> fits the bill, will do a PR - but:
>>>
>>> zsock_attach works on sock_t, whereas s_logsender is a libzmq socket handle; I could:
>>>
>>> - rewrite s_logsender ff to use a zsock_t (nah)
>>> - a new wrapper function which wraps an existing libzmq socket handle into a zsock_t along the lines of zsys_socket() (will likely interfere on shutdown but might be generally useful)
>>> - replicate the zsock_attach logic in zsys_set_logsender
>>> - extract the zsock_attach logic into a function and use it in both places
>>>
>>> what would you recommend?
>>>
>>> - Michael
>>>
>>>>
>>>> On Wed, May 20, 2015 at 10:16 AM, Michael Haberler <mail17 at mah.priv.at> wrote:
>>>>>
>>>>>> Am 20.05.2015 um 08:52 schrieb Pieter Hintjens <ph at imatix.com>:
>>>>>>
>>>>>> Right, now we have to choose between multiple processes or multiple
>>>>>> loggers... Can you use distinct endpoints per process?
>>>>>
>>>>> I could in theory - at the expense of (IMU uselessly) complicating the cause - the log demon starts before all other processes and would have to guess/prepare several sockets?
>>>>>
>>>>> any issues with swapping bind to connect?
>>>>>
>>>>> - Michael
>>>>>
>>>>>>
>>>>>> On Wed, May 20, 2015 at 7:52 AM, Michael Haberler <mail17 at mah.priv.at> wrote:
>>>>>>> czmq: zsys_set_logsender() currently zmq_bind()s to an endpoint.
>>>>>>>
>>>>>>> That is fine in the inproc testcase as per zsys.c but fails if one has several processes which would like to log over an IPC socket, to say an existing log daemon. In this case the a second process doing zsys_set_logsender(ipc endpoint) fails the bind:
>>>>>>>
>>>>>>> // Bind to specified endpoint
>>>>>>> int rc = zmq_bind (s_logsender, endpoint);
>>>>>>> assert (rc == 0); <------ fail
>>>>>>>
>>>>>>> this would work if zsys_set_logsender() did a connect instead, and only the log subscriber did a bind.
>>>>>>>
>>>>>>>
>>>>>>> the following tentative patch cures the issue - should I prepare a PR?
>>>>>>>
>>>>>>> @@ -1315,11 +1315,11 @@ zsys_set_logsender (const char *endpoint)
>>>>>>> if (!s_logsender) {
>>>>>>> s_logsender = zsys_socket (ZMQ_PUB, NULL, 0);
>>>>>>> assert (s_logsender);
>>>>>>> }
>>>>>>> // Bind to specified endpoint
>>>>>>> - int rc = zmq_bind (s_logsender, endpoint);
>>>>>>> + int rc = zmq_connect (s_logsender, endpoint);
>>>>>>> assert (rc == 0);
>>>>>>> }
>>>>>>> else
>>>>>>> if (s_logsender) {
>>>>>>> zsys_close (s_logsender, NULL, 0);
>>>>>>> @@ -1551,11 +1551,11 @@ zsys_test (bool verbose)
>>>>>>> // Test logging system
>>>>>>> zsys_set_logident ("czmq_selftest");
>>>>>>> zsys_set_logsender ("inproc://logging");
>>>>>>> void *logger = zsys_socket (ZMQ_SUB, NULL, 0);
>>>>>>> assert (logger);
>>>>>>> - rc = zsocket_connect (logger, "inproc://logging");
>>>>>>> + rc = zsocket_bind (logger, "inproc://logging");
>>>>>>> assert (rc == 0);
>>>>>>> rc = zmq_setsockopt (logger, ZMQ_SUBSCRIBE, "", 0);
>>>>>>> assert (rc == 0);
>>>>>>>
>>>>>>> if (verbose) {
>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> 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
>>>> _______________________________________________
>>>> 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
>
> _______________________________________________
> 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