pthreadpool: Fix deadlock
authorVolker Lendecke <vl@samba.org>
Tue, 12 Dec 2017 22:07:39 +0000 (23:07 +0100)
committerChristof Schmitt <cs@samba.org>
Wed, 13 Dec 2017 03:46:12 +0000 (04:46 +0100)
Christof's idea from

https://lists.samba.org/archive/samba-technical/2017-December/124384.html

was that the thread already exited. It could also be that the thread is
not yet idle when the new pthreadpool_add_jobs comes around the corner.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Christof Schmitt <cs@samba.org>
Autobuild-User(master): Christof Schmitt <cs@samba.org>
Autobuild-Date(master): Wed Dec 13 04:46:12 CET 2017 on sn-devel-144

lib/pthreadpool/tests_cmocka.c

index 75a935fa42cba765964d43995bbe44cd3429a607..9753d212e1ce9620d19eb18d90f15cb76c90a3ba 100644 (file)
@@ -28,6 +28,7 @@
 #include <pthreadpool_tevent.h>
 
 #include <cmocka.h>
+#include <poll.h>
 
 struct pthreadpool_tevent_test {
        struct tevent_context *ev;
@@ -152,6 +153,8 @@ static void test_create(void **state)
        assert_return_code(ret, 0);
        assert_false(in_main_thread);
 
+       poll(NULL, 0, 10);
+
        /*
         * Workerthread will still be active for a second; immediately
         * running another job will also use the worker thread, even