Index: dbfile.scm ================================================================== --- dbfile.scm +++ dbfile.scm @@ -276,23 +276,27 @@ (define (dbfile:open-db dbstruct run-id init-proc) (if (> *dbfile:num-handles-in-use* 10) (let* ((wait-delay (- *dbfile:num-handles-in-use* 9))) (dbfile:print-err "INFO: over ten dbfile handle threads in use ("*dbfile:num-handles-in-use*") delaying "wait-delay" second") (thread-sleep! wait-delay))) - (let* ((subdb (dbfile:get-subdb dbstruct run-id))) (if (not subdb) ;; not yet defined (begin (dbfile:init-subdb dbstruct run-id init-proc) (dbfile:open-db dbstruct run-id init-proc)) (let* ((dbdat (dbfile:get-dbdat dbstruct run-id))) (if dbdat dbdat (let* ((tmppath (dbr:dbstruct-tmppath dbstruct)) - (tmpdbpath (dbfile:run-id->path tmppath run-id))) - (dbfile:open-sqlite3-db tmpdbpath init-proc sync-mode: 0 journal-mode: "WAL"))))))) - + (tmpdbpath (dbfile:run-id->path tmppath run-id)) + (dbdat (dbfile:open-sqlite3-db tmpdbpath init-proc sync-mode: 0 journal-mode: "WAL"))) + ;; the following line short-circuits the "one db handle per thread" model + ;; + (dbfile:add-dbdat dbstruct run-id dbdat) + ;; + dbdat)))))) + ;; COMBINE dbfile:open-sqlite-db and dbfile:lock-create-open ;; ;; this stuff is for initial debugging, please remove it when ;; this code stabilizes