Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Mangement of fdtable[]
On Oct 25, 6:44pm, Peter Stephenson wrote:
} Subject: Re: Mangement of fdtable[]
}
} On Sat, 24 Oct 2015 14:05:39 -0700
} Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
} > OK, so the next question is, if the descriptor is going to be closed by
} > some external library (again I refer to db_gdbm.c), how should the
} > module mark it as no longer used in fdtable? Poke FDT_UNUSED directly?
}
} I guess so, it's just the rest of zclose() apart from the close itself.
So this then.
diff --git a/Src/Modules/db_gdbm.c b/Src/Modules/db_gdbm.c
index 76d4751..0329632 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;
Messages sorted by:
Reverse Date,
Date,
Thread,
Author