Index: dbmod.scm ================================================================== --- dbmod.scm +++ dbmod.scm @@ -149,10 +149,12 @@ (handler (sqlite3:make-busy-timeout 136000))) (sqlite3:set-busy-handler! db handler) (if write-access (init-proc db)) db)))) + +(define *sync-in-progress* #f) ;; Open the inmem db and the on-disk db ;; populate the inmem db with data ;; ;; Updates fields in dbstruct @@ -194,13 +196,18 @@ (dbr:dbstruct-ondiskdb-set! dbstruct db) (dbr:dbstruct-dbfile-set! dbstruct dbfullname) (dbr:dbstruct-dbfname-set! dbstruct dbfname) (dbr:dbstruct-sync-proc-set! dbstruct (lambda (last-update) - ;; (if db - (dbmod:sync-gasket tables last-update inmem db - dbfullname syncdir))) ;; ) + (if *sync-in-progress* + (debug:print 0 *default-log-port* "WARNING: overlapping calls to sync to disk") + (begin + (set! *sync-in-progress* #t) + (dbmod:sync-gasket tables last-update inmem db + dbfullname syncdir) + (thread-sleep! 0.5) ;; ensure at least 1/2 second down time between sync calls + (set! *sync-in-progress* #f))))) ;; (dbmod:sync-tables tables #f db inmem) ;; (if db (dbmod:sync-gasket tables #f inmem db dbfullname 'fromdest) ;; ) ;; load into inmem (dbr:dbstruct-last-update-set! dbstruct (current-seconds)) ;; should this be offset back in time by one second? dbstruct)) @@ -225,11 +232,10 @@ ((todisk) (dbmod:sync-tables tables last-update inmem dbh) ) (else (dbmod:sync-tables tables last-update dbh inmem)))))) - (define (dbmod:close-db dbstruct) ;; do final sync to disk file ;; (do-sync ...) (sqlite3:finalize! (dbr:dbstruct-ondiskdb dbstruct)))