573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
|
;; 3. gather the lock entries, apply the "winner" heuristic
;; 4. if I'm the winner, set tt-state to 'running else set to 'notthewinner
;;
;; New idea:
;; 1. check all processes entries that match the db
;; 2. sort by fixed heuristic
;; 3. if I'm number one, set state to 'running and db-locked-in to #t
(let* ((candidates (dbfile:with-no-sync-db
nosyncdbpath
(lambda (nsdb)
(dbfile:get-process-options nsdb "server" dbfname))))
(primecand (begin
(assert (not (null? candidates))
"HOW CAN WE NOT BE IN THE PROCESSES DB AS A SERVER?")
(dbfile:row->procinf (car candidates)))))
;; compare primecand with myself
;; if not me check that it is reachable
;; if reachable exit
#f)
#;(let* ((lock-result ;; this is the primary lock - need to double verify that got it
(dbfile:with-no-sync-db
|
>
|
|
|
|
|
>
|
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
|
;; 3. gather the lock entries, apply the "winner" heuristic
;; 4. if I'm the winner, set tt-state to 'running else set to 'notthewinner
;;
;; New idea:
;; 1. check all processes entries that match the db
;; 2. sort by fixed heuristic
;; 3. if I'm number one, set state to 'running and db-locked-in to #t
(let* ((candidates (map dbfile:row->procinfo
(dbfile:with-no-sync-db
nosyncdbpath
(lambda (nsdb)
(dbfile:get-process-options nsdb "server" dbfname)))))
(primecand (begin
(assert (not (null? candidates))
"HOW CAN WE NOT BE IN THE PROCESSES DB AS A SERVER?")
(car candidates))))
;; compare primecand with myself
;; if not me check that it is reachable
;; if reachable exit
#f)
#;(let* ((lock-result ;; this is the primary lock - need to double verify that got it
(dbfile:with-no-sync-db
|