mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
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:
parent
7181661442
commit
8bb5de4824
2 changed files with 48 additions and 5 deletions
|
@ -101,8 +101,8 @@ GS_EXPORT NSString* const NSConnectionProxyCount; /* Objects received */
|
||||||
BOOL _authenticateOut;
|
BOOL _authenticateOut;
|
||||||
BOOL _multipleThreads;
|
BOOL _multipleThreads;
|
||||||
BOOL _shuttingDown;
|
BOOL _shuttingDown;
|
||||||
BOOL _dummy1;
|
BOOL _useKeepalive;
|
||||||
BOOL _dummy2;
|
BOOL _dummy;
|
||||||
NSPort *_receivePort;
|
NSPort *_receivePort;
|
||||||
NSPort *_sendPort;
|
NSPort *_sendPort;
|
||||||
unsigned _requestDepth;
|
unsigned _requestDepth;
|
||||||
|
@ -132,6 +132,8 @@ GS_EXPORT NSString* const NSConnectionProxyCount; /* Objects received */
|
||||||
NSMutableArray *_cachedEncoders;
|
NSMutableArray *_cachedEncoders;
|
||||||
NSString *_registeredName;
|
NSString *_registeredName;
|
||||||
NSPortNameServer *_nameServer;
|
NSPortNameServer *_nameServer;
|
||||||
|
int _lastKeepalive;
|
||||||
|
void *_reserved; // For expansion
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSArray*) allConnections;
|
+ (NSArray*) allConnections;
|
||||||
|
|
|
@ -239,6 +239,7 @@ stringFromMsgType(int type)
|
||||||
- (void) handlePortMessage: (NSPortMessage*)msg;
|
- (void) handlePortMessage: (NSPortMessage*)msg;
|
||||||
- (void) _runInNewThread;
|
- (void) _runInNewThread;
|
||||||
+ (void) setDebug: (int)val;
|
+ (void) setDebug: (int)val;
|
||||||
|
- (void) _enableKeepalive;
|
||||||
|
|
||||||
- (void) addLocalObject: (NSDistantObject*)anObj;
|
- (void) addLocalObject: (NSDistantObject*)anObj;
|
||||||
- (void) removeLocalObject: (NSDistantObject*)anObj;
|
- (void) removeLocalObject: (NSDistantObject*)anObj;
|
||||||
|
@ -2328,6 +2329,13 @@ static void retEncoder (DOContext *ctxt)
|
||||||
GSIMapNode node;
|
GSIMapNode node;
|
||||||
|
|
||||||
[rmc decodeValueOfObjCType: @encode(int) at: &sequence];
|
[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);
|
M_LOCK(conn->_queueGate);
|
||||||
node = GSIMapNodeForKey(conn->_replyMap, (GSIMapKey)sequence);
|
node = GSIMapNodeForKey(conn->_replyMap, (GSIMapKey)sequence);
|
||||||
if (node == 0)
|
if (node == 0)
|
||||||
|
@ -2387,6 +2395,42 @@ static void retEncoder (DOContext *ctxt)
|
||||||
debug_connection = val;
|
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)
|
static void callDecoder (DOContext *ctxt)
|
||||||
{
|
{
|
||||||
const char *type = ctxt->type;
|
const char *type = ctxt->type;
|
||||||
|
@ -3063,7 +3107,6 @@ static void callEncoder (DOContext *ctxt)
|
||||||
NSDate *limit;
|
NSDate *limit;
|
||||||
BOOL sent = NO;
|
BOOL sent = NO;
|
||||||
BOOL raiseException = NO;
|
BOOL raiseException = NO;
|
||||||
BOOL needsReply = NO;
|
|
||||||
NSMutableArray *components = [c _components];
|
NSMutableArray *components = [c _components];
|
||||||
|
|
||||||
if (_authenticateOut == YES
|
if (_authenticateOut == YES
|
||||||
|
@ -3084,7 +3127,6 @@ static void callEncoder (DOContext *ctxt)
|
||||||
switch (msgid)
|
switch (msgid)
|
||||||
{
|
{
|
||||||
case PROXY_RETAIN:
|
case PROXY_RETAIN:
|
||||||
needsReply = YES;
|
|
||||||
case CONNECTION_SHUTDOWN:
|
case CONNECTION_SHUTDOWN:
|
||||||
case METHOD_REPLY:
|
case METHOD_REPLY:
|
||||||
case ROOTPROXY_REPLY:
|
case ROOTPROXY_REPLY:
|
||||||
|
@ -3097,7 +3139,6 @@ static void callEncoder (DOContext *ctxt)
|
||||||
case METHOD_REQUEST:
|
case METHOD_REQUEST:
|
||||||
case ROOTPROXY_REQUEST:
|
case ROOTPROXY_REQUEST:
|
||||||
case METHODTYPE_REQUEST:
|
case METHODTYPE_REQUEST:
|
||||||
needsReply = YES;
|
|
||||||
default:
|
default:
|
||||||
raiseException = YES;
|
raiseException = YES;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue