summaryrefslogtreecommitdiffstats
path: root/source3/torture/msgtest.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2014-04-22 16:07:18 -0700
committerJeremy Allison <jra@samba.org>2014-04-24 00:50:55 +0200
commitea27382ef40650f1a8310bce02fe60c0a94fa121 (patch)
tree1a702b58991de85c6e397595ac1d5c71c1e3e313 /source3/torture/msgtest.c
parent4fa1235cda2d9e1c98e80c5e451aef5be51ffd35 (diff)
downloadsamba-ea27382ef40650f1a8310bce02fe60c0a94fa121.tar.gz
samba-ea27382ef40650f1a8310bce02fe60c0a94fa121.tar.xz
samba-ea27382ef40650f1a8310bce02fe60c0a94fa121.zip
s3: torture - Fix racy assumption in original messaging test.
Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: "Stefan (metze) Metzmacher" <metze@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Thu Apr 24 00:50:55 CEST 2014 on sn-devel-104
Diffstat (limited to 'source3/torture/msgtest.c')
-rw-r--r--source3/torture/msgtest.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/source3/torture/msgtest.c b/source3/torture/msgtest.c
index 32f4b04cf0..07a7b6dbe8 100644
--- a/source3/torture/msgtest.c
+++ b/source3/torture/msgtest.c
@@ -85,7 +85,7 @@ static void pong_message(struct messaging_context *msg_ctx,
}
}
- /* Now test that the duplicate filtering code works. */
+ /* Ensure all messages get through to ourselves. */
pong_count = 0;
strlcpy(buf, "1234567890", sizeof(buf));
@@ -97,15 +97,25 @@ static void pong_message(struct messaging_context *msg_ctx,
MSG_PING,(uint8 *)buf, 11);
}
- for (i=0;i<n;i++) {
+ /*
+ * We have to loop at least 2 times for
+ * each message as local ping messages are
+ * handled by an immediate callback, that
+ * has to be dispatched, which sends a pong
+ * message, which also has to be dispatched.
+ * Above we sent 2*n messages, which means
+ * we have to dispatch 4*n times.
+ */
+
+ while (pong_count < n*2) {
ret = tevent_loop_once(evt_ctx);
if (ret != 0) {
break;
}
}
- if (pong_count != 2) {
- fprintf(stderr, "Duplicate filter failed (%d).\n", pong_count);
+ if (pong_count != 2*n) {
+ fprintf(stderr, "Message count failed (%d).\n", pong_count);
}
/* Speed testing */