mirror of
https://github.com/janet-lang/janet
synced 2026-01-01 04:39:06 +00:00
Fix unix sockets issue on FreeBSD
Sometimes a unix socket has a 0 status return which indicates the connection immediately succeeded, at which point entering the event loop waiting on the connection to complete actually breaks things. It seems on FreeBSD with events being edge triggered, we're awaiting a connection to signal it's writeable (to complete the connection) but that never occurs (the event already took place before we registered for the event). Going by status alone to determine if we should enter into the event loop to await the complete connection seems sensible here.
This commit is contained in:
@@ -572,7 +572,15 @@ JANET_CORE_FN(cfun_net_connect,
|
||||
}
|
||||
#endif
|
||||
|
||||
if (status) {
|
||||
if (status == 0) {
|
||||
/* Connect completed synchronously (common for unix domain sockets).
|
||||
* Return the stream directly without scheduling an async wait,
|
||||
* as edge-triggered kqueue may not signal EVFILT_WRITE if the socket
|
||||
* is already connected when registered. */
|
||||
return janet_wrap_abstract(stream);
|
||||
}
|
||||
|
||||
if (status == -1) {
|
||||
#ifdef JANET_WINDOWS
|
||||
if (err != WSAEWOULDBLOCK) {
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user