Пример #1
0
/*
=================
Sys_DoSignalAction
=================
*/
void Sys_DoSignalAction( int signal, const char* sigstring )
{
	static qboolean signalcaught = qfalse;
	char termmsg[MAX_STRING_CHARS];

	Com_Printf( "Received signal: %s, exiting...\n", sigstring );

	if( signalcaught )
	{
		Com_Printf( "DOUBLE SIGNAL FAULT: Received signal: %s, exiting...\n", sigstring);
	}

	else
	{
		signalcaught = qtrue;
		Com_Printf("Server received signal: %s\nShutting down server...\n", sigstring);
		Com_sprintf(termmsg, sizeof(termmsg), "\nServer received signal: %s\nTerminating server...", sigstring);
		SV_Shutdown( termmsg );

		Sys_EnterCriticalSection( 2 );

		Com_CloseLogFiles(); //close all open logfiles
		FS_Shutdown(qtrue);
	}

	if( signal == SIGTERM || signal == SIGINT )
		Sys_Exit( 1 );
	else
		Sys_Exit( 2 );
}
Пример #2
0
/*
===============
Host_Shutdown

FIXME: this is a callback from Sys_Quit and Sys_Error.  It would be better
to run quit through here before the final handoff to the sys code.
===============
*/
void Host_Shutdown(void)
{
	static qboolean isdown = false;

	if (isdown)
	{
		Con_Print("recursive shutdown\n");
		return;
	}
	if (setjmp(host_abortframe))
	{
		Con_Print("aborted the quitting frame?!?\n");
		return;
	}
	isdown = true;

	// be quiet while shutting down
	S_StopAllSounds();

	// disconnect client from server if active
	CL_Disconnect();

	// shut down local server if active
	Host_ShutdownServer ();

	// Shutdown menu
	if(MR_Shutdown)
		MR_Shutdown();

	// AK shutdown PRVM
	// AK hmm, no PRVM_Shutdown(); yet

	CL_Gecko_Shutdown();
	CL_Video_Shutdown();

	Host_SaveConfig();

	CDAudio_Shutdown ();
	S_Terminate ();
	Curl_Shutdown ();
	NetConn_Shutdown ();
	//PR_Shutdown ();

	if (cls.state != ca_dedicated)
	{
		R_Modules_Shutdown();
		VID_Shutdown();
		Thread_Shutdown();
	}

	Cmd_Shutdown();
	Key_Shutdown();
	CL_Shutdown();
	Sys_Shutdown();
	Log_Close();
	Crypto_Shutdown();
	FS_Shutdown();
	Con_Shutdown();
	Memory_Shutdown();
}
Пример #3
0
/*
=================
Sys_SigHandler
=================
*/
void Sys_SigHandler( int signal )
{
	static qboolean signalcaught = qfalse;

	fprintf( stderr, "Received signal: %s, exiting...\n",
		strsignal(signal) );

	if( signalcaught )
	{
		fprintf( stderr, "DOUBLE SIGNAL FAULT: Received signal: %s, exiting...\n",
			strsignal(signal));
	}

	else
	{
		signalcaught = qtrue;
		Com_Printf("Server received signal: %s\nShutting down server...", strsignal(signal));
		SV_Shutdown(va("\nServer received signal: %s\nTerminating server...", strsignal(signal)) );
		Sys_EnterCriticalSection( 2 );
		if(logfile)
			FS_FCloseFile(logfile);
		if(adminlogfile)
			FS_FCloseFile(adminlogfile);
		if(reliabledump)
			FS_FCloseFile(reliabledump);

		FS_Shutdown(qtrue);
	}

	if( signal == SIGTERM || signal == SIGINT )
		Sys_Exit( 1 );
	else
		Sys_Exit( 2 );
}
Пример #4
0
void Host_FreeCommon( void )
{
	Image_Shutdown();
	Sound_Shutdown();
	Netchan_Shutdown();
	FS_Shutdown();

	Mem_FreePool( &host.mempool );
}
Пример #5
0
/*
=============
Com_Quit_f

Both client and server can use this, and it will
do the apropriate things.
=============
*/
void NORETURN Com_Quit_f( void ) {
	// don't try to shutdown if we are in a recursive error
	if ( !com_errorEntered ) {
		SV_Shutdown ("Server quit\n");
		CL_Shutdown ();
		Com_Shutdown ();
		FS_Shutdown();
	}
	Sys_Quit ();
}
Пример #6
0
/**
 * @brief
 * @sa Qcommon_Init
 * @sa Sys_Quit
 * @note Don't call anything that depends on cvars, command system, or any other
 * subsystem that is allocated in the mem pools and maybe already freed
 */
