msgtest fd-passing
authorStefan Metzmacher <metze@samba.org>
Fri, 5 Sep 2014 23:14:22 +0000 (01:14 +0200)
committerStefan Metzmacher <metze@samba.org>
Mon, 10 Feb 2020 13:37:55 +0000 (14:37 +0100)
source3/torture/msgtest.c

index 1d2a8a9b1c86275a74d6cd11ec23cd6d6858e3a4..dbaf6a802370b6a237cb253545059e29619b2c96 100644 (file)
@@ -47,6 +47,8 @@ static void pong_message(struct messaging_context *msg_ctx,
        char buf[12];
        int ret;
        TALLOC_CTX *frame = talloc_stackframe();
+       int fds[1] = { 0 };
+       NTSTATUS status;
 
        smb_init_locale();
 
@@ -74,8 +76,24 @@ static void pong_message(struct messaging_context *msg_ctx,
        messaging_register(msg_ctx, NULL, MSG_PONG, pong_message);
 
        for (i=0;i<n;i++) {
-               messaging_send(msg_ctx, pid_to_procid(pid), MSG_PING,
-                              &data_blob_null);
+               status = messaging_send(msg_ctx, pid_to_procid(pid), MSG_PING,
+                                       &data_blob_null);
+               if (!NT_STATUS_IS_OK(status)) {
+                       fprintf(stderr, "%s:%s: error: %s\n",
+                               __location__, __func__,
+                               nt_errstr(status));
+                       TALLOC_FREE(frame);
+                       exit(1);
+               }
+               status = messaging_send_iov(msg_ctx, pid_to_procid(pid),
+                                           MSG_PING, NULL, 0, fds, 1);
+               if (!NT_STATUS_IS_OK(status)) {
+                       fprintf(stderr, "%s:%s: error: %s\n",
+                               __location__, __func__,
+                               nt_errstr(status));
+                       TALLOC_FREE(frame);
+                       exit(1);
+               }
        }
 
        while (pong_count < i) {
@@ -91,10 +109,24 @@ static void pong_message(struct messaging_context *msg_ctx,
        strlcpy(buf, "1234567890", sizeof(buf));
 
        for (i=0;i<n;i++) {
-               messaging_send(msg_ctx, messaging_server_id(msg_ctx), MSG_PING,
-                              &data_blob_null);
-               messaging_send_buf(msg_ctx, messaging_server_id(msg_ctx),
-                                  MSG_PING,(uint8_t *)buf, 11);
+               status = messaging_send(msg_ctx, messaging_server_id(msg_ctx),
+                                       MSG_PING, &data_blob_null);
+               if (!NT_STATUS_IS_OK(status)) {
+                       fprintf(stderr, "%s:%s: error: %s\n",
+                               __location__, __func__,
+                               nt_errstr(status));
+                       TALLOC_FREE(frame);
+                       exit(1);
+               }
+               status = messaging_send_buf(msg_ctx, messaging_server_id(msg_ctx),
+                                           MSG_PING, (uint8_t *)buf, 11);
+               if (!NT_STATUS_IS_OK(status)) {
+                       fprintf(stderr, "%s:%s: error: %s\n",
+                               __location__, __func__,
+                               nt_errstr(status));
+                       TALLOC_FREE(frame);
+                       exit(1);
+               }
        }
 
        /*
@@ -138,6 +170,10 @@ static void pong_message(struct messaging_context *msg_ctx,
                                                   msg_ctx, pid_to_procid(pid),
                                                   MSG_PING, &data_blob_null)))
                           ping_count++;
+                       if(NT_STATUS_IS_OK(messaging_send_iov(
+                                                  msg_ctx, pid_to_procid(pid),
+                                                  MSG_PING, NULL, 0, fds, 1)))
+                          ping_count++;
 
                        while (ping_count > pong_count + 20) {
                                ret = tevent_loop_once(evt_ctx);