From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17419 invoked by alias); 26 Oct 2015 01:15:57 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 36968 Received: (qmail 21981 invoked from network); 26 Oct 2015 01:15:56 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version:content-type; bh=lSdgjpTh+y4GzrUwfLCAdz7MAZS1AeSZ/IyOVdwPVBM=; b=dX9Ug5eug+cjEJsVxP1zy2PXPCQ0jji7MVwXWpgtsRKifHAcCrvVNARnbxcwLaig7v bcBwkGNQmkvxK2hbd6Bx8XZ9kHdBMhtmpG8RN4pzsKBqvg/cwzKyKZLiR5yAyukOyfVr yyy3yoM3pqmP3HfzsxBSJUwc7HY+ejOGz9rJvz2pZo6RYiftNQhyggp0XsUn+tRpMTFQ SCpLb0nKU/Ji39FDEkWpByiQTY7v/HqQBSsEzrn0RwE698BFEsCW9JzOci9O2WdnUydS BrEw93s0+2hqUBBOVg/vrM5SPm5TfQaliSNM60jq3HKMw+sTxLFz/4c9BQPUpSUw9hMx F1Ew== X-Gm-Message-State: ALoCoQlGoKlLhoHkARLCtz95cRab3fakl/TrUsuxanZ/5VmubXu22EpvV35lVDh0jbFKlcCXxazQ X-Received: by 10.182.60.193 with SMTP id j1mr3420099obr.57.1445822154349; Sun, 25 Oct 2015 18:15:54 -0700 (PDT) From: Bart Schaefer Message-Id: <151025181551.ZM13396@torch.brasslantern.com> Date: Sun, 25 Oct 2015 18:15:51 -0700 In-Reply-To: <20151025184446.5bb5ae63@ntlworld.com> Comments: In reply to Peter Stephenson "Re: Mangement of fdtable[]" (Oct 25, 6:44pm) References: <151015172252.ZM30709@torch.brasslantern.com> <20151024191621.7f6d71bf@ntlworld.com> <151024114352.ZM27626@torch.brasslantern.com> <20151024201439.35cb8bf1@ntlworld.com> <20151024204341.5c15808d@ntlworld.com> <151024140539.ZM31653@torch.brasslantern.com> <20151025184446.5bb5ae63@ntlworld.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: Mangement of fdtable[] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Oct 25, 6:44pm, Peter Stephenson wrote: } Subject: Re: Mangement of fdtable[] } } On Sat, 24 Oct 2015 14:05:39 -0700 } Bart Schaefer 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;