]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
tests/tls13/post-handshake-with-cert: avoid a race condition
authorAlexander Sosedkin <asosedkin@redhat.com>
Mon, 30 Aug 2021 17:26:49 +0000 (19:26 +0200)
committerAlexander Sosedkin <asosedkin@redhat.com>
Mon, 30 Aug 2021 17:46:03 +0000 (19:46 +0200)
A server tries to close connection and kill the client after reauth.
Client, in turn, attempts to send data in some cases.
This patch makes the server wait for the client to terminate first.

Signed-off-by: Alexander Sosedkin <asosedkin@redhat.com>
tests/tls13/post-handshake-with-cert.c

index 54159913dc256eb9c965f0dbc4783c30273abfab..d5912feb476c0f2523ed3696ca7541833ea7f007 100644 (file)
@@ -155,7 +155,7 @@ static void client(int fd, unsigned send_cert, unsigned max_auths)
                } while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
 
                if (ret != 0)
-                       fail("client: gnutls_reauth did not succeed as expected: %s\n", gnutls_strerror(ret));
+                       fail("client: gnutls_reauth %d did not succeed as expected: %s\n", i, gnutls_strerror(ret));
        }
 
 
@@ -203,7 +203,7 @@ static int hellos_callback(gnutls_session_t session, unsigned int htype,
        return 0;
 }
 
-static void server(int fd, int err, int type, unsigned max_auths)
+static void server(int fd, int err, int type, unsigned max_auths, int child)
 {
        int ret;
        char buffer[MAX_BUF + 1];
@@ -314,6 +314,8 @@ static void server(int fd, int err, int type, unsigned max_auths)
                        fail("server: gnutls_reauth did not succeed as expected: %s\n", gnutls_strerror(ret));
        }
 
+       waitpid(child, NULL, 0);
+
        close(fd);
        gnutls_deinit(session);
 
@@ -364,8 +366,7 @@ void start(const char *name, int err, int type, unsigned max_auths, unsigned sen
        if (child) {
                /* parent */
                close(fd[1]);
-               server(fd[0], err, type, max_auths);
-               kill(child, SIGTERM);
+               server(fd[0], err, type, max_auths, child);
        } else {
                close(fd[0]);
                client(fd[1], send_cert, max_auths);