Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
githubposter12 opened this issue Oct 31, 2018 · 1 comment

Comments

@githubposter12
Copy link

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;
}
@vyskocilm
Copy link
Contributor

Hi, thanks for posting the fix. Would you mind to send a PullRequest (https://yangsu.github.io/pull-request-tutorial/). You can make this simple fix via web editor on GitHub, so no worries about git CLI. That way we can run CI, merge it and you'll be noted in a list of contributors :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants