From f2575a3a755e625330263c06403d167f7e7901d4 Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 18 Feb 2016 02:49:28 +0100 Subject: * Change a while() to do while; to help code analysis * Add log message (possibly related to #2258) --- .../Source/SPMySQLConnection Categories/Querying & Preparation.m | 5 ++--- Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m | 5 ++++- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'Frameworks') diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m index e5a48d48..d96ebe52 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m @@ -296,7 +296,7 @@ [self _lockConnection]; unsigned long long theAffectedRowCount; - while (queryAttemptsAllowed > 0) { + do { // While recording the overall execution time (including network lag!), run // the raw query @@ -342,8 +342,7 @@ [self _lockConnection]; NSAssert(mySQLConnection != NULL, @"mySQLConnection has disappeared while checking it!"); - queryAttemptsAllowed--; - } + } while (--queryAttemptsAllowed > 0); id theResult = nil; diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m index e102c24d..286296af 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m @@ -928,7 +928,10 @@ static uint64_t _elapsedMicroSecondsSinceAbsoluteTime(uint64_t comparisonTime) uint64_t disconnectStartTime_t = mach_absolute_time(); while (![self _tryLockConnection]) { usleep(100000); - if (_elapsedSecondsSinceAbsoluteTime(disconnectStartTime_t) > 10) break; + if (_elapsedSecondsSinceAbsoluteTime(disconnectStartTime_t) > 10) { + NSLog(@"%s: Could not acquire connection lock within time limit (10s). Forcing unlock!",__PRETTY_FUNCTION__); + break; + } } [self _unlockConnection]; [self _cancelKeepAlives]; -- cgit v1.2.3