Megatest

Diff
Login

Differences From Artifact [95a5f80a6e]:

To Artifact [24167fae4d]:


90
91
92
93
94
95
96
97
98
99
100
101
102
103
104

;; udat struct, used by both caller and callee
;; instantiated as uconn by convention
;;
(defstruct udat
  ;; the listener side
  (port #f)
  (host-port #f)
  (socket #f)
  ;; the peers
  (peers  (make-hash-table)) ;; host:port->peer
  ;; work handling
  (work-queue (make-mailbox))
  (work-proc  #f)                ;; set by user
  (cnum       0)                 ;; cookie number







|







90
91
92
93
94
95
96
97
98
99
100
101
102
103
104

;; udat struct, used by both caller and callee
;; instantiated as uconn by convention
;;
(defstruct udat
  ;; the listener side
  (port #f)
  (host-port #f) ;; my host:port
  (socket #f)
  ;; the peers
  (peers  (make-hash-table)) ;; host:port->peer
  ;; work handling
  (work-queue (make-mailbox))
  (work-proc  #f)                ;; set by user
  (cnum       0)                 ;; cookie number
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
;;
(define (do-work uconn rdat)
  (let* () ;; get it each time - conceivebly it could change
    ;; put this following into a do-work procedure
    (match rdat
      ((rem-host-port qrykey cmd params)
       (case cmd
	 ((ping) #t) ;; bypass calling the proc
	 (else
	  (let* ((proc       (udat-work-proc uconn))
		 (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")))))

;;======================================================================
;; misc utils
;;======================================================================

(define (pp-uconn uconn)
  (pp (udat->alist uconn)))

  
;;======================================================================
;; network utilities
;;======================================================================

;; NOTE: Look at address-info egg as alternative to some of this

(define (rate-ip ipaddr)







|

















<







214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238

239
240
241
242
243
244
245
;;
(define (do-work uconn rdat)
  (let* () ;; get it each time - conceivebly it could change
    ;; put this following into a do-work procedure
    (match rdat
      ((rem-host-port qrykey cmd params)
       (case cmd
	 ((ping) 'ping-ack) ;; bypass calling the proc
	 (else
	  (let* ((proc       (udat-work-proc uconn))
		 (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")))))

;;======================================================================
;; misc utils
;;======================================================================

(define (pp-uconn uconn)
  (pp (udat->alist uconn)))


;;======================================================================
;; network utilities
;;======================================================================

;; NOTE: Look at address-info egg as alternative to some of this

(define (rate-ip ipaddr)