Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2020-08-28 20:34:52 +0300
committerCorinna Vinschen <corinna@vinschen.de>2020-08-28 20:37:42 +0300
commitb05b0b78fa91514473b092877da0f13be5a6b2c5 (patch)
tree2fd985284095f760b85740e7ca3ba8234ee5ec1d /winsup/cygwin/sigproc.cc
parentc6b45af544b5e48127ea24650a72a2b7b8b75c58 (diff)
Cygwin: sigproc: Eliminate redundant copying of chld_procs
On PROC_EXEC_CLEANUP, the pinfo's in chld_procs are removed. This is done in a loop always removing the child with index 0. This, however, results in copying the last child's pinfo in chld_procs to position 0. Do this for 100 children and you get 99 entirely useless copy operations. Fix this by calling remove_proc in reverse order. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup/cygwin/sigproc.cc')
-rw-r--r--winsup/cygwin/sigproc.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
index f46d3d0d8..aa946fb4c 100644
--- a/winsup/cygwin/sigproc.cc
+++ b/winsup/cygwin/sigproc.cc
@@ -299,8 +299,10 @@ proc_subproc (DWORD what, uintptr_t val)
goto scan_wait;
case PROC_EXEC_CLEANUP:
+ /* Cleanup backwards to eliminate redundant copying of chld_procs
+ array members inside remove_proc. */
while (chld_procs.count ())
- remove_proc (0);
+ remove_proc (chld_procs.count () - 1);
for (w = &waitq_head; w->next != NULL; w = w->next)
CloseHandle (w->next->ev);
break;