diff options
author | rowanbeentje <rowan@beent.je> | 2010-08-01 14:08:53 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2010-08-01 14:08:53 +0000 |
commit | c2f2a6d1d126e8cb658b745bf5a534ca7307476d (patch) | |
tree | f0332cec0247614bcdd9166f61b856926ff69661 /Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m | |
parent | a5abfee83c7ffb81c68bbdcec9f24b53d2dd0a09 (diff) | |
parent | 6406428538c8daae5c00a8b4080b5c6a03d45be6 (diff) | |
download | sequelpro-c2f2a6d1d126e8cb658b745bf5a534ca7307476d.tar.gz sequelpro-c2f2a6d1d126e8cb658b745bf5a534ca7307476d.tar.bz2 sequelpro-c2f2a6d1d126e8cb658b745bf5a534ca7307476d.zip |
- Branch (correct) 0.9.8 release for patching
Diffstat (limited to 'Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m')
-rw-r--r-- | Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m | 46 |
1 files changed, 13 insertions, 33 deletions
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m b/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m index 3b39738b..f6371b03 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m @@ -85,9 +85,7 @@ [mNames release]; mNames = nil; } - - - + mResult = mysql_use_result(mySQLPtr); if (mResult) { @@ -100,7 +98,7 @@ // Obtain SEL references and pointer isConnectedSEL = @selector(isConnected); isConnectedPtr = [parentConnection methodForSelector:isConnectedSEL]; - + // If the result is opened in download-data-fast safe mode, set up the additional variables // and threads required. if (!fullyStreaming) { @@ -133,14 +131,9 @@ */ - (void) dealloc { - [self cancelResultLoad]; //this should close the connection if it is still open - - if (!connectionUnlocked) { - //this should NEVER happen - NSLog(@"MCPStreamingResult: The connection has not been unlocked."); - [parentConnection unlockConnection]; - } - + [self cancelResultLoad]; + if (!connectionUnlocked) [parentConnection unlockConnection]; + if (!fullyStreaming) { pthread_mutex_destroy(&dataFreeLock); pthread_mutex_destroy(&dataCreationLock); @@ -169,14 +162,8 @@ if (fullyStreaming) { theRow = mysql_fetch_row(mResult); - // If no data was returned, we're at the end of the result set - unlock the connection and return nil - if (theRow == NULL) { - if (!connectionUnlocked) { - [parentConnection unlockConnection]; - connectionUnlocked = YES; - } - return nil; - } + // If no data was returned, we're at the end of the result set - return nil. + if (theRow == NULL) return nil; // Retrieve the lengths of the returned data fieldLengths = mysql_fetch_lengths(mResult); @@ -346,7 +333,6 @@ /* * Ensure the result set is fully processed and freed without any processing - * This method ensures that the connection is unlocked. */ - (void) cancelResultLoad { @@ -359,13 +345,7 @@ theRow = mysql_fetch_row(mResult); // If no data was returned, we're at the end of the result set - return. - if (theRow == NULL) { - if (!connectionUnlocked) { - [parentConnection unlockConnection]; - connectionUnlocked = YES; - } - return; - } + if (theRow == NULL) return; } // If in cached-streaming/fast download mode, loop until all data is fetched and freed @@ -381,8 +361,8 @@ // once all memory has been freed if (processedRowCount == downloadedRowCount) { while (!dataFreed) usleep(1000); - // we don't need to unlock the connection because - // the data loading thread already did that + [parentConnection unlockConnection]; + connectionUnlocked = YES; return; } processedRowCount++; @@ -479,8 +459,8 @@ } // Unlock the parent connection now data has been retrieved - [parentConnection unlockConnection]; - connectionUnlocked = YES; + connectionUnlocked = YES; + [parentConnection unlockConnection]; dataDownloaded = YES; [downloadPool drain]; @@ -528,4 +508,4 @@ [dataFreeingPool drain]; } -@end +@end
\ No newline at end of file |