r1300 - trunk/code/qcommon

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sun Apr 6 08:59:36 EDT 2008


Author: ludwig
Date: 2008-04-06 08:59:35 -0400 (Sun, 06 Apr 2008)
New Revision: 1300

Modified:
   trunk/code/qcommon/common.c
   trunk/code/qcommon/qcommon.h
   trunk/code/qcommon/vm.c
Log:
set flag to allow forced unload of a running VM

required to prevent a client from exiting if the server disconnects (bug 3585)

Modified: trunk/code/qcommon/common.c
===================================================================
--- trunk/code/qcommon/common.c	2008-04-06 12:59:30 UTC (rev 1299)
+++ trunk/code/qcommon/common.c	2008-04-06 12:59:35 UTC (rev 1300)
@@ -277,7 +277,9 @@
 
 	if (code == ERR_DISCONNECT || code == ERR_SERVERDISCONNECT) {
 		CL_Disconnect( qtrue );
+		VM_Forced_Unload_Start();
 		CL_FlushMemory( );
+		VM_Forced_Unload_Done();
 		// make sure we can get at our local stuff
 		FS_PureServerSetLoadedPaks("", "");
 		com_errorEntered = qfalse;

Modified: trunk/code/qcommon/qcommon.h
===================================================================
--- trunk/code/qcommon/qcommon.h	2008-04-06 12:59:30 UTC (rev 1299)
+++ trunk/code/qcommon/qcommon.h	2008-04-06 12:59:35 UTC (rev 1300)
@@ -325,6 +325,8 @@
 
 void	VM_Free( vm_t *vm );
 void	VM_Clear(void);
+void	VM_Forced_Unload_Start(void);
+void	VM_Forced_Unload_Done(void);
 vm_t	*VM_Restart( vm_t *vm );
 
 intptr_t		QDECL VM_Call( vm_t *vm, int callNum, ... );

Modified: trunk/code/qcommon/vm.c
===================================================================
--- trunk/code/qcommon/vm.c	2008-04-06 12:59:30 UTC (rev 1299)
+++ trunk/code/qcommon/vm.c	2008-04-06 12:59:35 UTC (rev 1300)
@@ -40,6 +40,9 @@
 vm_t	*lastVM    = NULL;
 int		vm_debugLevel;
 
+// used by Com_Error to get rid of running vm's before longjmp
+static int forced_unload;
+
 #define	MAX_VM		3
 vm_t	vmTable[MAX_VM];
 
@@ -613,8 +616,12 @@
 	}
 
 	if(vm->callLevel) {
-		Com_Error( ERR_FATAL, "VM_Free(%s) on running vm", vm->name );
-		return;
+		if(!forced_unload) {
+			Com_Error( ERR_FATAL, "VM_Free(%s) on running vm", vm->name );
+			return;
+		} else {
+			Com_Printf( "forcefully unloading %s vm\n", vm->name );
+		}
 	}
 
 	if(vm->destroy)
@@ -648,6 +655,14 @@
 	}
 }
 
+void VM_Forced_Unload_Start(void) {
+	forced_unload = 1;
+}
+
+void VM_Forced_Unload_Done(void) {
+	forced_unload = 0;
+}
+
 void *VM_ArgPtr( intptr_t intValue ) {
 	if ( !intValue ) {
 		return NULL;




More information about the quake3-commits mailing list