From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: Mangement of fdtable[]
Date: Sun, 25 Oct 2015 18:15:51 -0700 [thread overview]
Message-ID: <151025181551.ZM13396@torch.brasslantern.com> (raw)
In-Reply-To: <20151025184446.5bb5ae63@ntlworld.com>
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@brasslantern.com> 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;
prev parent reply other threads:[~2015-10-26 1:15 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-16 0:22 Bart Schaefer
2015-10-16 9:56 ` Chi Hsuan Yen
2015-10-16 19:44 ` Peter Stephenson
2015-10-24 18:16 ` Peter Stephenson
2015-10-24 18:43 ` Bart Schaefer
2015-10-24 19:14 ` Peter Stephenson
2015-10-24 19:37 ` Bart Schaefer
2015-10-24 19:43 ` Peter Stephenson
2015-10-24 21:05 ` Bart Schaefer
2015-10-25 18:44 ` Peter Stephenson
2015-10-26 1:15 ` Bart Schaefer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=151025181551.ZM13396@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).