mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-04 10:30:47 +00:00
Allow keepalive to be inherited from listening connection
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@27111 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
979ae03915
commit
610c16665a
2 changed files with 29 additions and 16 deletions
|
@ -997,6 +997,10 @@ static NSLock *cached_proxies_gate = nil;
|
||||||
{
|
{
|
||||||
[self addRequestMode: [parent->_requestModes objectAtIndex: count]];
|
[self addRequestMode: [parent->_requestModes objectAtIndex: count]];
|
||||||
}
|
}
|
||||||
|
if (parent->_useKeepalive == YES)
|
||||||
|
{
|
||||||
|
[self _enableKeepalive];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1013,6 +1017,7 @@ static NSLock *cached_proxies_gate = nil;
|
||||||
_requestModes = [[NSMutableArray alloc] initWithCapacity: 2];
|
_requestModes = [[NSMutableArray alloc] initWithCapacity: 2];
|
||||||
[self addRequestMode: NSDefaultRunLoopMode];
|
[self addRequestMode: NSDefaultRunLoopMode];
|
||||||
[self addRequestMode: NSConnectionReplyMode];
|
[self addRequestMode: NSConnectionReplyMode];
|
||||||
|
_useKeepalive = NO;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we have no parent, we must handle incoming packets on our
|
* If we have no parent, we must handle incoming packets on our
|
||||||
|
@ -2419,18 +2424,25 @@ static void retEncoder (DOContext *ctxt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
- (void) _enableKeepalive
|
- (void) _enableKeepalive
|
||||||
{
|
{
|
||||||
if (_receivePort == _sendPort)
|
_useKeepalive = YES; /* Set so that child connections will inherit. */
|
||||||
{
|
|
||||||
[NSException raise: NSGenericException format: @"Illegal operation"];
|
|
||||||
}
|
|
||||||
_useKeepalive = YES;
|
|
||||||
_lastKeepalive = 0;
|
_lastKeepalive = 0;
|
||||||
|
if (_receivePort != _sendPort)
|
||||||
|
{
|
||||||
|
/* If this is not a listening connection, we actually enable the
|
||||||
|
* keepalive timing (usng the regular housekeeping notifications)
|
||||||
|
* and must also enable multiple thread support as the keepalive
|
||||||
|
* notification may arrive in a different thread from the one we
|
||||||
|
* are running in.
|
||||||
|
*/
|
||||||
[self enableMultipleThreads];
|
[self enableMultipleThreads];
|
||||||
[[NSNotificationCenter defaultCenter] addObserver: self
|
[[NSNotificationCenter defaultCenter] addObserver: self
|
||||||
selector: @selector(_keepalive:)
|
selector: @selector(_keepalive:)
|
||||||
name: @"GSHousekeeping" object: nil];
|
name: @"GSHousekeeping" object: nil];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void callDecoder (DOContext *ctxt)
|
static void callDecoder (DOContext *ctxt)
|
||||||
|
|
15
Tools/gdnc.m
15
Tools/gdnc.m
|
@ -442,6 +442,14 @@ ihandler(int sig)
|
||||||
conn = [[NSConnection alloc] initWithReceivePort: port sendPort: nil];
|
conn = [[NSConnection alloc] initWithReceivePort: port sendPort: nil];
|
||||||
[conn setRootObject: self];
|
[conn setRootObject: self];
|
||||||
|
|
||||||
|
/* For ms-windows we need to enable keepalive on the connection so that
|
||||||
|
* we will find out if the remote end goes away.
|
||||||
|
*/
|
||||||
|
if ([conn respondsToSelector: @selector(_enableKeepalive)])
|
||||||
|
{
|
||||||
|
[conn _enableKeepalive];
|
||||||
|
}
|
||||||
|
|
||||||
if ([hostname length] == 0
|
if ([hostname length] == 0
|
||||||
|| [[NSHost hostWithName: hostname] isEqual: [NSHost currentHost]] == YES)
|
|| [[NSHost hostWithName: hostname] isEqual: [NSHost currentHost]] == YES)
|
||||||
{
|
{
|
||||||
|
@ -608,13 +616,6 @@ ihandler(int sig)
|
||||||
name: NSConnectionDidDieNotification
|
name: NSConnectionDidDieNotification
|
||||||
object: newConn];
|
object: newConn];
|
||||||
[newConn setDelegate: self];
|
[newConn setDelegate: self];
|
||||||
/* For ms-windows we need to enable keepalive on the connection so that
|
|
||||||
* we will find out if the remote end goes away.
|
|
||||||
*/
|
|
||||||
if ([newConn respondsToSelector: @selector(_enableKeepalive)])
|
|
||||||
{
|
|
||||||
[newConn _enableKeepalive];
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* Create a new map table entry for this connection with a value that
|
* Create a new map table entry for this connection with a value that
|
||||||
* is a table (normally with a single entry) containing registered
|
* is a table (normally with a single entry) containing registered
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue