[zeromq-dev] czmq v3.0.0: zsys_set_logsender, bind vs connect issue - tentative patch
Pieter Hintjens
ph at imatix.com
Wed May 20 08:52:34 CEST 2015
Right, now we have to choose between multiple processes or multiple
loggers... Can you use distinct endpoints per process?
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
More information about the zeromq-dev
mailing list