diff options
author | Max <post@wickenrode.com> | 2015-09-30 20:23:22 +0200 |
---|---|---|
committer | Max <post@wickenrode.com> | 2015-09-30 20:23:22 +0200 |
commit | 62acd195d1fe1ca3a586e2b88ca5710b09dbb461 (patch) | |
tree | fa377d1ee278a304ee3bd258a0fc85e586255314 | |
parent | 465062dacc96c2c84bfe9cff1ded58c14d01bdcd (diff) | |
download | sequelpro-62acd195d1fe1ca3a586e2b88ca5710b09dbb461.tar.gz sequelpro-62acd195d1fe1ca3a586e2b88ca5710b09dbb461.tar.bz2 sequelpro-62acd195d1fe1ca3a586e2b88ca5710b09dbb461.zip |
Remove a bit duplicate code
-rw-r--r-- | Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m index 40c95321..bcb4e031 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m @@ -526,10 +526,7 @@ asm(".desc ___crashreporter_info__, 0x10"); // Calling mysql_init will have automatically installed per-thread variables if necessary, // so track their installation for removal and to avoid recreating again. - if (!pthread_getspecific(mySQLThreadInitFlagKey)) { - pthread_setspecific(mySQLThreadInitFlagKey, &mySQLThreadFlag); - [(NSNotificationCenter *)[NSNotificationCenter defaultCenter] addObserver:[self class] selector:@selector(_removeThreadVariables:) name:NSThreadWillExitNotification object:[NSThread currentThread]]; - } + [self _validateThreadSetup]; // Disable automatic reconnection, as it's handled in-framework to preserve // options, encodings and connection state. @@ -1018,6 +1015,8 @@ asm(".desc ___crashreporter_info__, 0x10"); * Ensure that the thread this method is called on has been registered for * use with MySQL. MySQL requires thread-specific variables for safe * execution. + * + * Calling this multiple times per thread is OK. */ - (void)_validateThreadSetup { @@ -1026,7 +1025,7 @@ asm(".desc ___crashreporter_info__, 0x10"); if (pthread_getspecific(mySQLThreadInitFlagKey)) return; // If not, install it - mysql_thread_init(); + mysql_thread_init(); // multiple calls per thread OK. // Mark the thread to avoid multiple installs pthread_setspecific(mySQLThreadInitFlagKey, &mySQLThreadFlag); |