Fixed race condition where client cookie callbacks could be fired against wrong clients (bug 3375).
This commit is contained in:
parent
8d78c74554
commit
3c18289465
@ -196,9 +196,16 @@ bool CookieManager::SetCookieValue(Cookie *pCookie, int client, char *value)
|
|||||||
|
|
||||||
void CookieManager::OnClientAuthorized(int client, const char *authstring)
|
void CookieManager::OnClientAuthorized(int client, const char *authstring)
|
||||||
{
|
{
|
||||||
|
IGamePlayer *player = playerhelpers->GetGamePlayer(client);
|
||||||
|
|
||||||
|
if (player == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
connected[client] = true;
|
connected[client] = true;
|
||||||
|
|
||||||
TQueryOp *op = new TQueryOp(Query_SelectData, client);
|
TQueryOp *op = new TQueryOp(Query_SelectData, player->GetUserId());
|
||||||
strcpy(op->m_params.steamId, authstring);
|
strcpy(op->m_params.steamId, authstring);
|
||||||
|
|
||||||
g_ClientPrefs.AddQueryToQueue(op);
|
g_ClientPrefs.AddQueryToQueue(op);
|
||||||
@ -261,10 +268,18 @@ void CookieManager::OnClientDisconnecting(int client)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CookieManager::ClientConnectCallback(int client, IQuery *data)
|
void CookieManager::ClientConnectCallback(int userid, IQuery *data)
|
||||||
{
|
{
|
||||||
|
int client;
|
||||||
IResultSet *results;
|
IResultSet *results;
|
||||||
|
|
||||||
|
/* Check validity of client */
|
||||||
|
if ((client = playerhelpers->GetClientOfUserId(userid)) == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check validity of results */
|
||||||
if (data == NULL || (results = data->GetResultSet()) == NULL)
|
if (data == NULL || (results = data->GetResultSet()) == NULL)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -121,7 +121,7 @@ public:
|
|||||||
|
|
||||||
void Unload();
|
void Unload();
|
||||||
|
|
||||||
void ClientConnectCallback(int client, IQuery *data);
|
void ClientConnectCallback(int userid, IQuery *data);
|
||||||
void InsertCookieCallback(Cookie *pCookie, int dbId);
|
void InsertCookieCallback(Cookie *pCookie, int dbId);
|
||||||
void SelectIdCallback(Cookie *pCookie, IQuery *data);
|
void SelectIdCallback(Cookie *pCookie, IQuery *data);
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ void TQueryOp::RunThinkPart()
|
|||||||
|
|
||||||
case Query_SelectData:
|
case Query_SelectData:
|
||||||
{
|
{
|
||||||
g_CookieManager.ClientConnectCallback(m_client, m_pResult);
|
g_CookieManager.ClientConnectCallback(m_userid, m_pResult);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,10 +84,10 @@ void TQueryOp::RunThreadPart()
|
|||||||
if (!BindParamsAndRun())
|
if (!BindParamsAndRun())
|
||||||
{
|
{
|
||||||
g_pSM->LogError(myself,
|
g_pSM->LogError(myself,
|
||||||
"Failed SQL Query, Error: \"%s\" (Query id %i - client %i)",
|
"Failed SQL Query, Error: \"%s\" (Query id %i - userid %i)",
|
||||||
m_database->GetError(),
|
m_database->GetError(),
|
||||||
m_type,
|
m_type,
|
||||||
m_client);
|
m_userid);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_database->UnlockFromFullAtomicOperation();
|
m_database->UnlockFromFullAtomicOperation();
|
||||||
@ -115,10 +115,10 @@ void TQueryOp::Destroy()
|
|||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
TQueryOp::TQueryOp(enum querytype type, int client)
|
TQueryOp::TQueryOp(enum querytype type, int userid)
|
||||||
{
|
{
|
||||||
m_type = type;
|
m_type = type;
|
||||||
m_client = client;
|
m_userid = userid;
|
||||||
m_database = NULL;
|
m_database = NULL;
|
||||||
m_insertId = -1;
|
m_insertId = -1;
|
||||||
m_pResult = NULL;
|
m_pResult = NULL;
|
||||||
|
@ -68,7 +68,7 @@ struct ParamData
|
|||||||
class TQueryOp : public IDBThreadOperation
|
class TQueryOp : public IDBThreadOperation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TQueryOp(enum querytype type, int client);
|
TQueryOp(enum querytype type, int userid);
|
||||||
TQueryOp(enum querytype type, Cookie *cookie);
|
TQueryOp(enum querytype type, Cookie *cookie);
|
||||||
~TQueryOp() {}
|
~TQueryOp() {}
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ private:
|
|||||||
enum querytype m_type;
|
enum querytype m_type;
|
||||||
|
|
||||||
/* Data to be passed to the callback */
|
/* Data to be passed to the callback */
|
||||||
int m_client;
|
int m_userid;
|
||||||
int m_insertId;
|
int m_insertId;
|
||||||
Cookie *m_pCookie;
|
Cookie *m_pCookie;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user