Welcome! Log In Create A New Profile

Advanced

Re: Fwd: Windows shmem fix: makes shared memory fully ASLR and DEP compliant (ea. cache zone, limit zone, etc.)

Sergey Brester
June 08, 2015 03:58PM
Hi,

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:


https://msdn.microsoft.com/en-en/library/windows/desktop/ms741565%28v=vs.85%29.aspx

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.

Regards,
sebres.



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 [1] [1]).
>> @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 [2] [2]).
>
> 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
> connections.
>
> 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:
>
> http://msdn.microsoft.com/en-us/library/windows/desktop/ms683463(v=vs.85).aspx
> [3]
>


Links:
------
[1] http://forum.nginx.org/read.php?2,188714,188714#msg-188714
[2] http://forum.nginx.org/read.php?2,188714,212568#msg-212568
[3]
http://msdn.microsoft.com/en-us/library/windows/desktop/ms683463(v=vs.85).aspx

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

Fwd: Windows shmem fix: makes shared memory fully ASLR and DEP compliant (ea. cache zone, limit zone, etc.)

Sergey Brester 1604 April 22, 2015 03:46AM

RE: Windows shmem fix: makes shared memory fully ASLR and DEP compliant (ea. cache zone, limit zone, etc.)

Filipe DA SILVA 741 April 22, 2015 04:54AM

RE: Windows shmem fix: makes shared memory fully ASLR and DEP compliant (ea. cache zone, limit zone, etc.)

Sergey Brester 586 April 22, 2015 07:40AM

Re: Fwd: Windows shmem fix: makes shared memory fully ASLR and DEP compliant (ea. cache zone, limit zone, etc.)

Maxim Dounin 1158 April 22, 2015 12:30PM

Re: Fwd: Windows shmem fix: makes shared memory fully ASLR and DEP compliant (ea. cache zone, limit zone, etc.)

Sergey Brester 862 April 23, 2015 07:22PM

Re: Fwd: Windows shmem fix: makes shared memory fully ASLR and DEP compliant (ea. cache zone, limit zone, etc.)

Sergey Brester 569 June 08, 2015 03:58PM



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

Online Users

Guests: 247
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