Index: dbmod.scm ================================================================== --- dbmod.scm +++ dbmod.scm @@ -4178,14 +4178,14 @@ (tl-test-id (if tl-testdat (db:test-get-id tl-testdat) #f))) (if (member state '("LAUNCHED" "REMOTEHOSTSTART")) (db:general-call dbstruct 'set-test-start-time run-id (list test-id))) - ;; (mutex-lock! *db-transaction-mutex*) (db:with-db dbstruct run-id #f (lambda (db) + (mutex-lock! *db-transaction-mutex*) (let ((tr-res (sqlite3:with-transaction db (lambda () ;; NB// Pass the db so it is part fo the transaction @@ -4204,11 +4204,11 @@ state-status-counts))); end debug:print (if tl-test-id (db:db-test-set-state-status db run-id tl-test-id newstate newstatus #f)) ;; we are still in the transaction - must access the db and not the dbstruct )))))) - ;; (mutex-unlock! *db-transaction-mutex*) + (mutex-unlock! *db-transaction-mutex*) (if (and test-id state status (equal? status "AUTO")) (db:test-data-rollup dbstruct run-id test-id status)) tr-res))) ;; this was moved out of test-set-state-status (mt:process-triggers dbstruct run-id test-id state status))) @@ -4271,31 +4271,30 @@ ;; NB// Pass the db so it is part of the transaction (list newstate newstatus)))) (define (db:set-state-status-and-roll-up-run dbstruct run-id curr-state curr-status) - ;; (mutex-lock! *db-transaction-mutex*) - (db:with-db - dbstruct #f #f - (lambda (db) -;; (let ((tr-res - (sqlite3:with-transaction - db - (lambda () - (let* ((state-status-counts (db:get-all-state-status-counts-for-run dbstruct run-id)) - (state-statuses (db:roll-up-rules state-status-counts #f #f )) - (newstate (car state-statuses)) - (newstatus (cadr state-statuses))) - (if (or (not (eq? newstate curr-state)) (not (eq? newstatus curr-status))) - (begin - (db:set-run-state-status dbstruct run-id newstate newstatus) - #t) ;; changes made - #f) ;; no changes - )))))) - ;; (mutex-unlock! *db-transaction-mutex*) -;; tr-res)))) - + (db:with-db + dbstruct #f #f + (lambda (db) + (mutex-lock! *db-transaction-mutex*) + (let ((tr-res + (sqlite3:with-transaction + db + (lambda () + (let* ((state-status-counts (db:get-all-state-status-counts-for-run dbstruct run-id)) + (state-statuses (db:roll-up-rules state-status-counts #f #f )) + (newstate (car state-statuses)) + (newstatus (cadr state-statuses))) + (if (or (not (eq? newstate curr-state)) (not (eq? newstatus curr-status))) + (begin + (db:set-run-state-status dbstruct run-id newstate newstatus) + #t) ;; changes made + #f) ;; no changes + ))))) + (mutex-unlock! *db-transaction-mutex*) + tr-res)))) (define (db:get-all-state-status-counts-for-run dbstruct run-id) (let* ((test-count-recs (db:with-db dbstruct #f #f (lambda (db) @@ -5839,43 +5838,49 @@ (define (db:register-server dbstruct host port servkey pid ipaddr apath dbname) (db:with-db dbstruct #f #f (lambda (db) + (mutex-lock! *db-transaction-mutex*) (sqlite3:with-transaction db (lambda () - (let* ((sinfo (db:get-server-info dbstruct apath dbname))) - (if sinfo - (begin - (debug:print-info 0 *default-log-port* "Server already running at "sinfo ", while trying to register server " host":"port) - #f) ;; server already registered - (begin - (sqlite3:execute db "INSERT INTO servers (host,port,servkey,pid,ipaddr,apath,dbname) VALUES (?,?,?,?,?,?,?);" - host port servkey pid ipaddr apath dbname) - (db:get-server-info dbstruct apath dbname))))))))) + (let* ((sinfo (db:get-server-info dbstruct apath dbname)) + (res (if sinfo + (begin + (debug:print-info 0 *default-log-port* "Server already running at "sinfo ", while trying to register server " host":"port) + #f) ;; server already registered + (begin + (sqlite3:execute db "INSERT INTO servers (host,port,servkey,pid,ipaddr,apath,dbname) VALUES (?,?,?,?,?,?,?);" + host port servkey pid ipaddr apath dbname) + (db:get-server-info dbstruct apath dbname))))) + (mutex-unlock! *db-transaction-mutex*) + res)))))) ;; run this one in a transaction where first check if host:port is taken (define (db:deregister-server dbstruct host port servkey pid ipaddr apath dbname) (db:with-db dbstruct #f #f (lambda (db) - (sqlite3:with-transaction - db - (lambda () - (let* ((sinfo (db:get-server-info dbstruct apath dbname))) - (if (not sinfo) - (begin - (debug:print-info 0 *default-log-port* "Server already removed for "apath", "dbname) ;; at "sinfo ", while trying to register server " host":"port) - #f) ;; server already deregistered - (begin - (sqlite3:execute db "DELETE FROM servers WHERE apath=? AND dbname=?;" ;; (host,port,servkey,pid,ipaddr,apath,dbname) VALUES (?,?,?,?,?,?,?);" - ;; host port servkey pid ipaddr - apath dbname) - #;(db:get-server-info dbstruct apath dbname) - 'done)))))))) + (mutex-lock! *db-transaction-mutex*) + (let ((res (sqlite3:with-transaction + db + (lambda () + (let* ((sinfo (db:get-server-info dbstruct apath dbname))) + (if (not sinfo) + (begin + (debug:print-info 0 *default-log-port* "Server already removed for "apath", "dbname) ;; at "sinfo ", while trying to register server " host":"port) + #f) ;; server already deregistered + (begin + (sqlite3:execute db "DELETE FROM servers WHERE apath=? AND dbname=?;" ;; (host,port,servkey,pid,ipaddr,apath,dbname) VALUES (?,?,?,?,?,?,?);" + ;; host port servkey pid ipaddr + apath dbname) + #;(db:get-server-info dbstruct apath dbname) + 'done))))))) + (mutex-unlock! *db-transaction-mutex*) + res)))) (define (db:get-server-info dbstruct apath dbname) (db:with-db dbstruct #f #f