RFC on C Library Safety in Nginx Module Callback

Sinan Kaya Okaya at kernel.org
Fri Jun 14 18:35:28 UTC 2019


On 6/14/2019 8:51 AM, Ranier Vf wrote:
> Maybe this help.
> http://www.doublersolutions.com/docs/dce/osfdocs/htmls/develop/appdev/Appde193.htm
> 
> "One solution to the problem of calling *fork( )* in a multithreaded
> environment exists. (Note that this method will not work for server
> application code or any other application code that is invoked by a
> callback from a library.) Before an application performs a *fork( )*
> followed by something other than *exec( )*, it must cancel all of the
> other threads. After it joins the canceled threads, it can safely *fork(
> )* because it is the only thread in existence. This means that libraries
> that create threads must establish cancel handlers that propagate the
> cancel to the created threads and join them. The application should save
> enough state so that the threads can be recreated and restarted after
> the *fork( )* processing completes. "

Yes, this helps. As long as nginx has been designed to honor these
rules, we can make our application do the same thing.



More information about the nginx-devel mailing list