malamute icon indicating copy to clipboard operation
malamute copied to clipboard

mlm_client_send returns OK when no message was sent

Open malanka opened this issue 8 years ago • 3 comments

Hi,

simple example:

# include <malamute.h>

int main () {
    mlm_client_t *client = mlm_client_new();
    mlm_client_connect (client, "ipc://@/malamute", 1000, "myname");

    zmsg_t* msg = zmsg_new ();
    int rv = mlm_client_send (client, "subject", &msg);
    printf ("rv=%d\n", rv);
    mlm_client_destroy (&client);
    return 0;
}

I would expect mlm_client_send return -1 (as message was NOT actually send), but unfortunately it returned 0.

mlm_client_set_producer was intentionally omitted.

malanka avatar Aug 23 '16 14:08 malanka

+1 : according to recent bugs our team dealt with, this misbehavior was still in place, and bit us with some collateral damage.

jimklimov avatar Sep 04 '17 15:09 jimklimov

man zmq_msg_send

 Note
 A successful invocation of zmq_msg_send() does not indicate that the message has been
 transmitted to the network, only that it has been queued on the socket and 0MQ has assumed
 responsibility for the message.

All messages are sent asynchronously, so the synchronous API call cannot know if the message has been sent over the network or not. Only if there were problems when creating it and queueing it up (or HWMs were full, etc)

bluca avatar Sep 04 '17 15:09 bluca

According to our devs (and sorry if I'm playing broken phone here):

(our original issue in our project) is technically resolved by malamute upstream/master - send on unset stream behaves properly, but puts agent into state where calls to set consumer/producer fail. I'm not sure I consider that a bug. (The case was: ) We get a request to publish something before we set the stream, we try to publish, we try to set the stream and the last call fails. The concrete issue was resolved by fixing our race condition, now I am just trying to see if there is something Malamute can do to prevent it from happening again.

So that's about all the summary I have to forward at this time :)

jimklimov avatar Sep 04 '17 20:09 jimklimov