Add ivar for expansion, remove a few lines unused code, add private keepalive.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@27105 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2008-11-21 08:02:41 +00:00
parent 1d36408eea
commit b7b3ed920e
2 changed files with 48 additions and 5 deletions

View file

@ -101,8 +101,8 @@ GS_EXPORT NSString* const NSConnectionProxyCount; /* Objects received */
BOOL _authenticateOut;
BOOL _multipleThreads;
BOOL _shuttingDown;
BOOL _dummy1;
BOOL _dummy2;
BOOL _useKeepalive;
BOOL _dummy;
NSPort *_receivePort;
NSPort *_sendPort;
unsigned _requestDepth;
@ -132,6 +132,8 @@ GS_EXPORT NSString* const NSConnectionProxyCount; /* Objects received */
NSMutableArray *_cachedEncoders;
NSString *_registeredName;
NSPortNameServer *_nameServer;
int _lastKeepalive;
void *_reserved; // For expansion
}
+ (NSArray*) allConnections;

View file

@ -239,6 +239,7 @@ stringFromMsgType(int type)
- (void) handlePortMessage: (NSPortMessage*)msg;
- (void) _runInNewThread;
+ (void) setDebug: (int)val;
- (void) _enableKeepalive;
- (void) addLocalObject: (NSDistantObject*)anObj;
- (void) removeLocalObject: (NSDistantObject*)anObj;
@ -2328,6 +2329,13 @@ static void retEncoder (DOContext *ctxt)
GSIMapNode node;
[rmc decodeValueOfObjCType: @encode(int) at: &sequence];
if (type == ROOTPROXY_REPLY && sequence == _lastKeepalive)
{
_lastKeepalive = 0;
NSDebugMLLog(@"NSConnection", @"Handled keepalive %d on %@",
sequence, conn);
[self _doneInRmc: rmc];
}
M_LOCK(conn->_queueGate);
node = GSIMapNodeForKey(conn->_replyMap, (GSIMapKey)sequence);
if (node == 0)
@ -2387,6 +2395,42 @@ static void retEncoder (DOContext *ctxt)
debug_connection = val;
}
- (void) _keepalive: (NSNotification*)n
{
if ([self isValid])
{
if (_lastKeepalive == 0)
{
NSPortCoder *op;
/* Send out a root proxy request to ping the other end.
*/
op = [self _makeOutRmc: 0 generate: &_lastKeepalive reply: NO];
[self _sendOutRmc: op type: ROOTPROXY_REQUEST];
}
else
{
/* keepalive timeout outstanding still.
*/
[self invalidate];
}
}
}
- (void) _enableKeepalive
{
if (_receivePort == _sendPort)
{
[NSException raise: NSGenericException format: @"Illegal operation"];
}
_useKeepalive = YES;
_lastKeepalive = 0;
[self enableMultipleThreads];
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(_keepalive:)
name: @"GSHousekeeping" object: nil];
}
static void callDecoder (DOContext *ctxt)
{
const char *type = ctxt->type;
@ -3063,7 +3107,6 @@ static void callEncoder (DOContext *ctxt)
NSDate *limit;
BOOL sent = NO;
BOOL raiseException = NO;
BOOL needsReply = NO;
NSMutableArray *components = [c _components];
if (_authenticateOut == YES
@ -3084,7 +3127,6 @@ static void callEncoder (DOContext *ctxt)
switch (msgid)
{
case PROXY_RETAIN:
needsReply = YES;
case CONNECTION_SHUTDOWN:
case METHOD_REPLY:
case ROOTPROXY_REPLY:
@ -3097,7 +3139,6 @@ static void callEncoder (DOContext *ctxt)
case METHOD_REQUEST:
case ROOTPROXY_REQUEST:
case METHODTYPE_REQUEST:
needsReply = YES;
default:
raiseException = YES;
break;