<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html><body style='font-size: 10pt; font-family: Verdana,Geneva,sans-serif'>
<p>Hi,</p>
<p>I've forgotten to free the shmem, thus enclosed an amendment with clean-up, relative last changeset.</p>
<p>Regards,<br />sebres.</p>
<p> </p>
<p>10.06.2015 21:48, Sergey Brester:</p>
<blockquote type="cite" style="padding-left:5px; border-left:#1010ff 2px solid; margin-left:5px"><!-- html ignored --><!-- head ignored --><!-- meta ignored -->
<p>Hi,</p>
<p>enclosed you will find an attached changeset, that contains fix for windows issue with multiple workers (once listening - only one made any work).</p>
<p>If someone needs a git version of it:</p>
<p><a href="https://github.com/sebres/nginx/pull/1/files">https://github.com/sebres/nginx/pull/1/files</a></p>
<p><a href="https://github.com/sebres/nginx/pull/1">Here</a> you may find a benchmark comparison for that (1 worker column - measured before fix).</p>
<p>--</p>
<p>Shortly about fix algorithm (changes related are marked as [*], unchanged - [-]):</p>
<p>- master process create all listener;</p>
<p>- [cycle] master process create a worker;</p>
<p>* [win32] master calls `ngx_share_listening_sockets`: each listener share (inheritance) info for pid of this worker ("cloned" via WSADuplicateSocket), that will be saved in shmem;</p>
<p>- master process wait until worker will send an event "worker_nnn";</p>
<p>* [win32] worker process executes `ngx_get_listening_share_info` to obtain shared info, protocol structure that can be used to create a new socket descriptor for a shared socket;</p>
<p>* [win32] worker process creates all listener sockets using given shared info of master;</p>
<p>- worker process sets an event "worker_nnn";</p>
<p>- master process create next worker, repeat [cycle].</p>
<p>--</p>
<p>@Maxim Dounin:<br />1) your suggested way with shared handle and bInheritHandle does not work, because of:<br />[quote]<br />Sockets. No error is returned, but the duplicate handle may not be recognized by Winsock at the target process. Also, using <strong>DuplicateHandle</strong> interferes with internal reference counting on the underlying object. <br />To duplicate a socket handle, use the <strong>WSADuplicateSocket</strong> function.<br />[/quote]</p>
<p>2) proposal to use an environment instead of shared memory can not work also, because sharing via WSADuplicateSocket should already know a pid of target process, that uses this handle - specially shared for each worker.</p>
<p>BTW, using of `accept_mutex` was disallowed for win32, cause of possible deadlock if grabbed by a process which can't accept connections. Because, this is fixed now, I have removed this "restriction" in separated commit.<br />But I think, accept_mutex is not needed in win32 resp. with accept_mutex it is much slower as without him. So, whats about set default of `accept_mutex` to `off` on windows platform?</p>
<p>BTW[2], I have executed extensive tests of this fix, also with reloading (increase/decrease `worker_processes`), restarting, as well as auto-restarting of worker, if it was "crashed" (ex.: have sporadically killed some worker).</p>
<p>Regards,<br />Serg G. Brester (aka sebres).</p>
<p> </p>
<div> </div>
<!-- html ignored --><br />
<pre>_______________________________________________
nginx-devel mailing list
<a href="mailto:nginx-devel@nginx.org">nginx-devel@nginx.org</a>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx-devel">http://mailman.nginx.org/mailman/listinfo/nginx-devel</a>
</pre>
</blockquote>
</body></html>