Commits

Tuukka Norri committed 64d1c76

Fixed a gc-related problem which caused crashes
- Used CFRetain and CFRelease. A more thorough fix will be needed.

  • Participants
  • Parent commits fa0e655
  • Branches PGTS

Comments (0)

Files changed (2)

Framework/Sources/PGTSConnectionPrivate.m

 			
 			if (0 == selectStatus)
 			{
+#if 0 //FIXME: debugging
 				[self setErrorMessage: NSLocalizedString (@"Connection timed out.", @"Error message for connection failure")];
+#endif
 				break;
 			}
             else if (0 >= selectStatus || YES == stop)

Framework/Sources/TSRunloopMessenger.m

 
 #import "TSRunloopMessenger.h"
 
+/*
+ * struct message
+ */
+struct message
+{
+	NSConditionLock		* resultLock;
+	NSInvocation			* invocation;
+};
+
+extern void sendData( NSData * aData, NSPort * aPort );
+
 
 @implementation TSRunloopMessenger
 
 	return [[[TSRunloopMessengerForwardingProxy alloc] _initWithTarget:aTarget withOwner:self withResult:aResultFlag] autorelease];
 }
 
+- (void)messageInvocation:(NSInvocation *)anInvocation withResult:(BOOL)aResultFlag
+{
+	struct message		* theMessage;
+	NSMutableData		* theData;
+	NSConditionLock		* theLock;
+	
+	[anInvocation retainArguments];
+	
+	theData = [NSMutableData dataWithLength:sizeof(struct message)];
+	theMessage = (struct message *)[theData mutableBytes];
+	
+	theMessage->invocation = (id) CFRetain (anInvocation);		// will be released by handlePortMessage
+	if (aResultFlag)
+	{
+		theLock = [[NSConditionLock alloc] initWithCondition: NO];
+		theMessage->resultLock = theLock;
+	}
+	else
+	{
+		theMessage->resultLock = nil;
+	}
+	
+	sendData( theData, port );
+	
+	if( aResultFlag )
+	{
+		[theMessage->resultLock lockWhenCondition:YES];
+		[theMessage->resultLock unlock];
+		[theMessage->resultLock release];
+	}
+}
+
+- (void)handlePortMessage:(NSPortMessage *)aPortMessage
+{
+	struct message 	* theMessage;
+	NSData				* theData;
+	void					handlePerformSelectorMessage( struct message * aMessage );
+	void					handleInvocationMessage( struct message * aMessage );
+	
+	theData = [[aPortMessage components] lastObject];
+	
+	theMessage = (struct message *)[theData bytes];
+	
+	[theMessage->invocation invoke];
+	if( theMessage->resultLock )
+	{
+		[theMessage->resultLock lock];
+		[theMessage->resultLock unlockWithCondition:YES];
+	}
+	
+	CFRelease (theMessage->invocation);	// to balance messageInvocation:withResult:
+}
+
 @end