276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
|
num-synced)
0))))
;; close all opened run-id dbs
(define (db:close-all dbstruct)
;; finalize main.db
(db:sync-touched dbstruct 0 force-sync: #t)
(sqlite3:finalize! (db:get-db dbstruct #f))
(let* ((local (dbr:dbstruct-get-local dbstruct))
(rundb (dbr:dbstruct-get-rundb dbstruct)))
(if local
(for-each
(lambda (db)
(if (sqlite3:database? db)
(begin
(sqlite3:interrupt! db)
(sqlite3:finalize! db #t))))
(hash-table-values (dbr:dbstruct-get-locdbs dbstruct))))
(thread-sleep! 3)
(if (and rundb
(sqlite3:database? rundb))
(handle-exceptions
exn
#t ;; (debug:print 0 "WARNING: database files may not have been closed correctly. Consider running -cleanup-db")
(sqlite3:interrupt! rundb)
(sqlite3:finalize! rundb #t)))))
(define (db:open-inmem-db)
(let* ((db (sqlite3:open-database ":memory:"))
(handler (make-busy-timeout 3600)))
(db:initialize-run-id-db db)
(sqlite3:set-busy-handler! db handler)
db))
|
>
>
|
>
|
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
|
num-synced)
0))))
;; close all opened run-id dbs
(define (db:close-all dbstruct)
;; finalize main.db
(db:sync-touched dbstruct 0 force-sync: #t)
(common:db-block-further-queries)
(mutex-lock! *db-sync-mutex*) ;; with this perhaps it isn't necessary to use the block-further-queries mechanism?
(sqlite3:finalize! (db:get-db dbstruct #f))
(let* ((local (dbr:dbstruct-get-local dbstruct))
(rundb (dbr:dbstruct-get-rundb dbstruct)))
(if local
(for-each
(lambda (db)
(if (sqlite3:database? db)
(begin
(sqlite3:interrupt! db)
(sqlite3:finalize! db #t))))
(hash-table-values (dbr:dbstruct-get-locdbs dbstruct))))
(thread-sleep! 3)
(if (and rundb
(sqlite3:database? rundb))
(handle-exceptions
exn
#t ;; (debug:print 0 "WARNING: database files may not have been closed correctly. Consider running -cleanup-db")
(sqlite3:interrupt! rundb)
(sqlite3:finalize! rundb #t))))
(mutex-unlock! *db-sync-mutex*))
(define (db:open-inmem-db)
(let* ((db (sqlite3:open-database ":memory:"))
(handler (make-busy-timeout 3600)))
(db:initialize-run-id-db db)
(sqlite3:set-busy-handler! db handler)
db))
|