Skip to content

Instantly share code, notes, and snippets.

@ccgus ccgus/gist:285384
Created Jan 24, 2010

Embed
What would you like to do?
The crash stack:
#0 0x7fff88084314 in objc_msgSend_vtable13
#1 0x7fff80380678 in _Block_object_assign
#2 0x10018b0c3 in __copy_helper_block_1037 at LBServer.m:91
#3 0x7fff8038044a in _Block_copy_internal
#4 0x7fff80380526 in _dispatch_Block_copy
#5 0x7fff803a1bff in dispatch_async
#6 0x10018adac in -[LBServer connectUsingBlock:] at LBServer.m:83
#7 0x100003d1d in -[LAAppDelegate connectToDefaultServerAndPullMail] at LAAppDelegate.m:178
#8 0x100002b46 in -[LAAppDelegate applicationDidFinishLaunching:] at LAAppDelegate.m:86
- (void) connectToDefaultServerAndPullMail {
for (LBAccount *acct in [self accounts]) {
// FIXME: this is going to have to be temporary, till we get a UI to turn it on/ off
[acct setIsActive:YES];
if ([acct isActive]) {
debug(@"connecting to server.");
[[acct server] connectUsingBlock:^(BOOL success, NSError *error) {
debug(@"connect success: %@", success);
if (!success) {
NSLog(@"error: %@", error);
}
}];
}
}
}
- (void) connectUsingBlock:(void (^)(BOOL s, NSError *e))block {
LBIMAPConnection *conn = [self checkoutIMAPConnection];
block = [block copy];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0),^(void){
NSError *err = nil;
//BOOL success = [conn connectWithAccount:[self account] error:&err];
dispatch_async(dispatch_get_main_queue(),^ {
block(YES, err);
[block release];
[self checkInIMAPConnection:conn];
});
});
}
- (LBIMAPConnection*) checkoutIMAPConnection {
// FIXME: this isn't thread safe.
// FIXME: need to set an upper limit on these guys.
LBIMAPConnection *conn = [_inactiveIMAPConnections lastObject];
if (!conn) {
conn = [[[LBIMAPConnection alloc] init] autorelease];
}
[_activeIMAPConnections addObject:conn];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.