stash / Feersum

A PSGI engine for Perl based on EV/libev
http://search.cpan.org/~stash/Feersum/
74 stars 15 forks source link

unix domain socket support #33

Closed vividsnow closed 4 years ago

vividsnow commented 4 years ago

support listening on unix socket, so one can run: plackup -E production -l /tmp/app.sock -s Feersum --pre-fork N app.psgi or feersum --native --listen /tmp/app.sock --pre-fork N ./app.feersum

stash commented 4 years ago

Hi @vividsnow ! Thanks for the PR! I haven't used or tested this module for years. The patch looks small so perhaps you can just walk me through it? Or, if we have a mutual friend, can you have them vouch for you and I'll just give you merge permission?

I am not sure why the socket file is getting unlinked if it exists (unlink $listen if -S $listen;) ... doesn't this cause a race condition between unlinking and opening it via IO::Socket::UNIX? Also, doesn't calling umask(0) make the file mode rwx by everyone? Would it be simpler, and less prone to race and permission issues, to just let IO::Socket::UNIX->new fail if permission isn't right?

Nice to have: if you could make the code the same as the IO::Socket::INET constructor below, that would be ideal.

stash commented 4 years ago

s/to just let/to not unlink and just let/

stash commented 4 years ago

Or I suppose we can wait for @audreyt to take a look (thank you so much for looking after Feersum!)

vividsnow commented 4 years ago

Hi, @stash @audreyt

I fixed code style, but passing 'Blocking => 0' is currently unsupported by IO::Socket::UNIX, which is presumably a bug https://github.com/Perl/perl5/pull/17787

audreyt commented 4 years ago

This looks good to me. Would it be possible to write a unit test in t/ ?

vividsnow commented 4 years ago

Yes, it will be feasible by using Test::SharedFork

audreyt commented 3 years ago

This is now released in CPAN as 0.410.