コード例 #1
0
void DatabaseWorkerPool<T>::DirectCommitTransaction(SQLTransaction& transaction)
{
	T* connection = GetFreeConnection();
	int errorCode = connection->ExecuteTransaction(transaction);
	if (!errorCode)
	{
		connection->Unlock();      // OK, operation succesful
		return;
	}

	//! Handle MySQL Errno 1213 without extending deadlock to the core itself
	/// @todo More elegant way
	if (errorCode == ER_LOCK_DEADLOCK)
	{
		uint8 loopBreaker = 5;
		for (uint8 i = 0; i < loopBreaker; ++i)
		{
			if (!connection->ExecuteTransaction(transaction))
				break;
		}
	}

	//! Clean up now.
	transaction->Cleanup();

	connection->Unlock();
}