agnicore / nfx

.NET Standard Unistack Framework
http://nfxlib.com
Other
75 stars 91 forks source link

Glue Native Sync listener hangs on Linux #1

Open itadapter opened 6 years ago

itadapter commented 6 years ago

Suspect that tcpServer.Accept is not broken by socket.close() on *nix platforms need to investigate

saleyn commented 6 years ago

I don't think this problem is .NET specific. On Linux the way to interrupt a blocking accept(3) without killing the thread that executes it is to send a signal to a process, in which case the accept() call would return EINTR (or whatever is the .NET equivalent code/exception). This is pretty ugly though. It would be much better to use the non-blocking socket to call accept() and use a reactive demultiplexer to poll for client connections.

agnibos commented 6 years ago

I have not researched where the freeze is as of yet. I suspect it is in the listener.accept with 90%+ confidence. But you are correct, about async listener, however keep in mind that this needs to be very simple solution, and secondarily, Glue does not need to handle very many accepts/sec so even the MPX binding is half synchronous which SIGNIFICANTLY simplifies it (no need to handle async accept etc..)

I am planning to get to this after Stabilization milestone