From 38d7235ab45334e0c88f97c1e5bc7d4814f59669 Mon Sep 17 00:00:00 2001 From: Sam Varshavchik Date: Tue, 27 Oct 2020 20:01:00 -0400 Subject: Fix LTO failure on F33. --- waitlib/testwait.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'waitlib/testwait.c') diff --git a/waitlib/testwait.c b/waitlib/testwait.c index fb0fe48..6020c36 100644 --- a/waitlib/testwait.c +++ b/waitlib/testwait.c @@ -1,5 +1,5 @@ /* -** Copyright 1998 - 2006 Double Precision, Inc. +** Copyright 1998 - 2020 Double Precision, Inc. ** See COPYING for distribution information. */ @@ -10,17 +10,24 @@ #include #include #include +#include /* Stress test waitlib.c */ #define NUMCHILDREN 100 /* Start 100 child processes */ #define INITCHILDREN 10 /* Start with these many child procs */ +pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; +pthread_cond_t cond = PTHREAD_COND_INITIALIZER; + static unsigned started, finished; static void reap_child(pid_t p, int dummy) { + pthread_mutex_lock(&mutex); ++finished; + pthread_cond_signal(&cond); + pthread_mutex_unlock(&mutex); } static RETSIGTYPE sighandler(int sig) @@ -87,13 +94,16 @@ char c; ; /* Shut gcc up */ close(pipefd[1]); close(pipefd2[0]); - while (started < NUMCHILDREN) if (start_child() == 0) _exit(0); alarm(30); + pthread_mutex_lock(&mutex); while (finished < started) - foobar(); + { + pthread_cond_wait(&cond, &mutex); + } + pthread_mutex_unlock(&mutex); exit(0); } -- cgit v1.2.3 From 0d4feee51d2c360c8f061c823b441afefddd07df Mon Sep 17 00:00:00 2001 From: Sam Varshavchik Date: Wed, 28 Oct 2020 21:25:13 -0400 Subject: Fix LTO problem on Fedora --- waitlib/testwait.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'waitlib/testwait.c') diff --git a/waitlib/testwait.c b/waitlib/testwait.c index 6020c36..a720e49 100644 --- a/waitlib/testwait.c +++ b/waitlib/testwait.c @@ -17,17 +17,13 @@ #define NUMCHILDREN 100 /* Start 100 child processes */ #define INITCHILDREN 10 /* Start with these many child procs */ -pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; -pthread_cond_t cond = PTHREAD_COND_INITIALIZER; - -static unsigned started, finished; +static unsigned started; +static int reap_pipefd[2]; static void reap_child(pid_t p, int dummy) { - pthread_mutex_lock(&mutex); - ++finished; - pthread_cond_signal(&cond); - pthread_mutex_unlock(&mutex); + if (write(reap_pipefd[1], "", 1) < 0) + ; /* shut up gcc */ } static RETSIGTYPE sighandler(int sig) @@ -65,8 +61,9 @@ int main() int pipefd[2]; int pipefd2[2]; char c; +unsigned finished=0; - if (pipe(pipefd) || pipe(pipefd2)) + if (pipe(reap_pipefd) || pipe(pipefd) || pipe(pipefd2)) { perror("pipe"); exit(1); @@ -74,7 +71,7 @@ char c; signal(SIGCHLD, sighandler); - started=finished=0; + started=0; while (started < INITCHILDREN) { if (start_child() == 0) @@ -99,11 +96,17 @@ char c; _exit(0); alarm(30); - pthread_mutex_lock(&mutex); while (finished < started) { - pthread_cond_wait(&cond, &mutex); + char c; + int n=read(reap_pipefd[0], &c, 1); + + if (n <= 0) + { + fprintf(stderr, "pipe error\n"); + exit(1); + } + ++finished; } - pthread_mutex_unlock(&mutex); exit(0); } -- cgit v1.2.3