Changeset 3140

Show
Ignore:
Timestamp:
02/17/06 01:31:16 (2 years ago)
Author:
timothy
Message:

Reworked my last fix that I had to roll out. Rooms and users are now released when their ref count hits 1. Call drain on all autorelease pool first.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/cocoa-networking/Chat Core/MVChatRoom.h

    r3128 r3140  
    6262        unsigned long _modes; 
    6363        unsigned int _hash; 
     64        BOOL _releasing; 
    6465} 
    6566- (MVChatConnection *) connection; 
  • branches/cocoa-networking/Chat Core/MVChatRoom.m

    r3134 r3140  
    11#import "MVChatConnection.h" 
     2#import "MVChatConnectionPrivate.h" 
    23#import "MVChatRoom.h" 
    34#import "MVChatUser.h" 
     
    6566} 
    6667 
     68- (void) release { 
     69        if( ! _releasing && ( [self retainCount] - 1 ) == 1 ) { 
     70                _releasing = YES; 
     71                [[self connection] _removeJoinedRoom:self]; 
     72        } 
     73 
     74        [super release]; 
     75} 
     76 
    6777- (void) dealloc { 
    6878        [_name release]; 
  • branches/cocoa-networking/Chat Core/MVIRCChatConnection.h

    r3131 r3140  
    4343- (void) _removeFileTransfer:(MVFileTransfer *) transfer; 
    4444 
     45- (void) _removeKnownUser:(MVChatUser *) user; 
     46 
    4547- (void) _setCurrentNickname:(NSString *) nickname; 
    4648@end 
  • branches/cocoa-networking/Chat Core/MVIRCChatConnection.m

    r3138 r3140  
    572572                _connectionThread = nil; 
    573573 
     574        [pool drain]; 
    574575        [pool release]; 
    575576} 
     
    897898        @synchronized( _fileTransfers ) { 
    898899                if( transfer ) [_fileTransfers removeObject:transfer]; 
     900        } 
     901} 
     902 
     903#pragma mark - 
     904 
     905- (void) _removeKnownUser:(MVChatUser *) user { 
     906        @synchronized( _knownUsers ) { 
     907                if( user ) [_knownUsers removeObjectForKey:[user uniqueIdentifier]]; 
    899908        } 
    900909} 
     
    12131222                                room = [[MVIRCChatRoom allocWithZone:nil] initWithName:name andConnection:self]; 
    12141223                                [self _addJoinedRoom:room]; 
    1215                                 [room release]; 
    1216                         } 
     1224                        } else [room retain]; 
    12171225 
    12181226                        [room _setDateJoined:[NSDate date]]; 
     
    15541562                        [room _setNamesSynced:YES]; 
    15551563                        [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatRoomJoinedNotification object:room]; 
     1564                        [room release]; // balance the alloc or retain from _handleJoinWithParameters 
    15561565                } 
    15571566        } 
  • branches/cocoa-networking/Chat Core/MVIRCChatUser.h

    r3081 r3140  
    44@class MVIRCChatConnection; 
    55 
    6 @interface MVIRCChatUser : MVChatUser {} 
     6@interface MVIRCChatUser : MVChatUser { 
     7        BOOL _releasing; 
     8
    79- (id) initLocalUserWithConnection:(MVIRCChatConnection *) connection; 
    810- (id) initWithNickname:(NSString *) nickname andConnection:(MVIRCChatConnection *) connection; 
  • branches/cocoa-networking/Chat Core/MVIRCChatUser.m

    r3134 r3140  
    2727        [[NSNotificationCenter defaultCenter] removeObserver:self]; 
    2828        [super finalize]; 
     29} 
     30 
     31- (void) release { 
     32        if( ! _releasing && [self isRemoteUser] && ( [self retainCount] - 1 ) == 1 ) { 
     33                _releasing = YES; 
     34                [[self connection] _removeKnownUser:self]; 
     35        } 
     36 
     37        [super release]; 
    2938} 
    3039 
  • branches/cocoa-networking/Chat Core/MVIRCFileTransfer.m

    r3134 r3140  
    353353        _connectionThread = nil; 
    354354 
     355        [pool drain]; 
    355356        [pool release]; 
    356357} 
     
    597598        _connectionThread = nil; 
    598599 
     600        [pool drain]; 
    599601        [pool release]; 
    600602} 
  • branches/cocoa-networking/Chat Core/MVSILCChatConnection.h

    r3081 r3140  
    5252- (NSMutableDictionary *) _sentCommands; 
    5353 
     54- (void) _removeKnownUser:(MVChatUser *) user; 
     55 
    5456- (NSData *) _detachInfo; 
    5557- (void) _setDetachInfo:(NSData *) info; 
  • branches/cocoa-networking/Chat Core/MVSILCChatConnection.m

    r3134 r3140  
    13821382                pool = [[NSAutoreleasePool allocWithZone:nil] init]; 
    13831383                silc_schedule_one( _silcClient -> schedule, -1 ); 
     1384                [pool drain]; 
    13841385                [pool release]; 
    13851386        } 
     
    14701471- (NSMutableDictionary *) _sentCommands { 
    14711472        return _sentCommands; 
     1473} 
     1474 
     1475#pragma mark - 
     1476 
     1477- (void) _removeKnownUser:(MVChatUser *) user { 
     1478        @synchronized( _knownUsers ) { 
     1479                if( user ) [_knownUsers removeObjectForKey:[user uniqueIdentifier]]; 
     1480        } 
    14721481} 
    14731482 
  • branches/cocoa-networking/Chat Core/MVSILCChatUser.h

    r3081 r3140  
    88@interface MVSILCChatUser : MVChatUser { 
    99        SilcClientEntry _clientEntry; 
     10        BOOL _releasing; 
    1011} 
    1112- (id) initLocalUserWithConnection:(MVSILCChatConnection *) connection; 
  • branches/cocoa-networking/Chat Core/MVSILCChatUser.m

    r3134 r3140  
    2828 
    2929        return self; 
     30} 
     31 
     32- (void) release { 
     33        if( ! _releasing && [self isRemoteUser] && ( [self retainCount] - 1 ) == 1 ) { 
     34                _releasing = YES; 
     35                [[self connection] _removeKnownUser:self]; 
     36        } 
     37 
     38        [super release]; 
    3039} 
    3140