Corrected lock function problems
This commit is contained in:
+3
-3
@@ -25,13 +25,13 @@
|
|||||||
ks-begin-transaction
|
ks-begin-transaction
|
||||||
ks-end-transaction
|
ks-end-transaction
|
||||||
ks-abort-transaction
|
ks-abort-transaction
|
||||||
|
ks-with-lock
|
||||||
)
|
)
|
||||||
|
|
||||||
(define (any? a) #t)
|
(define (any? a) #t)
|
||||||
|
|
||||||
(define-struct keystore
|
(define-struct keystore
|
||||||
(file path dbh lock-sem (in-lock #:mutable) (entered #:mutable))
|
(file path dbh lock-sem (in-lock #:mutable) (entered #:mutable))
|
||||||
#:transparent
|
|
||||||
)
|
)
|
||||||
|
|
||||||
(define keystore*? keystore?)
|
(define keystore*? keystore?)
|
||||||
@@ -62,7 +62,7 @@
|
|||||||
(λ ()
|
(λ ()
|
||||||
(cond
|
(cond
|
||||||
((eq? (keystore-in-lock ksh) (current-thread))
|
((eq? (keystore-in-lock ksh) (current-thread))
|
||||||
(set-keystore-entered! ksh (+ keystore-entered ksh) 1))
|
(set-keystore-entered! ksh (+ (keystore-entered ksh) 1)))
|
||||||
(else
|
(else
|
||||||
(semaphore-wait (keystore-lock-sem ksh))
|
(semaphore-wait (keystore-lock-sem ksh))
|
||||||
(set-keystore-entered! ksh 1)
|
(set-keystore-entered! ksh 1)
|
||||||
@@ -70,7 +70,7 @@
|
|||||||
(set-keystore-in-lock! ksh (current-thread)))
|
(set-keystore-in-lock! ksh (current-thread)))
|
||||||
proc
|
proc
|
||||||
(λ ()
|
(λ ()
|
||||||
(set-keystore-entered! (- (keystore-entered ksh) 1))
|
(set-keystore-entered! ksh (- (keystore-entered ksh) 1))
|
||||||
(when (= (keystore-entered ksh) 0)
|
(when (= (keystore-entered ksh) 0)
|
||||||
(set-keystore-in-lock! ksh #f)
|
(set-keystore-in-lock! ksh #f)
|
||||||
(semaphore-post (keystore-lock-sem ksh))))
|
(semaphore-post (keystore-lock-sem ksh))))
|
||||||
|
|||||||
Reference in New Issue
Block a user