aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2016-06-15 12:59:10 +0000
committerWerner Koch <[email protected]>2016-06-15 12:59:10 +0000
commit7ed150201cc5058650cf9673a4e53720a37841c8 (patch)
treeeb44fc4f59a75b1f437cda113465ddfe5600a145
parentestream: Fix assertion failure due to es_flush. (diff)
downloadlibgpg-error-7ed150201cc5058650cf9673a4e53720a37841c8.tar.gz
libgpg-error-7ed150201cc5058650cf9673a4e53720a37841c8.zip
tests: Fix rare deadlock condition in t-poll.
* tests/t-poll.c (launch_thread): Use es_fileno before starting the thread. -- GnuPG-bug-id: 2257
-rw-r--r--tests/t-poll.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/tests/t-poll.c b/tests/t-poll.c
index 56b29c8..811f895 100644
--- a/tests/t-poll.c
+++ b/tests/t-poll.c
@@ -122,19 +122,22 @@ consumer_thread (void *argaddr)
static void
launch_thread (THREAD_RET_TYPE (*fnc)(void *), struct thread_arg *th)
{
+ int fd;
+
+ th->stop_me = 0;
+ fd = es_fileno (th->stream);
#ifdef _WIN32
th->thread = CreateThread (NULL, 0, fnc, th, 0, NULL);
if (!th->thread)
die ("creating thread '%s' failed: rc=%d", th->name, (int)GetLastError ());
- show ("thread '%s' launched (fd=%d)\n", th->name, es_fileno (th->stream));
+ show ("thread '%s' launched (fd=%d)\n", th->name, fd);
#elif USE_POSIX_THREADS
- th->stop_me = 0;
if (pthread_create (&th->thread, NULL, fnc, th))
die ("creating thread '%s' failed: %s\n", th->name, strerror (errno));
- show ("thread '%s' launched (fd=%d)\n", th->name, es_fileno (th->stream));
+ show ("thread '%s' launched (fd=%d)\n", th->name, fd);
# else /* no thread support */