NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/51885: [PATCH] tests/lib/libpthread/t_detach: eliminate races



The following reply was made to PR bin/51885; it has been noted by GNATS.

From: "Ngie Cooper (yaneurabeya)" <yaneurabeya%gmail.com@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: bin/51885: [PATCH] tests/lib/libpthread/t_detach: eliminate races
Date: Sun, 15 Jan 2017 13:00:47 -0800

 --Apple-Mail=_2A74C15A-C5A2-42F1-8F33-76776BCD3AF9
 Content-Transfer-Encoding: 7bit
 Content-Type: text/plain;
 	charset=us-ascii
 
 Patch attached.
 -Ngie
 
 --Apple-Mail=_2A74C15A-C5A2-42F1-8F33-76776BCD3AF9
 Content-Disposition: attachment;
 	filename=t_detach-defeat-races.patch
 Content-Type: application/octet-stream;
 	x-unix-mode=0644;
 	name="t_detach-defeat-races.patch"
 Content-Transfer-Encoding: 7bit
 
 Index: lib/libpthread/t_detach.c
 ===================================================================
 RCS file: /cvsroot/src/tests/lib/libpthread/t_detach.c,v
 retrieving revision 1.1
 diff -u -r1.1 t_detach.c
 --- lib/libpthread/t_detach.c	24 Mar 2011 13:52:04 -0000	1.1
 +++ lib/libpthread/t_detach.c	15 Jan 2017 20:54:32 -0000
 @@ -31,8 +31,9 @@
  #include <sys/cdefs.h>
  __RCSID("$NetBSD: t_detach.c,v 1.1 2011/03/24 13:52:04 jruoho Exp $");
  
 -#include <pthread.h>
  #include <errno.h>
 +#include <pthread.h>
 +#include <time.h>
  
  #include <atf-c.h>
  
 @@ -43,6 +44,7 @@
  static void *
  func(void *arg)
  {
 +	sleep(2);
  	return NULL;
  }
  
 @@ -72,14 +74,17 @@
  	 */
  	PTHREAD_REQUIRE(pthread_detach(t));
  
 +	sleep(1);
  	rv = pthread_join(t, NULL);
  	ATF_REQUIRE(rv == EINVAL);
  
 +	sleep(3);
 +
  	/*
  	 * As usual, ESRCH should follow if
  	 * we try to detach an invalid thread.
  	 */
 -	rv = pthread_cancel(NULL);
 +	rv = pthread_cancel(t);
  	ATF_REQUIRE(rv == ESRCH);
  }
  
 
 --Apple-Mail=_2A74C15A-C5A2-42F1-8F33-76776BCD3AF9--
 


Home | Main Index | Thread Index | Old Index