use non-blocking mode to accept connections

This commit is contained in:
Richard Frith-Macdonald 2023-04-13 14:27:09 +01:00
parent 96a8613dbc
commit a2f63bfec0
2 changed files with 24 additions and 0 deletions

View file

@ -1,3 +1,10 @@
2022-04-13 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSSocketPort.m: set listening socket into non-blocking mode
if possible, so if multiple threads are using the same port we don't
get one thread blocked wating for an accept which was handled by
another one.
2022-03-23 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSTimer.m: wrap call to block in exception handler (bug #289)

View file

@ -1864,6 +1864,23 @@ static Class tcpPortClass;
{
#if defined(_WIN32)
int rc;
#else
int e;
if ((e = fcntl(desc, F_GETFL, 0)) >= 0)
{
e |= NBLK_OPT;
if (fcntl(desc, F_SETFL, e) < 0)
{
NSLog(@"unable to set non-blocking mode on %d - %@",
desc, [NSError _last]);
}
}
else
{
NSLog(@"unable to get/set non-blocking mode on %d - %@",
desc, [NSError _last]);
}
#endif
/*
* Set up the listening descriptor and the actual TCP port