Index: http-transport.scm ================================================================== --- http-transport.scm +++ http-transport.scm @@ -407,11 +407,12 @@ (if (and *server-run* (or (> (+ last-access server-timeout) (current-seconds)) (and (eq? run-id 0) (> (tasks:num-servers-non-zero-running tdb) 0)) - (> (db:get-count-tests-running *inmemdb* run-id) 0) + (and (not (eq? run-id 0)) ;; only makes sense in non-zero run-id servers + (> (db:get-count-tests-running *inmemdb* run-id) 0)) )) (begin (debug:print-info 0 "Server continuing, seconds since last db access: " (- (current-seconds) last-access)) ;; ;; Consider implementing some smarts here to re-insert the record or kill self is Index: portlogger.scm ================================================================== --- portlogger.scm +++ portlogger.scm @@ -29,11 +29,12 @@ (sqlite3:execute db "CREATE TABLE ports ( port INTEGER PRIMARY KEY, state TEXT DEFAULT 'not-used', - fail_count INTEGER DEFAULT 0);")) + fail_count INTEGER DEFAULT 0, + update_time TIMESTAMP DEFAULT (strftime('%s','now')) );")) db)) (define (portlogger:open-run-close proc . params) (handle-exceptions exn @@ -44,11 +45,11 @@ res))) ;; (fold-row PROC INIT DATABASE SQL . PARAMETERS) (define (portlogger:take-port db portnum) (let* ((qry1 (sqlite3:prepare db "INSERT INTO ports (port,state) VALUES (?,?);")) - (qry2 (sqlite3:prepare db "UPDATE ports SET state=? WHERE port=?;")) + (qry2 (sqlite3:prepare db "UPDATE ports SET state=?,update_time=strftime('%s','now') WHERE port=?;")) (qry3 (sqlite3:prepare db "SELECT state FROM ports WHERE port=?;")) (res (sqlite3:with-transaction db (lambda () ;; (fold-row (lambda (var curr) (or var curr)) #f db "SELECT var FROM foo WHERE id=100;") @@ -75,16 +76,16 @@ res)) ;; set port to "released", "failed" etc. ;; (define (portlogger:set-port db portnum value) - (sqlite3:execute db "UPDATE ports SET state=? WHERE port=?;" value portnum)) + (sqlite3:execute db "UPDATE ports SET state=?,update_time=strftime('%s','now') WHERE port=?;" value portnum)) ;; set port to failed (attempted to take but got error) ;; (define (portlogger:set-failed db portnum) - (sqlite3:execute db "UPDATE ports SET state='failed',fail_count=fail_count+1 WHERE port=?;" portnum)) + (sqlite3:execute db "UPDATE ports SET state='failed',fail_count=fail_count+1,update_time=strftime('%s','now') WHERE port=?;" portnum)) ;;====================================================================== ;; MAIN ;;====================================================================== Index: tasks.scm ================================================================== --- tasks.scm +++ tasks.scm @@ -148,12 +148,11 @@ (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) + "SELECT count(id) FROM servers WHERE run_id != 0 AND state = 'running';") 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))