about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2015-10-26 07:25:51 -0700
committerBarton E. Schaefer <schaefer@zsh.org>2015-10-26 07:25:51 -0700
commit609273875d3fb911c20806aeb7c4d558e698a7f2 (patch)
tree126179989a5e29f8c8782e978d11d1aa8ecf97cd
parent8934007f25600150cee7e6eda2816c9110a9dc69 (diff)
downloadzsh-609273875d3fb911c20806aeb7c4d558e698a7f2.tar.gz
zsh-609273875d3fb911c20806aeb7c4d558e698a7f2.tar.xz
zsh-609273875d3fb911c20806aeb7c4d558e698a7f2.zip
36968: use addmodulefd() to tell the shell about the descriptor of the dbm file
-rw-r--r--ChangeLog3
-rw-r--r--Src/Modules/db_gdbm.c9
2 files changed, 10 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index a55439df4..df70cbd45 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2015-10-26  Barton E. Schaefer  <schaefer@zsh.org>
 
+	* 36968: Src/Modules/db_gdbm.c: use addmodulefd() to tell the
+	shell about the descriptor of the dbm file
+
 	* 36956: Src/mem.c: revert 34451, mmap() is too slow on MacOS
 
 2015-10-26  Peter Stephenson  <p.w.stephenson@ntlworld.com>
diff --git a/Src/Modules/db_gdbm.c b/Src/Modules/db_gdbm.c
index 76d4751bf..032963262 100644
--- a/Src/Modules/db_gdbm.c
+++ b/Src/Modules/db_gdbm.c
@@ -106,7 +106,9 @@ bin_ztie(char *nam, char **args, Options ops, UNUSED(int func))
     }
 
     dbf = gdbm_open(resource_name, 0, read_write, 0666, 0);
-    if(!dbf) {
+    if(dbf)
+	addmodulefd(gdbm_fdesc(dbf), FDT_INTERNAL);
+    else {
 	zwarnnam(nam, "error opening database file %s", resource_name);
 	return 1;
     }
@@ -114,6 +116,7 @@ bin_ztie(char *nam, char **args, Options ops, UNUSED(int func))
     if (!(tied_param = createspecialhash(pmname, &getgdbmnode, &scangdbmkeys,
 					 pmflags))) {
         zwarnnam(nam, "cannot create the requested parameter %s", pmname);
+	fdtable[gdbm_fdesc(dbf)] = FDT_UNUSED;
 	gdbm_close(dbf);
 	return 1;
     }
@@ -319,8 +322,10 @@ gdbmuntie(Param pm)
     GDBM_FILE dbf = (GDBM_FILE)(pm->u.hash->tmpdata);
     HashTable ht = pm->u.hash;
 
-    if (dbf) /* paranoia */
+    if (dbf) { /* paranoia */
+	fdtable[gdbm_fdesc(dbf)] = FDT_UNUSED;
 	gdbm_close(dbf);
+    }
 
     ht->tmpdata = NULL;