torture3: Extend read3 for the "messaging target re-inits" failure
authorVolker Lendecke <vl@samba.org>
Thu, 7 Feb 2019 16:48:34 +0000 (17:48 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 14 Feb 2019 01:18:28 +0000 (02:18 +0100)
Do ping_pong a hundred times, re-initializing the msg_ctx every time.

https://bugzilla.samba.org/show_bug.cgi?id=13786

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
selftest/knownfail.d/local-messaging [new file with mode: 0644]
source3/torture/test_messaging_read.c

diff --git a/selftest/knownfail.d/local-messaging b/selftest/knownfail.d/local-messaging
new file mode 100644 (file)
index 0000000..46cf30c
--- /dev/null
@@ -0,0 +1 @@
+^samba3.smbtorture_s3.LOCAL-MESSAGING-READ3
index d3e4079074b4be43bf5e8ab4b482887121908591..555f084c040b7effcff2bd936b656f097b6cc944 100644 (file)
@@ -250,14 +250,13 @@ fail:
 }
 
 struct msg_pingpong_state {
-       uint8_t dummy;
+       struct messaging_context *msg_ctx;
 };
 
 static void msg_pingpong_done(struct tevent_req *subreq);
 
 static struct tevent_req *msg_pingpong_send(TALLOC_CTX *mem_ctx,
                                            struct tevent_context *ev,
-                                           struct messaging_context *msg_ctx,
                                            struct server_id dst)
 {
        struct tevent_req *req, *subreq;
@@ -269,13 +268,23 @@ static struct tevent_req *msg_pingpong_send(TALLOC_CTX *mem_ctx,
                return NULL;
        }
 
-       status = messaging_send_buf(msg_ctx, dst, MSG_PING, NULL, 0);
+       if (!tevent_req_set_endtime(req, ev, timeval_current_ofs(10, 0))) {
+               return tevent_req_post(req, ev);
+       }
+
+       state->msg_ctx = messaging_init(state, ev);
+       if (tevent_req_nomem(state->msg_ctx, req)) {
+               return tevent_req_post(req, ev);
+       }
+
+       status = messaging_send_buf(state->msg_ctx, dst, MSG_PING, NULL, 0);
        if (!NT_STATUS_IS_OK(status)) {
+               DBG_DEBUG("messaging_send_buf failed: %s\n", nt_errstr(status));
                tevent_req_error(req, map_errno_from_nt_status(status));
                return tevent_req_post(req, ev);
        }
 
-       subreq = messaging_read_send(state, ev, msg_ctx, MSG_PONG);
+       subreq = messaging_read_send(state, ev, state->msg_ctx, MSG_PONG);
        if (tevent_req_nomem(subreq, req)) {
                return tevent_req_post(req, ev);
        }
@@ -308,18 +317,17 @@ static int msg_pingpong_recv(struct tevent_req *req)
        return 0;
 }
 
-static int msg_pingpong(struct messaging_context *msg_ctx,
-                       struct server_id dst)
+static int msg_pingpong(struct server_id dst)
 {
        struct tevent_context *ev;
        struct tevent_req *req;
        int ret = ENOMEM;
 
-       ev = tevent_context_init(msg_ctx);
+       ev = tevent_context_init(talloc_tos());
        if (ev == NULL) {
                goto fail;
        }
-       req = msg_pingpong_send(ev, ev, msg_ctx, dst);
+       req = msg_pingpong_send(ev, ev, dst);
        if (req == NULL) {
                goto fail;
        }
@@ -398,7 +406,7 @@ bool run_messaging_read3(int dummy)
        pid_t child;
        int ready_pipe[2];
        int exit_pipe[2];
-       int ret;
+       int i, ret;
        char c;
        struct server_id dst;
        ssize_t written;
@@ -433,19 +441,15 @@ bool run_messaging_read3(int dummy)
                fprintf(stderr, "tevent_context_init failed\n");
                goto fail;
        }
-       msg_ctx = messaging_init(ev, ev);
-       if (msg_ctx == NULL) {
-               fprintf(stderr, "messaging_init failed\n");
-               goto fail;
-       }
 
-       dst = messaging_server_id(msg_ctx);
-       dst.pid = child;
+       dst = (struct server_id){ .pid = child, .vnn = NONCLUSTER_VNN, };
 
-       ret = msg_pingpong(msg_ctx, dst);
-       if (ret != 0){
-               fprintf(stderr, "msg_pingpong failed\n");
-               goto fail;
+       for (i=0; i<100; i++) {
+               ret = msg_pingpong(dst);
+               if (ret != 0){
+                       fprintf(stderr, "msg_pingpong failed\n");
+                       goto fail;
+               }
        }
 
        printf("Parent: telling child to exit\n");