Index: common.scm ================================================================== --- common.scm +++ common.scm @@ -129,11 +129,12 @@ (define *test-paths* (make-hash-table)) ;; cache test-id to test run paths here (define *test-ids* (make-hash-table)) ;; cache run-id, testname, and item-path => test-id (define *test-info* (make-hash-table)) ;; cache the test info records, update the state, status, run_duration etc. from testdat.db (define *run-info-cache* (make-hash-table)) ;; run info is stable, no need to reget - +(define *launch-setup-mutex* (make-mutex)) ;; need to be able to call launch:setup often so mutex it and re-call the real deal only if *toppath* not set +(define *homehost-mutex* (make-mutex)) ;; Awful. Please FIXME (define *env-vars-by-run-id* (make-hash-table)) ;; Testconfig and runconfig caches. (define *testconfigs* (make-hash-table)) ;; test-name => testconfig @@ -809,19 +810,26 @@ ;; logic for getting homehost. Returns (host . at-home) ;; IF *toppath* is not set, wait up to five seconds trying every two seconds ;; (this is to accomodate the watchdog) ;; (define (common:get-homehost #!key (trynum 5)) + ;; called often especially at start up. use the launch setup mutex to eliminate collisions + (mutex-lock! *homehost-mutex*) (cond - (*home-host* *home-host*) + (*home-host* + (mutex-unlock! *homehost-mutex*) + *home-host*) ((not *toppath*) + (mutex-unlock! *homehost-mutex*) + (launch:setup) ;; safely mutexed now (if (> trynum 0) (begin (thread-sleep! 2) (common:get-homehost trynum: (- trynum 1))) #f)) (else + (mutex-unlock! *homehost-mutex*) (let* ((currhost (get-host-name)) (bestadrs (server:get-best-guess-address currhost)) ;; first look in config, then look in file .homehost, create it if not found (homehost (or (configf:lookup *configdat* "server" "homehost" ) (let ((hhf (conc *toppath* "/.homehost"))) Index: launch.scm ================================================================== --- launch.scm +++ launch.scm @@ -702,10 +702,20 @@ ;; sets; *configdat* (megatest.config info) ;; *runconfigdat* (runconfigs.config info) ;; *configstatus* (status of the read data) ;; (define (launch:setup #!key (force #f)) + (mutex-lock! *launch-setup-mutex*) + (if *toppath* + (begin + (mutex-unlock! *launch-setup-mutex*) + *toppath*) + (let ((res (launch:setup-body force: force))) + (mutex-unlock! *launch-setup-mutex*) + res))) + +(define (launch:setup-body #!key (force #f)) (let* ((toppath (or *toppath* (getenv "MT_RUN_AREA_HOME"))) ;; preserve toppath (runname (common:args-get-runname)) (target (common:args-get-target)) (linktree (common:get-linktree)) (sections (if target (list "default" target) #f)) ;; for runconfigs