Index: http-transport.scm ================================================================== --- http-transport.scm +++ http-transport.scm @@ -392,13 +392,16 @@ (set! last-access *last-db-access*) (mutex-unlock! *heartbeat-mutex*) ;; (debug:print 11 "last-access=" last-access ", server-timeout=" server-timeout) ;; - ;; no_traffic + ;; no_traffic, no running tests, if server 0, no running servers ;; (if (and *server-run* + (or (> (db:get-count-tests-running *inmemdb* run-id) 0) + (and (eq? run-id 0) + (> (tasks:num-servers-non-zero-running tdb) 0))) (> (+ last-access server-timeout) (current-seconds))) (begin (debug:print-info 0 "Server continuing, seconds since last db access: " (- (current-seconds) last-access)) ;; Index: tasks.scm ================================================================== --- tasks.scm +++ tasks.scm @@ -141,10 +141,20 @@ (set! res num-in-queue)) mdb "SELECT count(id) FROM servers WHERE run_id=? AND state = 'available';" run-id) res)) + +(define (tasks:num-servers-non-zero-running mdb) + (let ((res 0)) + (sqlite3:for-each-row + (lambda (num-running) + (set! res num-running)) + mdb + "SELECT count(id) FROM servers WHERE run_id != 0 AND state = 'running';" + run-id) + res)) (define (tasks:server-clean-out-old-records-for-run-id mdb run-id tag) (sqlite3:execute mdb "UPDATE servers SET state=?,heartbeat=strftime('%s','now') WHERE state in ('available','shutting-down') AND (strftime('%s','now') - start_time) > 50 AND run_id=?;" (conc "defunct" tag) run-id))