Welcome! Log In Create A New Profile

Advanced

Re: Fix for ngx_unlock() and thus race conditions in AIO mechanism

Maxim Dounin
April 19, 2016 12:48PM
Hello!

On Tue, Apr 19, 2016 at 05:09:55PM +0100, Mindaugas Rasiukevicius wrote:

> Maxim Dounin <mdounin@mdounin.ru> wrote:
> > Patch that follows the same logic as used in ngx_update_time(), that is,
> > with an explicit ngx_memory_barrier() call before ngx_unlock(), and no
> > barrier semantics in ngx_unlock() itself:
>
> I can just point out that pretty much all spin-lock implementations
> provide memory ordering guarantees; this is 1990s discussion which has
> been settled by now with a consensus that certain ordering guarantees
> should be provided by the synchronisation primitives. If you will look
> into the kernels (be it Linux, BSD or Solaris -- it was Sun who de facto
> set the standard back in the day), libraries (say libpthread) or other
> projects, (e.g. PostgreSQL) -- you will find the right barrier in the
> unlock operation.
>
> If you do not provide these guarantees, then you provide something what
> is different from a textbook implementation of a spin-lock. It is rather
> dangerous and unlikely to prevent from bugs.

Sure, current behaviour of ngx_unlock() is different from a
textbook one, and we may consider changing it to something more
common, even if it means additional unneeded barriers in
ngx_update_time(). But changing semantics and fixing bugs are
distinct things and shouldn't be mixed whenever possible.

--
Maxim Dounin
http://nginx.org/

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Fix for ngx_unlock() and thus race conditions in AIO mechanism

Mindaugas Rasiukevicius 436 April 18, 2016 05:42PM

Re: Fix for ngx_unlock() and thus race conditions in AIO mechanism

Maxim Dounin 208 April 19, 2016 10:02AM

Re: Fix for ngx_unlock() and thus race conditions in AIO mechanism

Mindaugas Rasiukevicius 178 April 19, 2016 12:12PM

Re: Fix for ngx_unlock() and thus race conditions in AIO mechanism

Maxim Dounin 230 April 19, 2016 12:48PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 169
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready