Commit 64f33033 authored by Amirouche's avatar Amirouche

okvs: quick fix, protect okvs-session(!) with a mutex

parent 7cdb4e49
......@@ -40,6 +40,7 @@
(scheme bytevector)
(scheme case-lambda)
(scheme generator)
(ice-9 threads)
(only (scheme list) drop take)
(prefix (wiredtiger) wt:)
(wiredtiger pack))
......@@ -109,7 +110,10 @@
(string-append "isolation=\"" (symbol->string (okvs-isolation okvs)) "\"")
""))
(define (get-or-create-session okvs)
;; TODO: move into okvs record
(define okvs-mutex (make-mutex))
(define (%get-or-create-session okvs)
;; XXX: caller has the reponsability to close or put back the session
(if (null? (okvs-sessions okvs))
;; new session
......@@ -120,6 +124,9 @@
(okvs-sessions! okvs (cdr (okvs-sessions okvs)))
session)))
(define (get-or-create-session okvs)
(with-mutex okvs-mutex (%get-or-create-session okvs)))
(define (okvs-config config)
(let ((home #f)
(cache #f)
......@@ -192,7 +199,7 @@ directory"
(define (okvs-transaction-begin okvs . config)
(let ((session (get-or-create-session okvs))) ;; TODO: protect with lock/mutex
(let ((session (get-or-create-session okvs)))
(wt:session-transaction-begin (session-object session) "")
(make-transaction okvs session)))
......@@ -200,19 +207,19 @@ directory"
;; commit the transaction and put back the session into okvs
(wt:session-transaction-commit (session-object (transaction-session transaction)) "")
(wt:session-reset (session-object (transaction-session transaction)))
;; TODO: protect with lock/mutex
(okvs-sessions! (transaction-okvs transaction)
(cons (transaction-session transaction)
(okvs-sessions (transaction-okvs transaction)))))
(with-mutex okvs-mutex
(okvs-sessions! (transaction-okvs transaction)
(cons (transaction-session transaction)
(okvs-sessions (transaction-okvs transaction))))))
(define (okvs-transaction-rollback transaction . config)
;; rollback the transaction and put back the session into okvs
(wt:session-transaction-rollback (session-object (transaction-session transaction)) "")
(wt:session-reset (session-object (transaction-session transaction)))
;; TODO: protect with lock/mutex
(okvs-sessions! (transaction-okvs transaction)
(cons (transaction-session transaction)
(okvs-sessions (transaction-okvs transaction)))))
(with-mutex okvs-mutex
(okvs-sessions! (transaction-okvs transaction)
(cons (transaction-session transaction)
(okvs-sessions (transaction-okvs transaction))))))
(define (okvs-transactional proc)
(lambda (some . args)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment