Skip to content

malamute broker crashes if 2 clients connect with same address. Patch included #318

@githubposter12

Description

@githubposter12

Malamute cores if 2 clients connect with the same address instead of expiring the older client.
Here is patch.
Test case for crash is below.
Thanks.

diff --git a/src/mlm_server.c b/src/mlm_server.c
index f2f6cd2..597820c 100644
--- a/src/mlm_server.c
+++ b/src/mlm_server.c
@@ -714,7 +714,7 @@ client_expired (client_t *self)
 static void
 client_closed_connection (client_t *self)
 {
-    if (*self->address)
+    if (self->address)
         zsys_info ("client %u address='%s' - closed connection", self->unique_id, self->address);
 }
#include <malamute.h>

int main (int argc, char *argv [])
{
	int rc=0;
    //  Let's start a new Malamute broker
    zactor_t *broker = zactor_new (mlm_server, NULL);

    //  Switch on verbose tracing... this gets a little overwhelming so you
    //  can comment or delete this when you're bored with it:
    zsock_send (broker, "s", "VERBOSE");

   zstr_sendx (broker, "BIND", "tcp://*:12345", NULL);

    mlm_client_t *client1 = mlm_client_new ();
    assert (client1);
    rc = mlm_client_connect (client1, "tcp://127.0.0.1:12345", 1000, "client");
    assert (rc == 0);

    mlm_client_t *client2 = mlm_client_new ();
    assert (client2);
    rc = mlm_client_connect (client2, "tcp://127.0.0.1:12345", 1000, "client");
    assert (rc == 0);

    mlm_client_destroy(&client1);
    mlm_client_destroy(&client2);
    zactor_destroy(&broker);
    return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions