Fossil SCM

unloadTcl is only needed on Win32, not for Win64 or any other platform.

jan.nijtmans 2013-09-27 07:49 UTC trunk
Commit 0013d9ccb6595fd6ff120d548d976daede4a4626
2 files changed +2 -2 +10 -19
+2 -2
--- src/main.c
+++ src/main.c
@@ -346,20 +346,20 @@
346346
/*
347347
** atexit() handler which frees up "some" of the resources
348348
** used by fossil.
349349
*/
350350
static void fossil_atexit(void) {
351
-#if defined(_WIN32) && defined(FOSSIL_ENABLE_TCL) && defined(USE_TCL_STUBS)
351
+#if defined(_WIN32) && !defined(_WIN64) && defined(FOSSIL_ENABLE_TCL) && defined(USE_TCL_STUBS)
352352
/*
353353
** If Tcl is compiled on Windows using the latest MinGW, Fossil can crash
354354
** when exiting while a stubs-enabled Tcl is still loaded. This is due to
355355
** a bug in MinGW, see:
356356
**
357357
** http://comments.gmane.org/gmane.comp.gnu.mingw.user/41724
358358
**
359359
** The workaround is to manually unload the loaded Tcl library prior to
360
- ** exiting the process.
360
+ ** exiting the process. Win64 is not affected.
361361
*/
362362
unloadTcl(g.interp, &g.tcl);
363363
#endif
364364
#ifdef FOSSIL_ENABLE_JSON
365365
cson_value_free(g.json.gc.v);
366366
--- src/main.c
+++ src/main.c
@@ -346,20 +346,20 @@
346 /*
347 ** atexit() handler which frees up "some" of the resources
348 ** used by fossil.
349 */
350 static void fossil_atexit(void) {
351 #if defined(_WIN32) && defined(FOSSIL_ENABLE_TCL) && defined(USE_TCL_STUBS)
352 /*
353 ** If Tcl is compiled on Windows using the latest MinGW, Fossil can crash
354 ** when exiting while a stubs-enabled Tcl is still loaded. This is due to
355 ** a bug in MinGW, see:
356 **
357 ** http://comments.gmane.org/gmane.comp.gnu.mingw.user/41724
358 **
359 ** The workaround is to manually unload the loaded Tcl library prior to
360 ** exiting the process.
361 */
362 unloadTcl(g.interp, &g.tcl);
363 #endif
364 #ifdef FOSSIL_ENABLE_JSON
365 cson_value_free(g.json.gc.v);
366
--- src/main.c
+++ src/main.c
@@ -346,20 +346,20 @@
346 /*
347 ** atexit() handler which frees up "some" of the resources
348 ** used by fossil.
349 */
350 static void fossil_atexit(void) {
351 #if defined(_WIN32) && !defined(_WIN64) && defined(FOSSIL_ENABLE_TCL) && defined(USE_TCL_STUBS)
352 /*
353 ** If Tcl is compiled on Windows using the latest MinGW, Fossil can crash
354 ** when exiting while a stubs-enabled Tcl is still loaded. This is due to
355 ** a bug in MinGW, see:
356 **
357 ** http://comments.gmane.org/gmane.comp.gnu.mingw.user/41724
358 **
359 ** The workaround is to manually unload the loaded Tcl library prior to
360 ** exiting the process. Win64 is not affected.
361 */
362 unloadTcl(g.interp, &g.tcl);
363 #endif
364 #ifdef FOSSIL_ENABLE_JSON
365 cson_value_free(g.json.gc.v);
366
+10 -19
--- src/th_tcl.c
+++ src/th_tcl.c
@@ -868,49 +868,35 @@
868868
return TH_ERROR;
869869
}
870870
return TH_OK;
871871
}
872872
873
+#if defined(_WIN32) && !defined(_WIN64) && defined(FOSSIL_ENABLE_TCL) && defined(USE_TCL_STUBS)
873874
/*
874875
** Finalizes and unloads the previously loaded Tcl library, if applicable.
875876
*/
876877
int unloadTcl(
877878
Th_Interp *interp,
878879
void *pContext
879880
){
880881
struct TclContext *tclContext = (struct TclContext *)pContext;
881882
Tcl_Interp *tclInterp;
882
- tcl_FinalizeProc *xFinalize;
883
-#if defined(USE_TCL_STUBS)
884883
void *library;
885
-#endif /* defined(USE_TCL_STUBS) */
886884
887885
if ( !tclContext ){
888886
Th_ErrorMessage(interp,
889887
"invalid Tcl context", (const char *)"", 0);
890888
return TH_ERROR;
891889
}
892890
/*
893
- ** Grab the Tcl_Finalize function pointer prior to deleting the Tcl
894
- ** interpreter because the memory backing the Tcl stubs table will
895
- ** be going away.
896
- */
897
- xFinalize = tclContext->xFinalize;
898
- /*
899891
** If the Tcl interpreter has been created, formally delete it now.
900892
*/
901893
tclInterp = tclContext->interp;
902894
if ( tclInterp ){
903895
Tcl_DeleteInterp(tclInterp);
904
- tclContext->interp = tclInterp = 0;
905
- }
906
- /*
907
- ** If the Tcl library is not finalized prior to unloading it, a deadlock
908
- ** can occur in some circumstances (i.e. the [clock] thread is running).
909
- */
910
- if( xFinalize ) xFinalize();
911
-#if defined(USE_TCL_STUBS)
896
+ tclContext->interp = 0;
897
+ }
912898
/*
913899
** If Tcl is compiled on Windows using the latest MinGW, Fossil can crash
914900
** when exiting while a stubs-enabled Tcl is still loaded. This is due to
915901
** a bug in MinGW, see:
916902
**
@@ -919,16 +905,21 @@
919905
** The workaround is to manually unload the loaded Tcl library prior to
920906
** exiting the process.
921907
*/
922908
library = tclContext->library;
923909
if( library ){
910
+ /*
911
+ ** If the Tcl library is not finalized prior to unloading it, a deadlock
912
+ ** can occur in some circumstances (i.e. the [clock] thread is running).
913
+ */
914
+ tclContext->xFinalize();
924915
dlclose(library);
925
- tclContext->library = library = 0;
916
+ tclContext->library = 0;
926917
}
927
-#endif /* defined(USE_TCL_STUBS) */
928918
return TH_OK;
929919
}
920
+#endif
930921
931922
/*
932923
** Register the Tcl language commands with interpreter interp.
933924
** Usually this is called soon after interpreter creation.
934925
*/
935926
--- src/th_tcl.c
+++ src/th_tcl.c
@@ -868,49 +868,35 @@
868 return TH_ERROR;
869 }
870 return TH_OK;
871 }
872
 
