mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 07:12:07 +00:00
Fix the signal handler.
The signal handler was always fishy since it modified the global process state but worked on all common platforms. libcurl turns the process into a multithreaded environment, thus breaking that fragile construction. After the signal handler was called the global state is inconsistent and there's a high chance of things going wrong. For example at the net curl download or when setjmp() is called in Qcommon_Frame().
This commit is contained in:
parent
95c1bb9972
commit
7b200208c5
2 changed files with 23 additions and 1 deletions
|
@ -118,10 +118,12 @@ signalhandler(int sig)
|
|||
raise(sig);
|
||||
}
|
||||
|
||||
extern qboolean quitnextframe;
|
||||
|
||||
void
|
||||
terminate(int sig)
|
||||
{
|
||||
Cbuf_AddText("quit");
|
||||
quitnextframe = true;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -76,6 +76,10 @@ qboolean is_portable;
|
|||
// Game given by user
|
||||
char userGivenGame[MAX_QPATH];
|
||||
|
||||
// Game should quit next frame.
|
||||
// Hack for the signal handlers.
|
||||
qboolean quitnextframe;
|
||||
|
||||
// ----
|
||||
|
||||
static void
|
||||
|
@ -424,6 +428,14 @@ Qcommon_Frame(int msec)
|
|||
static qboolean last_was_packetframe;
|
||||
|
||||
|
||||
/* Tells the client to shutdown.
|
||||
Used by the signal handlers. */
|
||||
if (quitnextframe)
|
||||
{
|
||||
Cbuf_AddText("quit");
|
||||
}
|
||||
|
||||
|
||||
/* In case of ERR_DROP we're jumping here. Don't know
|
||||
if that' really save but it seems to work. So leave
|
||||
it alone. */
|
||||
|
@ -731,6 +743,14 @@ Qcommon_Frame(int msec)
|
|||
qboolean packetframe = true;
|
||||
|
||||
|
||||
/* Tells the client to shutdown.
|
||||
Used by the signal handlers. */
|
||||
if (quitnextframe)
|
||||
{
|
||||
Cbuf_AddText("quit");
|
||||
}
|
||||
|
||||
|
||||
/* In case of ERR_DROP we're jumping here. Don't know
|
||||
if that' really save but it seems to work. So leave
|
||||
it alone. */
|
||||
|
|
Loading…
Reference in a new issue