For now I do this using a read & write FILEHANDLE where they write to the last byte of a file. Then I check the end of the file to synchronize the childs. But I can't use a file in the final release, since I can't write data to the machine! There is a way to do using only the memory on Win32, without threads?
This can't be done by pipe, since I need to read & write and is for more than 2 childs.
But why I need this? I'm using a shared socket, in the port 80, between the childs. This socket has listen set to 5 and reuse is on. On Win32, if 2 childs make an accept() in the same time, they can't get the new connection of the client, and we need to wait for the socket timeout to try the accept again. In other words, I can't share very well the port between the childs.
What I'm doing is a HTTPD that accept multi connections in the same time to run Perl scripts, simulating CGI.
Or if someone know how to avoid the accept() problem, please reply! I already tried to use IO::Select, but nothing. I tried to use random sleep() or select(undef,undef,undef,rand(2)) to unsynchronize the accept() call, but doesn't work very well!
Or if someone already made a shared HTPPD on Perl, please comment.
Note, for who have tried to make a shared port with HTTP::Daemon, you need to fix a bug in the module, that unable the use of the socket handle inside childs, fork, or threads. Just put this in your code:
package HTTP::Daemon ; # Fix a bug on sockname of IO::Socket, that block the app for multi ch +ilds with # the same server opened. Or for a GLOB blessed in a package different + than # IO::Socket, since the socket of the server is blessed to HTTP::Daemo +n! (I saw the bug only on Win32). sub sockname { #getsockname($_[0]); getsockname( fileno($_[0]) ); }
PS: Need to work with Perl-5.6.1.
Graciliano M. P.
"The creativity is the expression of the liberty".
In reply to Shared Memory on Win32? And Share port for HTTP::Daemon. by gmpassos
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |