From 99ca565bb6bf3729df3a1ec6ceeb2a58211751f5 Mon Sep 17 00:00:00 2001
From: Philippe PITTOLI
Date: Sat, 10 Sep 2016 02:54:53 +0200
Subject: [PATCH] pubsub: eq test channels -- fixed
---
lib/communication.c | 2 ++
lib/pubsubd.c | 3 ++-
pubsub/test-gen-new-process.sh | 2 +-
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/lib/communication.c b/lib/communication.c
index 68030ce..31f41a9 100644
--- a/lib/communication.c
+++ b/lib/communication.c
@@ -162,6 +162,8 @@ int srv_get_new_process (const struct service *srv, struct process *p)
}
}
+ if (buf != NULL)
+ free (buf);
srv_process_gen (p, pid, index, version);
return 0;
diff --git a/lib/pubsubd.c b/lib/pubsubd.c
index e07c7db..d1619dd 100644
--- a/lib/pubsubd.c
+++ b/lib/pubsubd.c
@@ -116,7 +116,8 @@ struct channel * pubsubd_channel_get (struct channels *chans, struct channel *c)
int
pubsubd_channel_eq (const struct channel *c1, const struct channel *c2)
{
- return (strncmp (c1->chan, c2->chan, c1->chanlen) == 0);
+ return c1->chanlen == c2->chanlen &&
+ strncmp (c1->chan, c2->chan, c1->chanlen) == 0;
}
// SUBSCRIBER
diff --git a/pubsub/test-gen-new-process.sh b/pubsub/test-gen-new-process.sh
index e6aad3a..67d6699 100755
--- a/pubsub/test-gen-new-process.sh
+++ b/pubsub/test-gen-new-process.sh
@@ -3,5 +3,5 @@
for i in $(seq 1 10)
do
echo "${i} 1 1 pub chan${i}" > /tmp/ipc/gen
- sleep 1
+ sleep 0.1
done