From 03b021d94c75005aa14b852b2a0b3cbe38681fe4 Mon Sep 17 00:00:00 2001 From: Richard Frith-MacDonald Date: Wed, 17 Dec 2008 08:49:50 +0000 Subject: [PATCH] Enable keepalive for message port connections on windows git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@27320 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 7 +++++++ Source/NSConnection.m | 10 ++++++++++ Tools/gdnc.m | 12 ------------ 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index a3b572a7c..1966a5bbf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-12-17 Richard Frith-Macdonald + + * Source/NSConnection.m: + * Tools/gdnc.m: + Enable keepalive only on mswindows and for server connections using + NSMessagePort. + 2008-12-16 Richard Frith-Macdonald * Source/NSLock.m: Tiny cleanup of lock finalisation process. diff --git a/Source/NSConnection.m b/Source/NSConnection.m index 06e7e8943..4ff984eef 100644 --- a/Source/NSConnection.m +++ b/Source/NSConnection.m @@ -1634,6 +1634,16 @@ static NSLock *cached_proxies_gate = nil; - (void) setRootObject: (id)anObj { setRootObjectForInPort(anObj, _receivePort); +#if defined(__MINGW32__) + /* On ms-windows, the operating system does not inform us when the remote + * client of a message port goes away ... so we need to enable keepalive + * to detect that condition. + */ + if ([_receivePort isKindOfClass: [NSMessagePort class]]) + { + [self _enableKeepalive]; + } +#endif } /** diff --git a/Tools/gdnc.m b/Tools/gdnc.m index d70495624..dd7ac45c7 100644 --- a/Tools/gdnc.m +++ b/Tools/gdnc.m @@ -174,10 +174,6 @@ ihandler(int sig) } @end -@interface NSConnection (Private) -- (void) _enableKeepalive; -@end - @interface GDNCNotification : NSObject { @public @@ -448,14 +444,6 @@ ihandler(int sig) conn = [[NSConnection alloc] initWithReceivePort: port sendPort: nil]; [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 || [[NSHost hostWithName: hostname] isEqual: [NSHost currentHost]] == YES) {