This is a live mirror of the Perl 5 development currently hosted at
Code in wait4pid was calling hv_delete with the hash iterator
authorNicholas Clark <>
Tue, 25 Oct 2005 12:54:18 +0000 (12:54 +0000)
committerNicholas Clark <>
Tue, 25 Oct 2005 12:54:18 +0000 (12:54 +0000)
currently on that entry. On aggregate this does more work, beacuse
the next call to hv_iterinit() would spot the flag, and have to call
the delete routine, while in the meantime any new entries can't
re-use that memory.

p4raw-id: //depot/perl@25848


diff --git a/util.c b/util.c
index 96da1fc..74facce 100644 (file)
--- a/util.c
+++ b/util.c
@@ -2661,6 +2661,13 @@ Perl_wait4pid(pTHX_ Pid_t pid, int *statusp, int flags)
                pid = atoi(hv_iterkey(entry,(I32*)statusp));
                *statusp = SvIVX(sv);
                len = my_sprintf(spid, "%"IVdf, (IV)pid);
+               /* The hash iterator is currently on this entry, so simply
+                  calling hv_delete would trigger the lazy delete, which on
+                  aggregate does more work, beacuse next call to hv_iterinit()
+                  would spot the flag, and have to call the delete routine,
+                  while in the meantime any new entries can't re-use that
+                  memory.  */
+               hv_iterinit(PL_pidstatus);
                return pid;