Klaus Demo nginx / eeb7212
Thread pools: memory barriers in task completion notifications. The ngx_thread_pool_done object isn't volatile, and at least some compilers assume that it is permitted to reorder modifications of volatile and non-volatile objects. Added appropriate ngx_memory_barrier() calls to make sure all modifications will happen before the lock is released. Reported by Mindaugas Rasiukevicius, http://mailman.nginx.org/pipermail/nginx-devel/2016-April/008160.html. Maxim Dounin 6 years ago
1 changed file(s) with 4 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
344344 *ngx_thread_pool_done.last = task;
345345 ngx_thread_pool_done.last = &task->next;
346346
347 ngx_memory_barrier();
348
347349 ngx_unlock(&ngx_thread_pool_done_lock);
348350
349351 (void) ngx_notify(ngx_thread_pool_handler);
364366 task = ngx_thread_pool_done.first;
365367 ngx_thread_pool_done.first = NULL;
366368 ngx_thread_pool_done.last = &ngx_thread_pool_done.first;
369
370 ngx_memory_barrier();
367371
368372 ngx_unlock(&ngx_thread_pool_done_lock);
369373