log if we fail to turn on keepalive

This commit is contained in:
Richard Frith-Macdonald 2018-02-06 12:34:04 +00:00
parent ccd2fb1ac0
commit 0f7a6d58d3
2 changed files with 12 additions and 4 deletions

View file

@ -5,6 +5,7 @@
* Documentation/manual/ExceptionHandling.texi:
Update NSAssert() and NSCAssert() to handle variable arguments
(as OSX has done) and mark the numbered macros as obsolete.
* Source/NSSocketPort.m: Log if we fail to tuirn on keepalive
2018-02-05 Richard Frith-Macdonald <rfm@gnu.org>

View file

@ -677,8 +677,11 @@ static Class runLoopClass;
{
int status = 1;
setsockopt(desc, SOL_SOCKET, SO_KEEPALIVE, (char*)&status,
(OPTLEN)sizeof(status));
if (setsockopt(desc, SOL_SOCKET, SO_KEEPALIVE, (char*)&status,
(OPTLEN)sizeof(status)) < 0)
{
NSLog(@"failed to turn on keepalive for connected socket %d", desc);
}
addrNum = 0;
caller = YES;
[aPort addHandle: self forSend: YES];
@ -2116,8 +2119,12 @@ static Class tcpPortClass;
{
int status = 1;
setsockopt(desc, SOL_SOCKET, SO_KEEPALIVE, (char*)&status,
(OPTLEN)sizeof(status));
if (setsockopt(desc, SOL_SOCKET, SO_KEEPALIVE, (char*)&status,
(OPTLEN)sizeof(status)) < 0)
{
NSLog(@"failed to turn on keepalive for accepted socket %d",
desc);
}
#if defined(_WIN32)
// reset associated event with new socket
WSAEventSelect(desc, eventListener, 0);