torture3: Reproducer for bug 10284
authorVolker Lendecke <vl@samba.org>
Thu, 21 Nov 2013 15:16:33 +0000 (16:16 +0100)
committerVolker Lendecke <vl@samba.org>
Tue, 26 Nov 2013 21:53:04 +0000 (22:53 +0100)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Tue Nov 26 22:53:04 CET 2013 on sn-devel-104

source3/selftest/tests.py
source3/torture/proto.h
source3/torture/test_msg.c
source3/torture/torture.c

index baa0f2fd82c88ad0d84cf8a9229acb0d70078c85..df88f9dfb977f71ec056dd0a1a5a14a38957eb1d 100755 (executable)
@@ -64,6 +64,7 @@ tests = ["FDPASS", "LOCK1", "LOCK2", "LOCK3", "LOCK4", "LOCK5", "LOCK6", "LOCK7"
         "CLEANUP1",
         "CLEANUP2",
         "CLEANUP4",
+        "LOCAL-MSG2",
         "BAD-NBT-SESSION"]
 
 for t in tests:
index d430aef5d8956374d2781fcd6e374f546c6c2c4b..b7eacdf047f9d736cfd50b86e6b771e3937426c1 100644 (file)
@@ -107,6 +107,7 @@ bool run_cleanup3(int dummy);
 bool run_cleanup4(int dummy);
 bool run_ctdb_conn(int dummy);
 bool run_msg_test(int dummy);
+bool run_msg_test2(int dummy);
 bool run_notify_bench2(int dummy);
 bool run_notify_bench3(int dummy);
 bool run_dbwrap_watch1(int dummy);
index 2171598ab8f92e0a89449d96af07a0b9662fbc24..d57379ddf09296125ab5e7d976bd873405ef2e80 100644 (file)
@@ -129,3 +129,89 @@ bool run_msg_test(int dummy)
        TALLOC_FREE(ev);
        return (ret == 0);
 }
+
+/*
+ * Reproducer for bug 10284
+ */
+
+static void msg_callback(struct tevent_req *subreq);
+
+struct msg_test2_state {
+       struct tevent_context *ev;
+       struct messaging_context *msg;
+       struct msg_channel *channel;
+       struct messaging_rec *rec;
+       struct tevent_req *req;
+};
+
+bool run_msg_test2(int dummy)
+{
+       struct msg_test2_state s;
+       NTSTATUS status;
+       int i, ret;
+
+       s.ev = samba_tevent_context_init(talloc_tos());
+       if (s.ev == NULL) {
+               fprintf(stderr, "tevent_context_init failed\n");
+               return false;
+       }
+
+       s.msg = messaging_init(s.ev, s.ev);
+       if (s.msg == NULL) {
+               fprintf(stderr, "messaging_init failed\n");
+               return false;
+       }
+
+       ret = msg_channel_init(s.ev, s.msg, MSG_PING, &s.channel);
+       if (ret != 0) {
+               fprintf(stderr, "msg_channel_init returned %s\n",
+                       strerror(ret));
+               return false;
+       }
+
+       status = messaging_send(s.msg, messaging_server_id(s.msg), MSG_PING,
+                               &data_blob_null);
+       if (!NT_STATUS_IS_OK(status)) {
+               fprintf(stderr, "messaging_send returned %s\n",
+                       nt_errstr(status));
+               return false;
+       }
+
+       ret = tevent_loop_once(s.ev);
+       if (ret == -1) {
+               fprintf(stderr, "tevent_loop_once failed: %s\n",
+                       strerror(errno));
+               return false;
+       }
+
+       s.req = msg_read_send(s.ev, s.ev, s.channel);
+       if (s.req == NULL) {
+               fprintf(stderr, "msg_read_send failed\n");
+               return false;
+       }
+       tevent_req_set_callback(s.req, msg_callback, &s);
+
+       status = messaging_send(s.msg, messaging_server_id(s.msg), MSG_PING,
+                               &data_blob_null);
+       if (!NT_STATUS_IS_OK(status)) {
+               fprintf(stderr, "messaging_send returned %s\n",
+                       nt_errstr(status));
+               return false;
+       }
+
+       for (i=0; i<5; i++) {
+               tevent_loop_once(s.ev);
+       }
+
+       return true;
+}
+
+static void msg_callback(struct tevent_req *subreq)
+{
+       struct msg_test2_state *s = _tevent_req_callback_data(subreq);
+       struct messaging_rec *rec;
+       msg_read_recv(subreq, NULL, &rec);
+       TALLOC_FREE(subreq);
+       subreq = msg_read_send(s->ev, s->ev, s->channel);
+       tevent_req_set_callback(subreq, msg_callback, s);
+}
index 37a44b2201c8215e5461c9147c30aaccabaf6793..6789d8529d47eb8f03962b077dcf353a89c7f756 100644 (file)
@@ -9573,6 +9573,7 @@ static struct {
        { "LOCAL-TALLOC-DICT", run_local_talloc_dict, 0},
        { "LOCAL-CTDB-CONN", run_ctdb_conn, 0},
        { "LOCAL-MSG", run_msg_test, 0},
+       { "LOCAL-MSG2", run_msg_test2, 0},
        { "LOCAL-DBWRAP-WATCH1", run_dbwrap_watch1, 0 },
        { "LOCAL-BASE64", run_local_base64, 0},
        { "LOCAL-RBTREE", run_local_rbtree, 0},