miyagawa / Starman

Starman is a high-performance preforking Perl PSGI web server
http://search.cpan.org/dist/Starman
Other
287 stars 84 forks source link

Stop flock serialization on UNIX per http://kazeburo.hatenablog.com/entry/2013/04/15/173407 #69

Closed miyagawa closed 11 years ago

miyagawa commented 11 years ago

I am not sure if it's safe to do unserialized accept(2) when there're multiple listen address/ports. c.f. http://d.hatena.ne.jp/naoya/20070311/1173629378

cc @kazeburo

miyagawa commented 11 years ago
       serialize
           Determines whether the server serializes child connections.
           Options are undef, flock, semaphore, pipe, or none.  Default is
           undef.  On multi_port servers or on servers running on Solaris, the
           default is flock.  The flock option uses blocking exclusive flock
           on the file specified in lock_file (see below).  [...]  An
           option of none will not perform any serialization.  If "none" is
           passed and there are multiple ports then a the default
           serialization will be used insted of "none."

the documentation is kind of vague, but i guess even if you pass 'none', if there're multiple listen ports, flock is used anyway?

kazeburo commented 11 years ago

Net::Server::PreforkSimple will choose flock if multi_port and serialize eq 'none'

Net/Server/PreforkSimple.pm line 70

if ($prop->{'multi_port'} && $prop->{'serialize'} && $prop->{'serialize'} eq 'none') {
    $self->log(2, "Passed serialize value of none is incompatible with multiple ports - using default serialize");
    delete $prop->{'serialize'};
}
if (!$prop->{'serialize'}
    || $prop->{'serialize'} !~ /^(flock|semaphore|pipe|none)$/i) {
    $prop->{'serialize'} = ($^O eq 'MSWin32') ? 'pipe' : 'flock';
}
miyagawa commented 11 years ago

OK, so is this safe to merge?

kazeburo commented 11 years ago

Warning displayed , but It's safe