Megatest

Diff
Login

Differences From Artifact [13a08c65d1]:

To Artifact [47ba07ff8b]:


310
311
312
313
314
315
316


317
318
319
320





















321
322
323
324
325
326
327
	   (set! *api-process-request-count* (- *api-process-request-count* 1))
	   ;; (serialize payload)
	   (api:unregister-thread (current-thread))
	   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))





















  (case cmd
    ;;===============================================
    ;; READ/WRITE QUERIES
    ;;===============================================

    ((get-keys-write)                        (db:get-keys dbstruct)) ;; force a dummy "write" query to force server; for debug in -repl
    







>
>


|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
	   (set! *api-process-request-count* (- *api-process-request-count* 1))
	   ;; (serialize payload)
	   (api:unregister-thread (current-thread))
	   payload))
	(else
	 (assert #f "FATAL: failed to deserialize indat "indat))))))
       
(define *last-refresh-of-dbs* 0)
(define *db-starts-running* #f)

(define (api:dispatch-request dbstruct cmd run-id params)
  (if (not *no-sync-db*)(db:open-no-sync-db))

  (thread-start!
   (make-thread
    (lambda ()
      (if (and (not *db-starts-running*)
	       (not run-id) ;; i.e. we are mainl.db
	       (> (- (current-seconds) *last-refresh-of-dbs*) 20))
	  (set! *db-starts-running* #t)
	  (let loop ((dbnum 10))
	    (let* ((dbname     (conc dbnum".db")) ;; Yes, this is correct, use dbnum directly
		   (candidates (dbfile:get-process-options *no-sync-db* "server" dbname)))
	      (if (null? candidates)
		  ;; start a server for this dbfile
		  (tt:server-process-run
		   *toppath*
		   (common:get-testsuite-name)
		   (common:find-local-megatest)
		   dbname)))
	    (thread-sleep! 0.5)
	    (if (> dbnum 0)(loop (- dbnum 1)))
	    (set! *db-starts-running* #f)
	    (set! *last-refresh-of-dbs* (current-seconds)))))))
  (case cmd
    ;;===============================================
    ;; READ/WRITE QUERIES
    ;;===============================================

    ((get-keys-write)                        (db:get-keys dbstruct)) ;; force a dummy "write" query to force server; for debug in -repl