about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2004-04-23 11:17:13 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2004-04-23 11:17:13 +0000
commit63442b3eaa58d5fd140306bd2ce85dd994284889 (patch)
tree651a80eebbdf2fe8b766fb6a260bafa13661169c
parent5747147afff8a991561a490eca38892c1971a901 (diff)
downloadzsh-63442b3eaa58d5fd140306bd2ce85dd994284889.tar.gz
zsh-63442b3eaa58d5fd140306bd2ce85dd994284889.tar.xz
zsh-63442b3eaa58d5fd140306bd2ce85dd994284889.zip
19810: ksh autoloading
19812: autoloaded traps which are still buggy.
-rw-r--r--ChangeLog9
-rw-r--r--Src/builtin.c14
-rw-r--r--Src/exec.c4
3 files changed, 17 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index a0a4f29ff..720cd1804 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2004-04-23  Peter Stephenson  <pws@csr.com>
+
+	* 19810: Src/exec.c: avoid setting flag on Eprog which may
+	no longer be valid.  Had no feedback, so don't know if
+	it helps, but at worst harmless.
+
+	* 19812: Src/builtin.c: avoid race with autoloaded trap functions.
+	However, I think these still need substantial improvement.
+
 2004-04-21  Peter Stephenson  <pws@csr.com>
 
 	* 19809: Src/jobs.c, Src/signals.c, Src/signals.h: improve
diff --git a/Src/builtin.c b/Src/builtin.c
index 010c8c1f3..b8fd3f3b8 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -2515,12 +2515,13 @@ bin_functions(char *name, char **argv, Options ops, int func)
 	    shf = (Shfunc) zshcalloc(sizeof *shf);
 	    shf->flags = on;
 	    shf->funcdef = mkautofn(shf);
+	    shfunctab->addnode(shfunctab, ztrdup(*argv), shf);
 
 	    if (!strncmp(*argv, "TRAP", 4) &&
 		(signum = getsignum(*argv + 4)) != -1) {
 		if (settrap(signum, shf->funcdef)) {
-		    freeeprog(shf->funcdef);
-		    zfree(shf, sizeof(*shf));
+		    shfunctab->removenode(shfunctab, *argv);
+		    shfunctab->freenode((HashNode)shf);
 		    returnval = 1;
 		    ok = 0;
 		}
@@ -2528,12 +2529,9 @@ bin_functions(char *name, char **argv, Options ops, int func)
 		    sigtrapped[signum] |= ZSIG_FUNC;
 	    }
 
-	    if (ok) {
-		shfunctab->addnode(shfunctab, ztrdup(*argv), shf);
-		if (OPT_ISSET(ops,'X') &&
-		    eval_autoload(shf, shf->nam, ops, func))
-		    returnval = 1;
-	    }
+	    if (ok && OPT_ISSET(ops,'X') &&
+		eval_autoload(shf, shf->nam, ops, func))
+		returnval = 1;
 	} else
 	    returnval = 1;
     }
diff --git a/Src/exec.c b/Src/exec.c
index ff34edb4b..1bc461ffa 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -3546,10 +3546,10 @@ doshfunc(char *name, Eprog prog, LinkList doshargs, int flags, int noreturnval)
     if (prog->flags & EF_RUN) {
 	Shfunc shf;
 
-	runshfunc(prog, NULL, fstack.name);
-
 	prog->flags &= ~EF_RUN;
 
+	runshfunc(prog, NULL, fstack.name);
+
 	if (!(shf = (Shfunc) shfunctab->getnode(shfunctab,
 						(name = fname)))) {
 	    zwarn("%s: function not defined by file", name, 0);