connection root object fixup

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@28766 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2009-10-03 15:35:40 +00:00
parent d5df438a7d
commit 04d6ed096e
3 changed files with 40 additions and 14 deletions

View file

@ -1,3 +1,12 @@
2009-10-03 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSConnection.m:
Don't allow the root object of a connection to be released simply
because the remote proxy is released ... the connection itsself
may have been retained at the remote end, and the code there may
call the -rootProxy method and start sending messages to it again.
Fix for bug #27128
2009-10-01 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSPortCoder.m:

View file

@ -610,14 +610,14 @@ int main (int argc, char *argv[], char **env)
}
}
#if 0
#if 1
/* Check that we can retain the connection, release the proxy,
* and then regain the proxy from the connection.
*/
cobj = RETAIN([prx connectionForProxy]);
RELEASE(arp);
arp = [NSAutoreleasePool new];
prx = [cobj rootObject];
prx = [cobj rootProxy];
AUTORELEASE(cobj);
#else
cobj = [prx connectionForProxy];

View file

@ -1656,7 +1656,7 @@ static NSLock *cached_proxies_gate = nil;
* If this is a server connection without a remote end, its root proxy
* is the same as its root object.
*/
if (IreceivePort ==IsendPort)
if (IreceivePort == IsendPort)
{
return [self rootObject];
}
@ -2843,25 +2843,42 @@ static void callEncoder (DOContext *ctxt)
for (pos = 0; pos < count; pos++)
{
unsigned target;
NSDistantObject *prox;
ProxyStruct *prox;
[rmc decodeValueOfObjCType: @encode(typeof(target)) at: &target];
prox = (NSDistantObject*)[self includesLocalTarget: target];
if (prox != nil)
prox = (ProxyStruct*)[self includesLocalTarget: target];
if (prox != 0)
{
if (debug_connection > 3)
NSLog(@"releasing object with target (0x%x) on (%@) counter %d",
target, self, ((ProxyStruct*)prox)->_counter);
#if 1
// FIXME thread safety
if (--(((ProxyStruct*)prox)->_counter) == 0)
target, self, prox->_counter);
M_LOCK(IrefGate);
NS_DURING
{
[self removeLocalObject: prox];
if (--(prox->_counter) == 0)
{
id rootObject = rootObjectForInPort(IreceivePort);
if (rootObject == prox->_object)
{
/* Don't deallocate root object ...
*/
prox->_counter = 0;
}
else
{
[self removeLocalObject: (id)prox];
}
}
}
#else
[self removeLocalObject: prox];
#endif
NS_HANDLER
{
M_UNLOCK(IrefGate);
[localException raise];
}
NS_ENDHANDLER
M_UNLOCK(IrefGate);
}
else if (debug_connection > 3)
NSLog(@"releasing object with target (0x%x) on (%@) - nothing to do",