Skip to content

Commit

Permalink
logwriter shutdown glitch fix
Browse files Browse the repository at this point in the history
  • Loading branch information
IceNinjaman committed Sep 10, 2018
1 parent 1c7022f commit 2c5faf3
Show file tree
Hide file tree
Showing 18 changed files with 44 additions and 6 deletions.
Empty file removed bin/autoupdate.lock
Empty file.
10 changes: 5 additions & 5 deletions plugins/antispam/antispam_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,14 +421,14 @@ PCL void OnPlayerDC(client_t* client,const char* reason)

userData_t* IDiterator;

if(data.players[Plugin_ClientToSlot(client)].playerID == client->playerid) // just to be sure you know, incase of some weird swapping of clients without info to antispam
if(data.players[Plugin_GetClientNumForClient(client)].playerID == client->playerid) // just to be sure you know, incase of some weird swapping of clients without info to antispam
{
IDiterator = &(data.players[Plugin_ClientToSlot(client)]);
IDiterator = &(data.players[Plugin_GetClientNumForClient(client)]);
}

else
{
data.players[Plugin_ClientToSlot(client)].clear();
data.players[Plugin_GetClientNumForClient(client)].clear();
return;
}

Expand All @@ -444,7 +444,7 @@ PCL void OnPlayerDC(client_t* client,const char* reason)
else
{
//Plugin_Printf("Size of vector : %d", data.players.size());
data.players[Plugin_ClientToSlot(client)].clear();
data.players[Plugin_GetClientNumForClient(client)].clear();
return;
}
//playerID = IDiterator->playerID;
Expand Down Expand Up @@ -484,7 +484,7 @@ PCL void OnPlayerGotAuthInfo(netadr_t* from, uint64_t* playerid, uint64_t *steam
return;
}
//Plugin_Printf("Executing OnPlayerConnect\n" );
int slotnum = Plugin_ClientToSlot(cl);
int slotnum = Plugin_GetClientNumForClient(cl);
//Plugin_Printf("Connect clientnum : %d\n",slotnum );
//Plugin_Printf("Connect playerID : %d\n", data.players[slotnum].playerID );
data.players[slotnum].playerID = *playerid;
Expand Down
Empty file modified plugins/antispam/makedll.sh
100644 → 100755
Empty file.
9 changes: 9 additions & 0 deletions plugins/antispam/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CC=gcc
CPP=g++
TARGET_NAME=antispam

all: antispam_plugin.cpp
$(CPP) -m32 -Wall -O1 -g -fvisibility=hidden -mtune=core2 -c antispam_plugin.cpp
$(CPP) -m32 -g -shared -o $(TARGET_NAME).so *.o
clean:
rm *.o
Empty file modified plugins/censor/makedll.sh
100644 → 100755
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions plugins/legacybanlist/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CC=gcc
CPP=g++
TARGET_NAME=legacybanlist

all: qshared.c main.c
$(CC) -m32 -Wall -O1 -g -fvisibility=hidden -mtune=core2 -c *.c
$(CC) -m32 -g -shared -o $(TARGET_NAME).so *.o
clean:
rm *.o
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 16 additions & 1 deletion src/common_logprint.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,15 @@ void QDECL Com_DPrintfLogfile( const char *fmt, ... ) {

static volatile HANDLE wakelogfilewriter;
static volatile DWORD logfilewriterworking;
static volatile qboolean logwriterenabled;
static volatile threadid_t logthreadid = -1;


void* Com_WriteLogThread(void* null)
{
while(1)
logwriterenabled = qtrue;

while(logwriterenabled)
{
Sys_WaitForObject(wakelogfilewriter);
Sys_ResetEvent(wakelogfilewriter);
Expand All @@ -307,12 +312,20 @@ void* Com_WriteLogThread(void* null)
}
Sys_InterlockedDecrement(&logfilewriterworking);
}
logthreadid = -1;
_CloseHandle(wakelogfilewriter);
wakelogfilewriter = 0;
return NULL;
}


void Com_CloseLogFile(volatile fileHandle_t* f)
{
if(*f == 0)
{
return;
}

while(Sys_InterlockedIncrement(&logfilewriterworking) != 1) //Spin here until worker thread is ready
{
Sys_InterlockedDecrement(&logfilewriterworking);
Expand Down Expand Up @@ -376,6 +389,8 @@ void Com_CloseLogFiles()

Com_CloseLogFile( &gamelogfile ); //possible duplicate because this happens in G_ShutdownGame

logwriterenabled = qfalse;

Sys_LeaveCriticalSection(CRITSECT_LOGFILE);

}
Expand Down
5 changes: 5 additions & 0 deletions src/unix/sys_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,11 @@ BOOL __cdecl _CloseHandle(HANDLE handle)
// _ZdlPv_stub(hObject);
free(hObject);
return TRUE;
}else if(hObject->type == 'Evnt'){
hObject->type = 'DEAD';
pthread_mutex_destroy(&hObject->mutex);
free(hObject);
return TRUE;
}
return FALSE;
}
Expand Down

0 comments on commit 2c5faf3

Please sign in to comment.