Megatest

Diff
Login

Differences From Artifact [47a35a69e2]:

To Artifact [792a08dc51]:


196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
;;     retval tells send to expect and wait for return data (one line) and return it or time out
;;       this is for ping where we don't want to necessarily have set up our own server yet.
;;
;; NOTE: see below for beginnings of code to allow re-use of tcp connections
;;        - I believe (without substantial evidence) that re-using connections will
;;          be beneficial ...
;;
(define (send udata host-port qrykey cmd params)
  (mutex-lock! *send-mutex*)
  (let* ((my-host-port (udat-host-port udata))          ;; remote will return to this
	 (isme         (equal? host-port my-host-port)) ;; calling myself?
	 ;; dat is a self-contained work block that can be sent or handled locally
	 (dat          (list my-host-port qrykey cmd params))
	 (parts        (string-split host-port ":"))
	 (host         (car parts))







|







196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
;;     retval tells send to expect and wait for return data (one line) and return it or time out
;;       this is for ping where we don't want to necessarily have set up our own server yet.
;;
;; NOTE: see below for beginnings of code to allow re-use of tcp connections
;;        - I believe (without substantial evidence) that re-using connections will
;;          be beneficial ...
;;
(define (send-receive udata host-port qrykey cmd params)
  (mutex-lock! *send-mutex*)
  (let* ((my-host-port (udat-host-port udata))          ;; remote will return to this
	 (isme         (equal? host-port my-host-port)) ;; calling myself?
	 ;; dat is a self-contained work block that can be sent or handled locally
	 (dat          (list my-host-port qrykey cmd params))
	 (parts        (string-split host-port ":"))
	 (host         (car parts))
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
	    (close-output-port oup)
	    (mutex-unlock! *send-mutex*)
	    res)))))

;; send a request to the given host-port and register a mailbox in udata
;; wait for the mailbox data and return it
;;
(define (send-receive uconn host-port cmd data)
  (send uconn host-port 'qrykey cmd data))

;;======================================================================
;; responder side
;;======================================================================

;; take a request, rdat, and if not immediate put it in the work queue







|







223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
	    (close-output-port oup)
	    (mutex-unlock! *send-mutex*)
	    res)))))

;; send a request to the given host-port and register a mailbox in udata
;; wait for the mailbox data and return it
;;
#;(define (send-receive uconn host-port cmd data)
  (send uconn host-port 'qrykey cmd data))

;;======================================================================
;; responder side
;;======================================================================

;; take a request, rdat, and if not immediate put it in the work queue
306
307
308
309
310
311
312


313
314
315
316
317
318
319
    ;; put this following into a do-work procedure
    (match rdat
      ((rem-host-port qrykey cmd params)
       (let* ((start-time (current-milliseconds))
	      (result (proc rem-host-port qrykey cmd params))
	      (end-time (current-milliseconds))
	      (run-time (- end-time start-time)))


	 result))
      (else
       (print "ERROR: rdat "rdat", did not match rem-host-port qrykey cmd params")
       #f))))
           
;;======================================================================
;; misc utils







>
>







306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
    ;; put this following into a do-work procedure
    (match rdat
      ((rem-host-port qrykey cmd params)
       (let* ((start-time (current-milliseconds))
	      (result (proc rem-host-port qrykey cmd params))
	      (end-time (current-milliseconds))
	      (run-time (- end-time start-time)))
	 (if (> run-time 1000)
	     (print "ULEX INFO: Note that "cmd" with params "params" took "run-time"ms to complete."))
	 result))
      (else
       (print "ERROR: rdat "rdat", did not match rem-host-port qrykey cmd params")
       #f))))
           
;;======================================================================
;; misc utils