Changeset 3119
- Timestamp:
- 02/07/06 01:50:28 (3 years ago)
- Files:
-
- branches/cocoa-networking/Chat Core/MVIRCChatConnection.h (modified) (1 diff)
- branches/cocoa-networking/Chat Core/MVIRCChatConnection.m (modified) (10 diffs)
- branches/cocoa-networking/Chat Core/MVIRCFileTransfer.h (modified) (2 diffs)
- branches/cocoa-networking/Chat Core/MVIRCFileTransfer.m (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/cocoa-networking/Chat Core/MVIRCChatConnection.h
r3117 r3119 17 17 NSString *_password; 18 18 NSString *_realName; 19 NSConditionLock *_threadWaitLock; 19 20 unsigned short _serverPort; 20 21 } branches/cocoa-networking/Chat Core/MVIRCChatConnection.m
r3118 r3119 302 302 _currentNickname = [_nickname retain]; 303 303 _realName = [NSFullUserName() retain]; 304 _threadWaitLock = [[NSConditionLock allocWithZone:nil] initWithCondition:0]; 304 305 305 306 _knownUsers = [[NSMutableDictionary allocWithZone:nil] initWithCapacity:200]; … … 324 325 [_password release]; 325 326 [_realName release]; 327 [_threadWaitLock release]; 326 328 327 329 _chatConnection = nil; … … 335 337 _password = nil; 336 338 _realName = nil; 339 _threadWaitLock = nil; 337 340 338 341 [super dealloc]; … … 369 372 } 370 373 371 id old = _chatConnection; 372 _chatConnection = [[AsyncSocket allocWithZone:nil] initWithDelegate:self]; 373 [old setDelegate:nil]; 374 [old release]; 375 376 old = _lastConnectAttempt; 374 id old = _lastConnectAttempt; 377 375 _lastConnectAttempt = [[NSDate allocWithZone:nil] init]; 378 376 [old release]; … … 380 378 [self _willConnect]; // call early so other code has a chance to change our info 381 379 382 if( ! _connectionThread ) { 383 [NSThread prepareForInterThreadMessages]; 384 [NSThread detachNewThreadSelector:@selector( _ircRunloop ) toTarget:self withObject:nil]; 385 while( ! _connectionThread ) sched_yield(); 386 } 380 _connectionThread = nil; 381 [NSThread prepareForInterThreadMessages]; 382 [NSThread detachNewThreadSelector:@selector( _ircRunloop ) toTarget:self withObject:nil]; 383 384 [_threadWaitLock lockWhenCondition:1]; 385 [_threadWaitLock unlockWithCondition:0]; 387 386 388 387 [self performSelector:@selector( _connect ) inThread:_connectionThread]; … … 539 538 [self performSelector:@selector( _writeDataToServer: ) withObject:data inThread:_connectionThread]; 540 539 541 [[NSNotificationCenter defaultCenter] postNotification Name:MVChatConnectionGotRawMessageNotification object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:string, @"message", [NSNumber numberWithBool:YES], @"outbound", nil]];540 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatConnectionGotRawMessageNotification object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:string, @"message", [NSNumber numberWithBool:YES], @"outbound", nil]]; 542 541 543 542 [string release]; … … 679 678 680 679 - (void) _connect { 681 [_chatConnection disconnect]; 680 id old = _chatConnection; 681 _chatConnection = [[AsyncSocket allocWithZone:nil] initWithDelegate:self]; 682 [old setDelegate:nil]; 683 [old disconnect]; 684 [old release]; 685 682 686 if( ! [_chatConnection connectToHost:[self server] onPort:[self serverPort] error:NULL] ) 683 687 [self _didNotConnect]; … … 687 691 NSAutoreleasePool *pool = [[NSAutoreleasePool allocWithZone:nil] init]; 688 692 693 [_threadWaitLock lockWhenCondition:0]; 694 689 695 _connectionThread = [NSThread currentThread]; 690 696 [NSThread prepareForInterThreadMessages]; 697 698 [_threadWaitLock unlockWithCondition:1]; 691 699 692 700 BOOL active = YES; … … 753 761 id old = _localUser; 754 762 _localUser = nil; 755 [old release];756 757 old = _chatConnection;758 _chatConnection = nil;759 [old setDelegate:nil];760 763 [old release]; 761 764 … … 869 872 870 873 end: 871 [[NSNotificationCenter defaultCenter] postNotification Name:MVChatConnectionGotRawMessageNotification object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:rawString, @"message", [NSNumber numberWithBool:NO], @"outbound", nil]];874 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatConnectionGotRawMessageNotification object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:rawString, @"message", [NSNumber numberWithBool:NO], @"outbound", nil]]; 872 875 873 876 if( command && commandLength ) { branches/cocoa-networking/Chat Core/MVIRCFileTransfer.h
r3103 r3119 10 10 NSThread *_connectionThread; 11 11 NSFileHandle *_fileHandle; 12 NSConditionLock *_threadWaitLock; 12 13 BOOL _fileNameQuoted; 13 14 BOOL _readData; … … 29 30 NSThread *_connectionThread; 30 31 NSFileHandle *_fileHandle; 32 NSConditionLock *_threadWaitLock; 31 33 BOOL _fileNameQuoted; 32 34 BOOL _done; branches/cocoa-networking/Chat Core/MVIRCFileTransfer.m
r3104 r3119 251 251 if( directory || ! fileExists ) return; 252 252 253 [_fileHandle release];254 253 _fileHandle = [[NSFileHandle fileHandleForReadingAtPath:[self source]] retain]; 255 254 if( ! _fileHandle ) return; 256 255 [_fileHandle seekToFileOffset:[self startOffset]]; 257 256 257 _threadWaitLock = [[NSConditionLock allocWithZone:nil] initWithCondition:0]; 258 258 259 [NSThread prepareForInterThreadMessages]; 259 260 [NSThread detachNewThreadSelector:@selector( _dccRunloop ) toTarget:self withObject:nil]; 260 while( ! _connectionThread ) sched_yield(); 261 262 [_threadWaitLock lockWhenCondition:1]; 263 [_threadWaitLock unlockWithCondition:0]; 261 264 262 265 if( ! [self isPassive] ) [self performSelector:@selector( _waitForConnection ) inThread:_connectionThread]; … … 316 319 [self retain]; 317 320 321 [_threadWaitLock lockWhenCondition:0]; 322 318 323 _connectionThread = [NSThread currentThread]; 319 324 [NSThread prepareForInterThreadMessages]; 320 325 [NSThread setThreadPriority:0.75]; 326 327 [_threadWaitLock unlockWithCondition:1]; 321 328 322 329 BOOL active = YES; … … 479 486 if( ! fileExists ) return; 480 487 481 [_fileHandle release];482 488 _fileHandle = [[NSFileHandle fileHandleForWritingAtPath:[self destination]] retain]; 483 489 if( ! _fileHandle ) return; 484 490 [_fileHandle truncateFileAtOffset:[self startOffset]]; 485 491 492 _threadWaitLock = [[NSConditionLock allocWithZone:nil] initWithCondition:0]; 493 486 494 [NSThread prepareForInterThreadMessages]; 487 495 [NSThread detachNewThreadSelector:@selector( _dccRunloop ) toTarget:self withObject:nil]; 488 while( ! _connectionThread ) sched_yield(); 496 497 [_threadWaitLock lockWhenCondition:1]; 498 [_threadWaitLock unlockWithCondition:0]; 489 499 490 500 if( ! [self isPassive] ) [self performSelector:@selector( _connect ) inThread:_connectionThread]; … … 537 547 [self retain]; 538 548 549 [_threadWaitLock lockWhenCondition:0]; 550 539 551 _connectionThread = [NSThread currentThread]; 540 552 [NSThread prepareForInterThreadMessages]; 541 553 [NSThread setThreadPriority:0.75]; 554 555 [_threadWaitLock unlockWithCondition:1]; 542 556 543 557 BOOL active = YES;