void Qcommon_Shutdown (void)
{
	HTTP_Cleanup();

	FS_Shutdown();
	Cvar_Shutdown();
	Cmd_Shutdown();
	NET_Shutdown();
	Mem_Shutdown();
	Com_Shutdown();
}
Пример #7
0
/*
* Qcommon_Shutdown
*/
void Qcommon_Shutdown( void )
{
	static qboolean isdown = qfalse;

	if( isdown )
	{
		printf( "Recursive shutdown\n" );
		return;
	}
	isdown = qtrue;

	Com_ScriptModule_Shutdown();
	CM_Shutdown();
	Netchan_Shutdown();
	NET_Shutdown();
	Key_Shutdown();

	Steam_UnloadLibrary();

	Qcommon_ShutdownCommands();
	Memory_ShutdownCommands();

	if( log_stats_file )
	{
		FS_FCloseFile( log_stats_file );
		log_stats_file = 0;
	}
	if( log_file )
	{
		FS_FCloseFile( log_file );
		log_file = 0;
	}
	logconsole = NULL;
	FS_Shutdown();

	wswcurl_cleanup();

	Dynvar_Shutdown();
	dynvars_initialized = qfalse;
	Cvar_Shutdown();
	Cmd_Shutdown();
	Cbuf_Shutdown();
	Memory_Shutdown();
	
	QMutex_Destroy( &com_print_mutex );

	QThreads_Shutdown();
}
Пример #8
0
void TEST_Shutdown (void)
{
	SV_Shutdown("test shutdown", qfalse);
	FS_Shutdown();
	Cmd_Shutdown();
	Cvar_Shutdown();
	Mem_Shutdown();
	Com_Shutdown();
	Cbuf_Shutdown();
	NET_Shutdown();

	com_aliasSysPool = NULL;
	com_cmdSysPool = NULL;
	com_cmodelSysPool = NULL;
	com_cvarSysPool = NULL;
	com_fileSysPool = NULL;
	com_genericPool = NULL;
}
Пример #9
0
void TEST_Shutdown (void)
{
	PTL_InitStartup();
	R_ShutdownImages();
	SV_Shutdown("test shutdown", false);
	FS_Shutdown();
	UI_Shutdown();
	Cmd_Shutdown();
	developer = nullptr;
	Cvar_Shutdown();
	Mem_Shutdown();
	Com_Shutdown();
	Cbuf_Shutdown();
	NET_Shutdown();

	com_aliasSysPool = nullptr;
	com_cmdSysPool = nullptr;
	com_cmodelSysPool = nullptr;
	com_cvarSysPool = nullptr;
	com_fileSysPool = nullptr;
	com_genericPool = nullptr;
}
Пример #10
0
/*
=============
Com_Quit

Both client and server can use this, and it will
do the apropriate things. This function never returns.
=============
*/
void Com_Quit(const char *reason, error_type_t type)
{
    char buffer[MAX_STRING_CHARS];
    char *what = type == ERR_RECONNECT ? "restarted" : "quit";

    if (reason && *reason) {
        Q_snprintf(buffer, sizeof(buffer),
                   "Server %s: %s\n", what, reason);
    } else {
        Q_snprintf(buffer, sizeof(buffer),
                   "Server %s\n", what);
    }

    SV_Shutdown(buffer, type);
    CL_Shutdown();
    NET_Shutdown();
    logfile_close();
    FS_Shutdown();

    Sys_Quit();
    // doesn't get there
}
Пример #11
0
/*
=============
Com_Error

Both client and server can use this, and it will
do the apropriate things.
=============
*/
void Com_Error(error_type_t code, const char *fmt, ...)
{
    char            msg[MAXERRORMSG];
    va_list         argptr;
    size_t          len;

    // may not be entered recursively
    if (com_errorEntered) {
#ifdef _DEBUG
        if (com_debug_break && com_debug_break->integer) {
            Sys_DebugBreak();
        }
#endif
        Sys_Error("recursive error after: %s", com_errorMsg);
    }

    com_errorEntered = qtrue;

    va_start(argptr, fmt);
    len = Q_vscnprintf(msg, sizeof(msg), fmt, argptr);
    va_end(argptr);

    // save error msg
    // can't print into it directly since it may
    // overlap with one of the arguments!
    memcpy(com_errorMsg, msg, len + 1);

    // fix up drity message buffers
    MSG_Init();

    // abort any console redirects
    Com_AbortRedirect();

    // reset Com_Printf recursion level
    com_printEntered = 0;

    X86_POP_FPCW;

    if (code == ERR_DISCONNECT || code == ERR_RECONNECT) {
        Com_WPrintf("%s\n", com_errorMsg);
        SV_Shutdown(va("Server was killed: %s\n", com_errorMsg), code);
        CL_Disconnect(code);
        goto abort;
    }

#ifdef _DEBUG
    if (com_debug_break && com_debug_break->integer) {
        Sys_DebugBreak();
    }
#endif

    // make otherwise non-fatal errors fatal
    if (com_fatal_error && com_fatal_error->integer) {
        code = ERR_FATAL;
    }

    if (code == ERR_DROP) {
        Com_EPrintf("********************\n"
                    "ERROR: %s\n"
                    "********************\n", com_errorMsg);
        SV_Shutdown(va("Server crashed: %s\n", com_errorMsg), ERR_DROP);
        CL_Disconnect(ERR_DROP);
        goto abort;
    }

    if (com_logFile) {
        FS_FPrintf(com_logFile, "FATAL: %s\n", com_errorMsg);
    }

    SV_Shutdown(va("Server fatal crashed: %s\n", com_errorMsg), ERR_FATAL);
    CL_Shutdown();
    NET_Shutdown();
    logfile_close();
    FS_Shutdown();

    Sys_Error("%s", com_errorMsg);
    // doesn't get there

abort:
    if (com_logFile) {
        FS_Flush(com_logFile);
    }
    com_errorEntered = qfalse;
    longjmp(abortframe, -1);
}