67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
+
+
+
-
+
-
+
|
(let* ((areapath *toppath*);; TODO - resolve from dbstruct to be compatible with multiple areas
(runremote (or area-dat
*runremote*)))
;; ensure we have a record for our connection for given area
(if (not runremote) ;; can remove this one. should never get here.
(begin
(set! *runremote* (make-remote))
(set! runremote *runremote*)
(remote-server-timeout-set! runremote (server:expiration-timeout))
(remote-hh-dat-set! runremote (common:get-homehost ))
(set! runremote *runremote*))) ;; new runremote will come from this on next iteration
)) ;; new runremote will come from this on next iteration
(if (member cmd '(blah))
(begin
(mutex-lock! *send-receive-mutex*)
(if (not *runremote*)(set! *runremote* (make-remote)))
(let ((ulex:conn (remote-ulex:conn *runremote*)))
(if (not ulex:conn)(remote-ulex:conn-set! *runremote* (rmtmod:setup-ulex *toppath*)))
(if (not ulex:conn)(remote-ulex:conn-set! *runremote* (rmtmod:setup-ulex areapath)))
(rmtmod:send-receive-ulex ulex:conn cmd rid params attemptnum area-dat)))
(rmt:send-receive-orig *default-log-port* runremote *rmt-mutex* areapath *db-multi-sync-mutex* cmd rid params attemptnum: attemptnum area-dat: area-dat ro-queries: api:read-only-queries))))
;; RA => e.g. usage (rmt:send-receive 'get-var #f (list varname))
;;
;; add multi-sync-mutex
;;
|
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
-
|
;;
(let* ((start-time (current-seconds)) ;; snapshot time so all use cases get same value
(readonly-mode (rmtmod:calc-ro-mode runremote toppath)))
;; ensure we have a homehost record
(if (not (pair? (remote-hh-dat runremote))) ;; not on homehost
(thread-sleep! 0.1) ;; since we shouldn't get here, delay a little
(remote-hh-dat-set! runremote (common:get-homehost)))
;;(print "BB> readonly-mode is "readonly-mode" dbfile is "dbfile)
(cond
;; give up if more than 15 attempts
((> attemptnum 15)
(debug:print 0 log-port "ERROR: 15 tries to start/connect to server. Giving up.")
|