@@ -91,7 +91,7 @@ bool CHTTPD::StartHTTPD ( const char* szIP, unsigned int port )
91
91
return bResult;
92
92
}
93
93
94
- // Called from worker thread.
94
+ // Called from worker thread. Careful now.
95
95
// Do some stuff before allowing EHS to do the proper routing
96
96
HttpResponse * CHTTPD::RouteRequest ( HttpRequest * ipoHttpRequest )
97
97
{
@@ -227,6 +227,7 @@ CAccount * CHTTPD::CheckAuthentication ( HttpRequest * ipoHttpRequest )
227
227
if ( strAccountName.compare ( CONSOLE_ACCOUNT_NAME ) != 0 )
228
228
{
229
229
// Handle initial login logging
230
+ std::lock_guard< std::mutex > guard ( m_mutexLoggedInMap );
230
231
if ( m_LoggedInMap.find ( authName ) == m_LoggedInMap.end () )
231
232
CLogger::AuthPrintf ( " HTTP: '%s' entered correct password from %s\n " , authName.c_str () , ipoHttpRequest->GetAddress ().c_str () );
232
233
m_LoggedInMap[authName] = GetTickCount64_ ();
@@ -245,15 +246,10 @@ CAccount * CHTTPD::CheckAuthentication ( HttpRequest * ipoHttpRequest )
245
246
return m_pGuestAccount;
246
247
}
247
248
249
+ // Called from worker thread. Careful now.
248
250
void CHTTPD::HttpPulse ( void )
249
251
{
250
- // Prevent more than one thread running this at once
251
- static int iBusy = 0 ;
252
- if ( ++iBusy > 1 )
253
- {
254
- iBusy--;
255
- return ;
256
- }
252
+ std::lock_guard< std::mutex > guard ( m_mutexLoggedInMap );
257
253
258
254
long long llExpireTime = GetTickCount64_ () - 1000 * 60 * 5 ; // 5 minute timeout
259
255
@@ -263,23 +259,21 @@ void CHTTPD::HttpPulse ( void )
263
259
// Remove if too long since last request
264
260
if ( iter->second < llExpireTime )
265
261
{
266
- g_pGame->Lock (); // get the mutex (blocking)
267
262
CLogger::AuthPrintf ( " HTTP: '%s' no longer connected\n " , iter->first .c_str () );
268
263
m_LoggedInMap.erase ( iter++ );
269
- g_pGame->Unlock ();
270
264
}
271
265
else
272
266
iter++;
273
267
}
274
-
275
- iBusy--;
276
268
}
277
269
278
270
//
279
271
// Do DoS check here
280
- //
272
+ // Called from worker thread. Careful now.
281
273
bool CHTTPD::ShouldAllowConnection ( const char * szAddress )
282
274
{
275
+ std::lock_guard< std::mutex > guard ( m_mutexHttpDosProtect );
276
+
283
277
if ( MapContains ( m_HttpDosExcludeMap, szAddress ) )
284
278
return true ;
285
279
0 commit comments