Megatest

Check-in [124ed3f5a6]
Login
Overview
Comment:Switch from write-line and read-line to write and read for transport across the tcp connection
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: 124ed3f5a650700b813c000acffb3b269bca19aa
User & Date: matt on 2020-01-21 19:19:21
Other Links: branch diff | manifest | tags
Context
2020-01-22
22:33
wip-cleaning-up-send-receive check-in: 1dbae7035b user: matt tags: v1.70-captain-ulex, v1.70-defunct-try
2020-01-21
19:19
Switch from write-line and read-line to write and read for transport across the tcp connection check-in: 124ed3f5a6 user: matt tags: v1.70-captain-ulex, v1.70-defunct-try
2020-01-20
22:34
Scaffolding for send-receive check-in: 3f613cadf2 user: matt tags: v1.70-captain-ulex, v1.70-defunct-try
Changes

Modified apimod.scm from [e352dd959a] to [b9423f8dfd].

291
292
293
294
295
296
297
298

291
292
293
294
295
296
297

298







-
+
    ;;          (number? res)
    ;;          (boolean? res))
    ;;      res 
    ;;      (list "ERROR, not string, list, number or boolean" 1 cmd params res)))))
    (db:obj->string res transport: 'http)))


)
) 

Modified rmtmod.scm from [3b1ae2dfc7] to [1d07182ee0].

103
104
105
106
107
108
109

110
111

112

113
114

115
116
117
118
119
120
121
103
104
105
106
107
108
109
110
111
112
113

114
115

116
117
118
119
120
121
122
123







+


+
-
+

-
+







		       'main 'runs))
	 (dbfname  (if (eq? dbtype 'main)
		       "main.db"
		       (conc rid ".db")))
	 (dbfile   (conc areapath "/.db/" dbfname))
	 (udata    (alldat-ulexdat alldat))
	 (ulexconn (rmt:connect alldat dbfname dbtype)))  ;; ulexconn is our new *runremote*, it is a dbowner struct < pdat lastrefresh >
    	(ulex:remote-request udata ulexconn 'immediate dbfile 'execute rid params)))
    ;; need to call this on the other side 
    ;; (api:execute-requests dbstruct-local (vector (symbol->string cmd) params))))
    
    (with-input-from-string
    #;(with-input-from-string
	(ulex:remote-request udata ulexconn 'immediate dbfile 'execute rid (with-output-to-string (lambda ()(serialize params))))
       (lambda ()(deserialize)))))
       (lambda ()(deserialize)))

#;(rmt:open-qry-close-locally cmd 0 params)

;;   
;; ;; #;(common:telemetry-log (conc "rmt:"(->string cmd))
;; ;; #;(define (rmt:send-receive cmd rid params #!key (attemptnum 1)(area-dat #f)) ;; start attemptnum at 1 so the modulo below works as expected
;; ;; 

Modified ulex/ulex.scm from [210fc6977d] to [f8b8e960d6].

485
486
487
488
489
490
491
492
493


494
495
496

497
498
499
500
501
502
503
485
486
487
488
489
490
491


492
493
494
495

496
497
498
499
500
501
502
503







-
-
+
+


-
+







	    ;;    handlerkey host:port pid qrykey params ...
	    ;;
	    (let ((res
		   (if (and inp oup)
		       (let* ()
			 (if my-host-port
			     (begin
			       (write-line dat  oup)
			       (write-line data oup)
			       (write dat  oup)
			       (write data oup) ;; send as sexpr
			       ;; (print "Sent dat: " dat " data: " data)
			       (if retval
				   (read-line inp)
				   (read inp)
				   #t))
			     (begin
			       (print "ERROR: send called but no receiver has been setup. Please call setup first!")
			       #f))
			 ;; NOTE: DO NOT BE TEMPTED TO LOOK AT ANY DATA ON INP HERE!
			 ;;       (there is a listener for handling that)
			 )
604
605
606
607
608
609
610
611
612


613
614

615
616
617
618
619
620
621
604
605
606
607
608
609
610


611
612
613

614
615
616
617
618
619
620
621







-
-
+
+

-
+







(define (ulex-handler-loop udata)
  (let* ((serv-listener (udat-serv-listener udata)))
    ;; 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)))
	(let* ((controldat (read-line inp))
	       (data       (read-line inp))
	(let* ((controldat (read inp))
	       (data       (read inp))
	       (resp       (ulex-handler udata controldat data)))
	  (if resp (write-line resp oup))
	  (if resp (write resp oup))
	  (close-input-port inp)
	  (close-output-port oup))
	(loop state)))))

;; add a proc to the handler list, these are done symetrically (i.e. in all instances)
;; so that the proc can be dereferenced remotely
;;