@@ -9,11 +9,11 @@ ;; |-sdb.db ;; |-fdb.db ;; |-1.db ;; |-.db (define (make-dbr:dbstruct #!key (path #f)) - (make-vector + (vector #f ;; the main db (contains runs, test_meta etc.) NOT CACHED IN MEM (make-hash-table) ;; run-id => [ rundb inmemdb last-mod last-read last-sync ] #f ;; the global string db (use for state, status etc.) path)) ;; path to database files/megatest area @@ -26,11 +26,11 @@ (let* ((dbhash (vector-ref vec 1)) (runvec (hash-table-ref/default dbhash run-id))) (if runvec runvec (begin - (hash-table-set! dbhash run-id (vector #f #f -1 -1 -1)) + (hash-table-set! dbhash run-id (vector #f #f -1 -1 -1 #f)) (dbr:dbstruct-get-rundb-rec vec run-id))))) ;; [ rundb inmemdb last-mod last-read last-sync ] (define-inline (dbr:dbstruct-field-name->num field-name) (case field-name @@ -37,16 +37,19 @@ ((rundb) 0) ;; the on-disk db ((inmem) 1) ;; the in-memory db ((mtime) 2) ;; last modification time ((rtime) 3) ;; last read time ((stime) 4) ;; last sync time + ((inuse) 5) ;; is the db currently in use (else -1))) ;; get/set rundb fields (define (dbr:dbstruct-get-runrec vec run-id field-name) - (let ((runvec (dbr:dbstruct-get-rundb-rec vec run-id))) - (vector-ref runvec (dbr:dbstruct-field-name->num field-name)))) + (let ((runvec (dbr:dbstruct-get-rundb-rec vec run-id)) + (fieldnum (dbr:dbstruct-field-name->num field-name))) + ;; (vector-set! runvec (dbr:dbstruct-field-name->num 'inuse) #t) + (vector-ref runvec fieldnum))) (define (dbr:dbstruct-set-runvec! vec run-id field-name val) (let ((runvec (dbr:dbstruct-get-rundb-rec vec run-id))) (vector-set! runvec (dbr:dbstruct-field-name->num field-name) rundb)))