873 /*
874 ** Finalizes and unloads the previously loaded Tcl library, if applicable.
875 */
876 int unloadTcl(
877 Th_Interp *interp,
878 void *pContext
879 ){
880 struct TclContext *tclContext = (struct TclContext *)pContext;
881 Tcl_Interp *tclInterp;
882 tcl_FinalizeProc *xFinalize;
883 #if defined(USE_TCL_STUBS)
884 void *library;
885 #endif /* defined(USE_TCL_STUBS) */
886
887 if ( !tclContext ){
888 Th_ErrorMessage(interp,
889 "invalid Tcl context", (const char *)"", 0);
890 return TH_ERROR;
891 }
892 /*
893 ** Grab the Tcl_Finalize function pointer prior to deleting the Tcl
894 ** interpreter because the memory backing the Tcl stubs table will
895 ** be going away.
896 */
897 xFinalize = tclContext->xFinalize;
898 /*
899 ** If the Tcl interpreter has been created, formally delete it now.
900 */
901 tclInterp = tclContext->interp;
902 if ( tclInterp ){
903 Tcl_DeleteInterp(tclInterp);
904 tclContext->interp = tclInterp = 0;
905 }
906 /*
907 ** If the Tcl library is not finalized prior to unloading it, a deadlock
908 ** can occur in some circumstances (i.e. the [clock] thread is running).
909 */
910 if( xFinalize ) xFinalize();
911 #if defined(USE_TCL_STUBS)
912 /*
913 ** If Tcl is compiled on Windows using the latest MinGW, Fossil can crash
914 ** when exiting while a stubs-enabled Tcl is still loaded. This is due to
915 ** a bug in MinGW, see:
916 **
@@ -919,16 +905,21 @@
919 ** The workaround is to manually unload the loaded Tcl library prior to
920 ** exiting the process.
921 */
922 library = tclContext->library;
923 if( library ){
 
 
 
 
 
924 dlclose(library);
925 tclContext->library = library = 0;
926 }
927 #endif /* defined(USE_TCL_STUBS) */
928 return TH_OK;
929 }
 
930
931 /*
932 ** Register the Tcl language commands with interpreter interp.
933 ** Usually this is called soon after interpreter creation.
934 */
935
--- src/th_tcl.c
+++ src/th_tcl.c
@@ -868,49 +868,35 @@
868 return TH_ERROR;
869 }
870 return TH_OK;
871 }
872
873 #if defined(_WIN32) && !defined(_WIN64) && defined(FOSSIL_ENABLE_TCL) && defined(USE_TCL_STUBS)
874 /*
875 ** Finalizes and unloads the previously loaded Tcl library, if applicable.
876 */
877 int unloadTcl(
878 Th_Interp *interp,
879 void *pContext
880 ){
881 struct TclContext *tclContext = (struct TclContext *)pContext;
882 Tcl_Interp *tclInterp;
 
 
883 void *library;
 
884
885 if ( !tclContext ){
886 Th_ErrorMessage(interp,
887 "invalid Tcl context", (const char *)"", 0);
888 return TH_ERROR;
889 }
890 /*
 
 
 
 
 
 
891 ** If the Tcl interpreter has been created, formally delete it now.
892 */
893 tclInterp = tclContext->interp;
894 if ( tclInterp ){
895 Tcl_DeleteInterp(tclInterp);
896 tclContext->interp = 0;
897 }
 
 
 
 
 
 
898 /*
899 ** If Tcl is compiled on Windows using the latest MinGW, Fossil can crash
900 ** when exiting while a stubs-enabled Tcl is still loaded. This is due to
901 ** a bug in MinGW, see:
902 **
@@ -919,16 +905,21 @@
905 ** The workaround is to manually unload the loaded Tcl library prior to
906 ** exiting the process.
907 */
908 library = tclContext->library;
909 if( library ){
910 /*
911 ** If the Tcl library is not finalized prior to unloading it, a deadlock
912 ** can occur in some circumstances (i.e. the [clock] thread is running).
913 */
914 tclContext->xFinalize();
915 dlclose(library);
916 tclContext->library = 0;
917 }
 
918 return TH_OK;
919 }
920 #endif
921
922 /*
923 ** Register the Tcl language commands with interpreter interp.
924 ** Usually this is called soon after interpreter creation.
925 */
926

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button