diff options
author | rowanbeentje <rowan@beent.je> | 2009-10-13 20:44:37 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2009-10-13 20:44:37 +0000 |
commit | 6ddd95658062b14de2f63746f69b6d65d05792d4 (patch) | |
tree | 8d42080bc1786326ee89afdc3aec07d2ab6229b1 /Frameworks | |
parent | 8a3267a14a21b4c01d05c25e3add0887233298c0 (diff) | |
download | sequelpro-6ddd95658062b14de2f63746f69b6d65d05792d4.tar.gz sequelpro-6ddd95658062b14de2f63746f69b6d65d05792d4.tar.bz2 sequelpro-6ddd95658062b14de2f63746f69b6d65d05792d4.zip |
- Tweak query locking with MCPStreamingResults to fix certain operations releasing locks on different threads from which they were locked (which generates a console message)
Diffstat (limited to 'Frameworks')
-rw-r--r-- | Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h | 1 | ||||
-rw-r--r-- | Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m | 23 |
2 files changed, 21 insertions, 3 deletions
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h index 8a9e2567..604b69d5 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h @@ -203,6 +203,7 @@ void performThreadedKeepAlive(void *ptr); - (my_ulonglong)insertId; // Locking +- (void)lockConnection; - (void)unlockConnection; // Database structure diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m index 86261d4d..4e6e0ada 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m @@ -1352,7 +1352,14 @@ void performThreadedKeepAlive(void *ptr) } } - [queryLock lock]; + // Lock on this thread for normal result sets... + if (streamResultType == MCP_NO_STREAMING) { + [queryLock lock]; + + // ...but streaming result unlock on the main thread after processing, so ensure a lock on the main thread. + } else { + [self lockConnection]; + } // Run (or re-run) the query, timing the execution time of the query - note // that this time will include network lag. @@ -1480,11 +1487,21 @@ void performThreadedKeepAlive(void *ptr) #pragma mark Connection locking /** - * Unlock the connection + * Lock the connection from any thread + */ +- (void)lockConnection +{ + if ([NSThread isMainThread]) [queryLock lock]; + else [queryLock performSelectorOnMainThread:@selector(lock) withObject:nil waitUntilDone:YES]; +} + +/** + * Unlock the connection from any thread */ - (void)unlockConnection { - [queryLock performSelectorOnMainThread:@selector(unlock) withObject:nil waitUntilDone:YES]; + if ([NSThread isMainThread]) [queryLock unlock]; + else [queryLock performSelectorOnMainThread:@selector(unlock) withObject:nil waitUntilDone:YES]; } #pragma mark - |