224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
|
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
|
-
-
+
+
|
;; WARNING: Do not print anything in the lambda of this function as it
;; reads/writes to current in/out port
;;
(define (api:tcp-dispatch-request-make-handler dbstruct) ;; cmd run-id params)
(assert *toppath* "FATAL: api:tcp-dispatch-request-make-handler called but *toppath* not set.")
(if (not *server-signature*)
(set! *server-signature* (tt:mk-signature *toppath*)))
(lambda ()
(let* ((indat (deserialize))
(lambda (indat)
(let* (;; (indat (deserialize))
(newcount (+ *api-process-request-count* 1))
(delay-wait (if (> newcount 10)
(- newcount 10)
0))
(normal-proc (lambda (cmd run-id params)
(case cmd
((ping) *server-signature*)
|
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
|
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
|
-
+
+
|
(else
(normal-proc cmd run-id params))))
(meta (case cmd
((ping) `((sstate . ,server-state)))
(else `((wait . ,delay-wait)))))
(payload (list status errmsg result meta)))
(set! *api-process-request-count* (- *api-process-request-count* 1))
(serialize payload)))
;; (serialize payload)
payload))
(else
(assert #f "FATAL: failed to deserialize indat "indat))))))
(define (api:dispatch-request dbstruct cmd run-id params)
(if (not *no-sync-db*)
(db:open-no-sync-db))
|