unix_msg: add a test for dgram socket caching
authorRalph Boehme <slow@samba.org>
Fri, 19 Aug 2016 10:02:12 +0000 (12:02 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 13 Sep 2016 02:11:30 +0000 (04:11 +0200)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Sep 13 04:11:30 CEST 2016 on sn-devel-144

source3/lib/unix_msg/tests.c

index 9a15f9dff1e01559279a472cf66145f7bccab216..c743c3796142c5f57aea6e5ad78a3c6f81a5f27f 100644 (file)
@@ -126,6 +126,36 @@ int main(void)
 
        expect_messages(ev, &state, 1);
 
+       printf("test send queue caching\n");
+
+       /*
+        * queues are cached for some time, so this tests sending
+        * still works after the cache expires and the queue was
+        * freed.
+        */
+       sleep(SENDQ_CACHE_TIME_SECS + 1);
+       ret = tevent_loop_once(ev);
+       if (ret == -1) {
+               fprintf(stderr, "tevent_loop_once failed: %s\n",
+                       strerror(errno));
+               exit(1);
+       }
+
+       msg = random();
+       iov.iov_base = &msg;
+       iov.iov_len = sizeof(msg);
+       state.buf = &msg;
+       state.buflen = sizeof(msg);
+
+       ret = unix_msg_send(ctx1, &addr2, &iov, 1, NULL, 0);
+       if (ret != 0) {
+               fprintf(stderr, "unix_msg_send failed: %s\n",
+                       strerror(ret));
+               return 1;
+       }
+
+       expect_messages(ev, &state, 1);
+
        printf("sending six large, interleaved messages\n");
 
        for (i=0; i<sizeof(buf); i++) {