Fwd: Windows shmem fix: makes shared memory fully ASLR and DEP compliant (ea. cache zone, limit zone, etc.)
serg.brester at sebres.de
Mon Jun 8 19:56:16 UTC 2015
Back to my wish to fix a problem with multiple workers under windows...
Since we successful implemented shared memory on windows, it may be used
for proper sharing a socket descriptor for multiple workers.
Possible scenario can be found in this MSDN-article:
I need some help, to make the changes more nginx conform:
I have not yet decided which process will create/share a socket
(duplicate handle and set it to shared memory). The idea was to create
from master in ngx_event_process_init an initial shared memory with
empty socket descriptors. The first worker inside
ngx_open_listening_sockets may create a socket and duplicate a handle to
share it with all other workers (save it to shared memory).
The first problem would be the way windows does it - the (source)
process should know each target process handle to duplicate a socket
handle for it. So if a new worker will be created, it should "receive" a
new shared handle, duplicated specially for him.
So if not possible to do that somehow, only master process can create a
socket and duplicate handle for each worker, before create him. But this
will make the whole solution more complicated as now.
Another way is, to create child with CreateProcess and
bInheritHandles=1, and then save the first created socket handle in
shared memory, but the problem would be - all handles created from
childs will be shared also (files, channels, etc.), so if some handle
will be not proper closed before end of some process - it will be a
leak, as long as all processes including master are not terminated.
Any ideas are welcome.
22.04.2015 18:29, Maxim Dounin:
>> BTW(1): I have interest to fix a problem with multiple workers under
>> windows (ex.:
>> http://forum.nginx.org/read.php?2,188714,188714#msg-188714  ).
>> @Maxim Dounin: can you possibly give me more information, what you
>> mean here, resp. what it currently depends on (see
>> http://forum.nginx.org/read.php?2,188714,212568#msg-212568  ).
> The most obvious problem with multiple workers on Windows is
> listening sockets. As of now, if you start multiple workers on
> windows, nginx will open multiple listening sockets - one in each
> worker process. These are independant sockets, each opened with
> SO_REUSEADDR, and only one of these sockets will be able to accept
> Possible solution to the problem would be to pass listening sockets
> from a master process to worker processes via handle inheritance
> as available in Windows:
More information about the nginx-devel