The branch, master has been updated
       via  9daf40c talloc: Fix documentation typo
       via  33c0f55 ctdb-tests: Avoid race condition in sock_daemon test 5
      from  ac9d528 docs: Remove prog_guide4.txt

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 9daf40c55af61081abca663c7250f103d5b2a0df
Author: Martin Schwenke <mar...@meltin.net>
Date:   Thu Jan 18 16:08:15 2018 +1100

    talloc: Fix documentation typo
    
    Signed-off-by: Martin Schwenke <mar...@meltin.net>
    Reviewed-by: Amitay Isaacs <ami...@gmail.com>
    
    Autobuild-User(master): Martin Schwenke <mart...@samba.org>
    Autobuild-Date(master): Mon Jan 22 11:11:38 CET 2018 on sn-devel-144

commit 33c0f5599d93a34619c8f37945f79a6e399a1b5e
Author: Amitay Isaacs <ami...@gmail.com>
Date:   Mon Jan 22 12:54:49 2018 +1100

    ctdb-tests: Avoid race condition in sock_daemon test 5
    
    This test fails when it takes more than 10s to run.  This can occur
    when the system is loaded and socket-wrapper is used.
    
    Signed-off-by: Amitay Isaacs <ami...@gmail.com>
    Reviewed-by: Martin Schwenke <mar...@meltin.net>

-----------------------------------------------------------------------

Summary of changes:
 ctdb/tests/src/sock_daemon_test.c | 26 +++++++++++++++++---------
 lib/talloc/talloc.h               |  2 +-
 2 files changed, 18 insertions(+), 10 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ctdb/tests/src/sock_daemon_test.c 
b/ctdb/tests/src/sock_daemon_test.c
index 5641d37..ebc0b85 100644
--- a/ctdb/tests/src/sock_daemon_test.c
+++ b/ctdb/tests/src/sock_daemon_test.c
@@ -668,7 +668,8 @@ static void test4(TALLOC_CTX *mem_ctx, const char *pidfile,
  * Start daemon, multiple client connects, requests, disconnects
  */
 
-#define TEST5_MAX_CLIENTS      10
+#define TEST5_VALID_CLIENTS    10
+#define TEST5_MAX_CLIENTS      100
 
 struct test5_pkt {
        uint32_t len;
@@ -710,7 +711,8 @@ static void test5_client_callback(uint8_t *buf, size_t 
buflen,
        state->done = true;
 }
 
-static int test5_client(const char *sockpath, int id)
+static int test5_client(const char *sockpath, int id, pid_t pid_server,
+                       pid_t *client_pid)
 {
        pid_t pid;
        int fd[2];
@@ -760,7 +762,9 @@ static int test5_client(const char *sockpath, int id)
                close(fd[0]);
                state.fd = -1;
 
-               sleep(10);
+               while (kill(pid_server, 0) == 0 || errno != ESRCH) {
+                       sleep(1);
+               }
                exit(0);
        }
 
@@ -775,6 +779,7 @@ static int test5_client(const char *sockpath, int id)
 
        close(fd[0]);
 
+       *client_pid = pid;
        return ret;
 }
 
@@ -788,12 +793,12 @@ static bool test5_connect(struct sock_client_context 
*client,
        struct test5_server_state *state =
                (struct test5_server_state *)private_data;
 
-       if (state->num_clients == TEST5_MAX_CLIENTS) {
+       if (state->num_clients == TEST5_VALID_CLIENTS) {
                return false;
        }
 
        state->num_clients += 1;
-       assert(state->num_clients <= TEST5_MAX_CLIENTS);
+       assert(state->num_clients <= TEST5_VALID_CLIENTS);
        return true;
 }
 
@@ -925,6 +930,7 @@ static void test5(TALLOC_CTX *mem_ctx, const char *pidfile,
        pid_t pid_server, pid;
        int fd[2], ret, i;
        ssize_t n;
+       pid_t client_pid[TEST5_MAX_CLIENTS];
 
        pid = getpid();
 
@@ -968,16 +974,18 @@ static void test5(TALLOC_CTX *mem_ctx, const char 
*pidfile,
 
        close(fd[0]);
 
-       for (i=0; i<100; i++) {
-               ret = test5_client(sockpath, i);
-               if (i < TEST5_MAX_CLIENTS) {
+       for (i=0; i<TEST5_MAX_CLIENTS; i++) {
+               ret = test5_client(sockpath, i, pid_server, &client_pid[i]);
+               if (i < TEST5_VALID_CLIENTS) {
                        assert(ret == i+1);
                } else {
                        assert(ret == 0);
                }
        }
 
-       for (i=0; i<100; i++) {
+       for (i=TEST5_MAX_CLIENTS-1; i>=0; i--) {
+               kill(client_pid[i], SIGKILL);
+
                pid = wait(&ret);
                assert(pid != -1);
        }
diff --git a/lib/talloc/talloc.h b/lib/talloc/talloc.h
index 618430a..dda308d 100644
--- a/lib/talloc/talloc.h
+++ b/lib/talloc/talloc.h
@@ -1226,7 +1226,7 @@ size_t talloc_array_length(const void *ctx);
  *
  * @code
  *     ptr = talloc_array(ctx, type, count);
- *     if (ptr) memset(ptr, sizeof(type) * count);
+ *     if (ptr) memset(ptr, 0, sizeof(type) * count);
  * @endcode
  */
 void *talloc_zero_array(const void *ctx, #type, unsigned count);


-- 
Samba Shared Repository

Reply via email to