Megatest

Check-in [e858e4927e]
Login
Overview
Comment:wip
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | v1.70-captain-ulex | v1.70-defunct-try
Files: files | file ages | folders
SHA1: e858e4927eb2be2f9db3ffb451330cef49722a7e
User & Date: matt on 2020-01-14 22:43:32
Other Links: branch diff | manifest | tags
Context
2020-01-15
21:14
Ulex setup works check-in: a24928bf83 user: matt tags: v1.70-captain-ulex, v1.70-defunct-try
2020-01-14
22:43
wip check-in: e858e4927e user: matt tags: v1.70-captain-ulex, v1.70-defunct-try
13:22
wip check-in: 4f1427787a user: mrwellan tags: v1.70-captain-ulex, v1.70-defunct-try
Changes

Modified megatest.scm from [00d64b5513] to [6da4d10120].

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

;; (include "common.scm")
;; (include "megatest-version.scm")

;; fake out readline usage of toplevel-command
(define (toplevel-command . a) #f)

(use (prefix sqlite3 sqlite3:) srfi-1 posix regex regex-case srfi-69 (prefix base64 base64:)
     readline apropos json http-client directory-utils typed-records
     http-client srfi-18 extras format tcp6)

;; Added for csv stuff - will be removed
;;
(use sparse-vectors)

(declare (uses mtargs))
(declare (uses mtconfigf))







|
|
|







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

;; (include "common.scm")
;; (include "megatest-version.scm")

;; fake out readline usage of toplevel-command
(define (toplevel-command . a) #f)

(use (prefix sqlite3 sqlite3:) srfi-1 posix regex regex-case
     srfi-69 (prefix base64 base64:) readline apropos json http-client
     directory-utils typed-records http-client srfi-18 extras format tcp6)

;; Added for csv stuff - will be removed
;;
(use sparse-vectors)

(declare (uses mtargs))
(declare (uses mtconfigf))

Modified ulex/ulex.scm from [5d5093dbc4] to [aa4f6bc6b4].

34
35
36
37
38
39
40
41

42
43
44
45
46
47
48
(import srfi-18 pkts matchable regex
	typed-records srfi-69 srfi-1
	srfi-4 regex-case
	(prefix sqlite3 sqlite3:)
	foreign
	tcp6
	;; ulex-netutil
	hostinfo)


;;======================================================================
;; KEY FUNCTIONS - THESE ARE TOO BE EXPOSED AND USED
;;======================================================================

;; connection setup and management functions








|
>







34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
(import srfi-18 pkts matchable regex
	typed-records srfi-69 srfi-1
	srfi-4 regex-case
	(prefix sqlite3 sqlite3:)
	foreign
	tcp6
	;; ulex-netutil
	hostinfo
	)

;;======================================================================
;; KEY FUNCTIONS - THESE ARE TOO BE EXPOSED AND USED
;;======================================================================

;; connection setup and management functions

410
411
412
413
414
415
416
417
418
419
420
421


422
423

424
425
426
427
428
429


430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
(define (send-ack udata host-port qrykey) ;;  #!optional (hostname #f)(pid #f))
  (send udata host-port "ack" qrykey qrykey)) ;; we must send a second line - for the ack let it be the qrykey 
  
;; 
;;
(define (ulex-handler udata)
  (let* ((serv-listener (udat-serv-listener udata)))
    (let-values (((inp oup)(tcp-accept serv-listener)))
      ;; data comes as two lines
      ;;   handlerkey resp-addr:resp-port hostname pid qrykey [dbpath/dbfile.db]
      ;;   data
      (let loop ((state 'start))


	(let* ((controldat (read-line inp))
	       (data       (read-line inp)))

	  (match (string-split controldat)
	    ((handlerkey host:port pid qrykey params ...)
	     (print "handlerkey: " handlerkey " host:port: " host:port " pid: " pid " qrykey: " qrykey " params: " params)
	     (case (string->symbol handlerkey)
	       ((ack)(print "Got ack!"))
	       ((ping)


		(let* ((proc (hash-table-ref/default (udat-handlers udata) 'ping #f))
		       (val  (if proc (proc) "gotping")))
		  (send udata host:port "version" qrykey val)))
	       ((rucaptain)
		(send udata host:port "iamcaptain" qrykey (if (udat-my-cpkt-key udata)
							      "yes"
							      "no")))
	       (else
		;; (send-ack udata host:port qrykey)
		(add-to-work-queue udata (get-peer-dat udata host:port) handlerkey qrykey data))))
	    (else (print "BAD DATA? controldat=" controldat " data=" data))))
	(loop state)))))

;; add a proc to the handler list
(define (register-handler udata key proc)
  (hash-table-set! (udat-handlers udata) key proc))


;;======================================================================







|
|
|
|
|
>
>


>

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







411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
(define (send-ack udata host-port qrykey) ;;  #!optional (hostname #f)(pid #f))
  (send udata host-port "ack" qrykey qrykey)) ;; we must send a second line - for the ack let it be the qrykey 
  
;; 
;;
(define (ulex-handler udata)
  (let* ((serv-listener (udat-serv-listener udata)))
    (print "serv-listner: " serv-listener)
    ;; data comes as two lines
    ;;   handlerkey resp-addr:resp-port hostname pid qrykey [dbpath/dbfile.db]
    ;;   data
    (let loop ((state 'start))
      (let-values (((inp oup)(tcp-accept serv-listener)))
	(print "got here: inp=" inp " oup=" oup)
	(let* ((controldat (read-line inp))
	       (data       (read-line inp)))
	  (print "controldat: " controldat " data: " data)
	  (match (string-split controldat)
		 ((handlerkey host:port pid qrykey params ...)
		  (print "handlerkey: " handlerkey " host:port: " host:port " pid: " pid " qrykey: " qrykey " params: " params)
		  (case (string->symbol handlerkey)
		    ((ack)(print "Got ack!"))
		    ((ping) 
		     (close-input-port inp) ;;; these don't work
		     (close-output-port oup)
		     (let* ((proc (hash-table-ref/default (udat-handlers udata) 'ping #f))
			    (val  (if proc (proc) "gotping")))
		       (send udata host:port "version" qrykey val)))
		    ((rucaptain)
		     (send udata host:port "iamcaptain" qrykey (if (udat-my-cpkt-key udata)
								   "yes"
								   "no")))
		    (else
		     ;; (send-ack udata host:port qrykey)
		     (add-to-work-queue udata (get-peer-dat udata host:port) handlerkey qrykey data))))
		 (else (print "BAD DATA? controldat=" controldat " data=" data)))))
	(loop state))))

;; add a proc to the handler list
(define (register-handler udata key proc)
  (hash-table-set! (udat-handlers udata) key proc))


;;======================================================================