소스 검색

don't use pthread_once when there is no danger in race

Rich Felker 14 년 전
부모
커밋
02eff258c6
1개의 변경된 파일5개의 추가작업 그리고 2개의 파일을 삭제
  1. 5 2
      src/thread/cancel_impl.c

+ 5 - 2
src/thread/cancel_impl.c

@@ -71,8 +71,11 @@ static void init_cancellation()
 
 int pthread_cancel(pthread_t t)
 {
-	static pthread_once_t once;
-	pthread_once(&once, init_cancellation);
+	static int init;
+	if (!init) {
+		init_cancellation();
+		init = 1;
+	}
 	a_store(&t->cancel, 1);
 	return pthread_kill(t, SIGCANCEL);
 }