summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-10-17 12:41:31 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:59:58 -0500
commit6723885121554eebaf6e7a7720cb7afae57a3578 (patch)
tree0a1c627149f139259dd7cba6a66fa1ef7d743bfa
parent5882311fc46132e0f939d3297fd98787ebac41f7 (diff)
downloadsamba-6723885121554eebaf6e7a7720cb7afae57a3578.tar.gz
samba-6723885121554eebaf6e7a7720cb7afae57a3578.tar.bz2
samba-6723885121554eebaf6e7a7720cb7afae57a3578.zip
r3019: make the LOCAL-MESSAGING test a 2 process test
(This used to be commit 68890247c1247f5f9e299ac1f579052cd022e79f)
-rw-r--r--source4/torture/local/messaging.c60
1 files changed, 47 insertions, 13 deletions
diff --git a/source4/torture/local/messaging.c b/source4/torture/local/messaging.c
index 7302e3c119..057cdf0cea 100644
--- a/source4/torture/local/messaging.c
+++ b/source4/torture/local/messaging.c
@@ -29,42 +29,77 @@ static void pong_message(void *msg_ctx, void *private,
(*count)++;
}
+static void exit_message(void *msg_ctx, void *private,
+ uint32_t msg_type, servid_t src, DATA_BLOB *data)
+{
+ talloc_free(private);
+ exit(0);
+}
+
/*
test ping speed
*/
static BOOL test_ping_speed(TALLOC_CTX *mem_ctx)
{
struct event_context *ev = event_context_init(mem_ctx);
- void *msg_ctx1, *msg_ctx2;
+ void *msg_ctx;
int ping_count = 0;
int pong_count = 0;
BOOL ret = True;
- msg_ctx1 = messaging_init(mem_ctx, 1, ev);
- msg_ctx2 = messaging_init(mem_ctx, 2, ev);
+ if (fork() == 0) {
+ void *msg_ctx2 = messaging_init(mem_ctx, 1, ev);
+ messaging_register(msg_ctx2, mem_ctx, -1, exit_message);
+ event_loop_wait(ev);
+ exit(0);
+ }
+
+ sleep(2);
+
+ msg_ctx = messaging_init(mem_ctx, 2, ev);
- messaging_register(msg_ctx2, &pong_count, MSG_PONG, pong_message);
+ messaging_register(msg_ctx, &pong_count, MSG_PONG, pong_message);
start_timer();
printf("Sending pings for 10 seconds\n");
while (end_timer() < 10.0) {
DATA_BLOB data;
- data.data = "testing";
+ NTSTATUS status1, status2;
+
+ data.data = discard_const_p(char, "testing");
data.length = strlen(data.data);
- messaging_send(msg_ctx2, 1, MSG_PING, &data);
- messaging_send(msg_ctx2, 1, MSG_PING, NULL);
- ping_count += 2;
- event_loop_once(ev);
- event_loop_once(ev);
+ status1 = messaging_send(msg_ctx, 1, MSG_PING, &data);
+ status2 = messaging_send(msg_ctx, 1, MSG_PING, NULL);
+
+ if (!NT_STATUS_IS_OK(status1)) {
+ printf("Failed to send msg1 (%s) (done %d)\n", nt_errstr(status1), ping_count);
+ } else {
+ ping_count++;
+ }
+
+ if (!NT_STATUS_IS_OK(status2)) {
+ printf("Failed to send msg2 (%s) (done %d)\n", nt_errstr(status2), ping_count);
+ } else {
+ ping_count++;
+ }
+
+ while (pong_count < ping_count) {
+ event_loop_once(ev);
+ }
}
- printf("waiting for %d remaining replies\n", ping_count - pong_count);
+ printf("waiting for %d remaining replies (done %d)\n",
+ ping_count - pong_count, pong_count);
while (end_timer() < 30 && pong_count < ping_count) {
event_loop_once(ev);
}
+ printf("sending exit\n");
+ messaging_send(msg_ctx, 1, -1, NULL);
+ event_loop_once(ev);
+
if (ping_count != pong_count) {
printf("ping test failed! received %d, sent %d\n", pong_count, ping_count);
ret = False;
@@ -72,8 +107,7 @@ static BOOL test_ping_speed(TALLOC_CTX *mem_ctx)
printf("ping rate of %.0f messages/sec\n", (ping_count+pong_count)/end_timer());
- talloc_free(msg_ctx1);
- talloc_free(msg_ctx2);
+ talloc_free(msg_ctx);
event_context_destroy(ev);
return ret;