summaryrefslogtreecommitdiffstats
path: root/generic/tclZipfs.c
diff options
context:
space:
mode:
authorapnadkarni <apnmbx-wits@yahoo.com>2023-10-21 05:48:54 (GMT)
committerapnadkarni <apnmbx-wits@yahoo.com>2023-10-21 05:48:54 (GMT)
commitffb1230a3c6dfdbb1ba974b44ce60839cc066ddb (patch)
treee65c20d38c221cda4a3cfe1ba402ec376b438af3 /generic/tclZipfs.c
parent00b0ab809d40145b98bbb032e46f6050d030e94e (diff)
parenta21682acad5156d66092b97a3072e5ace01234b0 (diff)
downloadtcl-ffb1230a3c6dfdbb1ba974b44ce60839cc066ddb.zip
tcl-ffb1230a3c6dfdbb1ba974b44ce60839cc066ddb.tar.gz
tcl-ffb1230a3c6dfdbb1ba974b44ce60839cc066ddb.tar.bz2
Bug [33b2486199] - thread create/release unmounts zipfs
Diffstat (limited to 'generic/tclZipfs.c')
-rw-r--r--generic/tclZipfs.c55
1 files changed, 28 insertions, 27 deletions
diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c
index 6ef921a..9372079 100644
--- a/generic/tclZipfs.c
+++ b/generic/tclZipfs.c
@@ -6285,15 +6285,25 @@ ZipfsAppHookFindTclInit(
}
#endif
+/*
+ *------------------------------------------------------------------------
+ *
+ * TclZipfsFinalize --
+ *
+ * Frees all zipfs resources IRRESPECTIVE of open channels (there should
+ * not be any!) etc. To be called at process exit time (from
+ * Tcl_Finalize->TclFinalizeFilesystem)
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Frees up archives loaded into memory.
+ *
+ *------------------------------------------------------------------------
+ */
void TclZipfsFinalize(void)
{
- /*
- * Finalization steps:
- * For every mounted archive, if it no longer has any open handles
- * clean up the mount and associated zip file entries.
- * If there are no more mounted archives, clean up and free the
- * ZipFS.fileHash and ZipFS.zipHash tables.
- */
WriteLock();
if (!ZipFS.initialized) {
Unlock();
@@ -6305,30 +6315,21 @@ void TclZipfsFinalize(void)
for (hPtr = Tcl_FirstHashEntry(&ZipFS.zipHash, &zipSearch); hPtr;
hPtr = Tcl_NextHashEntry(&zipSearch)) {
ZipFile *zf = (ZipFile *) Tcl_GetHashValue(hPtr);
- if (zf->numOpen == 0) {
- Tcl_DeleteHashEntry(hPtr);
- CleanupMount(zf);
- ZipFSCloseArchive(NULL, zf);
- ckfree(zf);
- }
+ Tcl_DeleteHashEntry(hPtr);
+ CleanupMount(zf); /* Frees file entries belonging to the archive */
+ ZipFSCloseArchive(NULL, zf);
+ ckfree(zf);
}
- hPtr = Tcl_FirstHashEntry(&ZipFS.fileHash, &zipSearch);
- if (hPtr == NULL) {
- hPtr = Tcl_FirstHashEntry(&ZipFS.zipHash, &zipSearch);
- if (hPtr == NULL) {
- /* Both hash tables empty. Free all resources */
- Tcl_FSUnregister(&zipfsFilesystem);
- Tcl_DeleteHashTable(&ZipFS.fileHash);
- Tcl_DeleteHashTable(&ZipFS.zipHash);
- if (ZipFS.fallbackEntryEncoding) {
- ckfree(ZipFS.fallbackEntryEncoding);
- ZipFS.fallbackEntryEncoding = NULL;
- }
- ZipFS.initialized = 0;
- }
+ Tcl_FSUnregister(&zipfsFilesystem);
+ Tcl_DeleteHashTable(&ZipFS.fileHash);
+ Tcl_DeleteHashTable(&ZipFS.zipHash);
+ if (ZipFS.fallbackEntryEncoding) {
+ ckfree(ZipFS.fallbackEntryEncoding);
+ ZipFS.fallbackEntryEncoding = NULL;
}
+ ZipFS.initialized = 0;
Unlock();
}