Boost logo

Boost-Commit :

From: kbelco_at_[hidden]
Date: 2007-09-29 17:47:25


Author: noel_belcourt
Date: 2007-09-29 17:47:24 EDT (Sat, 29 Sep 2007)
New Revision: 39613
URL: http://svn.boost.org/trac/boost/changeset/39613

Log:
Renamed variables used in timeout code so I don't make
silly mistakes like using a negative time for the select
timeout.

Also added the setrlimit call back in since the
named_condition_test occassionally consumes multiple cpus
worth of time. That is, when I ran this test -j4, I found
the named_condition test consuming 4 cpus worth of time so
after 300 seconds of elapsed time when the test timed out,
it had consumed almost 1200 seconds worth of cpu. While the
test is killed after the elapsed time expired, setting a hard
cpu limit ensures it's killed after consuming either -lx seconds
worth of cpu or -lx seconds of elapsed time.

Text files modified:
   trunk/tools/jam/src/execunix.c | 18 +++++++++++++-----
   1 files changed, 13 insertions(+), 5 deletions(-)

Modified: trunk/tools/jam/src/execunix.c
==============================================================================
--- trunk/tools/jam/src/execunix.c (original)
+++ trunk/tools/jam/src/execunix.c 2007-09-29 17:47:24 EDT (Sat, 29 Sep 2007)
@@ -62,7 +62,7 @@
 
 static clock_t tps = 0;
 static struct timeval tv;
-static int timeout = 0;
+static int select_timeout = 0;
 static int intr = 0;
 static int cmdsrunning = 0;
 
@@ -221,6 +221,13 @@
              * we use killpg(pid, SIGKILL) to kill the
              * process group leader and all its children.
              */
+ if (0 < globs.timeout)
+ {
+ struct rlimit r_limit;
+ r_limit.rlim_cur = globs.timeout;
+ r_limit.rlim_max = globs.timeout;
+ setrlimit(RLIMIT_CPU, &r_limit);
+ }
             setpgid(cmdtab[slot].pid, cmdtab[slot].pid);
 
             execvp( argv[0], argv );
@@ -358,7 +365,7 @@
     int i, fd_max = 0;
     struct tms buf;
     clock_t current = times(&buf);
- timeout = globs.timeout;
+ select_timeout = globs.timeout;
 
     /* compute max read file descriptor for use in select */
     FD_ZERO(fds);
@@ -380,8 +387,9 @@
 
         if (globs.timeout && cmdtab[i].pid) {
             clock_t consumed = (current - cmdtab[i].start_time) / tps;
- if (0 <= (globs.timeout - consumed) && ((globs.timeout - consumed) < timeout)) {
- timeout = globs.timeout - consumed;
+ clock_t process_timesout = globs.timeout - consumed;
+ if (0 < process_timesout && process_timesout < select_timeout) {
+ select_timeout = process_timesout;
             }
             if (globs.timeout <= consumed) {
                 killpg(cmdtab[i].pid, SIGKILL);
@@ -420,7 +428,7 @@
 
         if (0 < globs.timeout) {
             /* force select to timeout so we can terminate expired processes */
- tv.tv_sec = timeout;
+ tv.tv_sec = select_timeout;
             tv.tv_usec = 0;
 
             /* select will wait until: io on a descriptor, a signal, or we time out */


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk