From: Samuel Thibault Date: Wed, 4 May 2016 13:14:29 +0000 (+0200) Subject: aio: fix newp->running data race X-Git-Tag: glibc-2.24~284 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fd67a9cf7b733da082e4b6a5f25c19ea7921b4cd;p=thirdparty%2Fglibc.git aio: fix newp->running data race * sysdeps/pthread/aio_misc.c (__aio_enqueue_request): Do not write `running` field of `newp` when a thread was started to process it, since that thread will not take `__aio_requests_mutex`, and the field already has the proper value actually. --- diff --git a/ChangeLog b/ChangeLog index 45e8375e5f0..575c17f7a7f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2016-05-04 Samuel Thibault + + * sysdeps/pthread/aio_misc.c (__aio_enqueue_request): Do not write + `running` field of `newp` when a thread was started to process it, + since that thread will not take `__aio_requests_mutex`, and the field + already has the proper value actually. + 2016-05-04 Florian Weimer [BZ #19787] diff --git a/sysdeps/pthread/aio_misc.c b/sysdeps/pthread/aio_misc.c index f55570d23b5..faf139d9011 100644 --- a/sysdeps/pthread/aio_misc.c +++ b/sysdeps/pthread/aio_misc.c @@ -453,7 +453,11 @@ __aio_enqueue_request (aiocb_union *aiocbp, int operation) result = 0; } } + else + newp->running = running; } + else + newp->running = running; /* Enqueue the request in the run queue if it is not yet running. */ if (running == yes && result == 0) @@ -466,9 +470,7 @@ __aio_enqueue_request (aiocb_union *aiocbp, int operation) pthread_cond_signal (&__aio_new_request_notification); } - if (result == 0) - newp->running = running; - else + if (result != 0) { /* Something went wrong. */ __aio_free_request (newp);