Overview
Comment: | Switched back to tcp6 |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | v2.0001-ulex-one-shot |
Files: | files | file ages | folders |
SHA1: |
1b8dcc586bd6bbddb8dd55e075ed29c2 |
User & Date: | matt on 2022-01-12 17:49:05 |
Other Links: | branch diff | manifest | tags |
Context
2022-01-13
| ||
06:18 | wip check-in: fb2aca7823 user: matt tags: v2.0001-ulex-one-shot | |
2022-01-12
| ||
17:49 | Switched back to tcp6 check-in: 1b8dcc586b user: matt tags: v2.0001-ulex-one-shot | |
16:52 | Sync up with v2.0001 check-in: d7b4fe7a7f user: matt tags: v2.0001-ulex-one-shot | |
Changes
Modified ulex-simple/ulex.scm from [eb641ce140] to [3a037ef6f7].
︙ | ︙ | |||
59 60 61 62 63 64 65 | chicken.base chicken.file chicken.time chicken.condition chicken.string chicken.sort chicken.pretty-print | | | | | 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | chicken.base chicken.file chicken.time chicken.condition chicken.string chicken.sort chicken.pretty-print ;; chicken.tcp address-info mailbox matchable ;; queues regex regex-case s11n srfi-1 srfi-18 srfi-4 srfi-69 system-information tcp6 typed-records ;; tcp-server ) ;; udat struct, used by both caller and callee ;; instantiated as uconn by convention ;; (defstruct udat |
︙ | ︙ | |||
99 100 101 102 103 104 105 106 107 108 109 110 111 112 | (cnum 0) ;; cookie number (mboxes (make-hash-table)) ;; for the replies (avail-cmboxes '()) ;; list of (<cookie> . <mbox>) for re-use ;; threads (numthreads 50) (cmd-thread #f) (work-queue-thread #f) ) ;; ;; struct for keeping track of others we are talking to ;; ;; ;; (defstruct pdat ;; (host-port #f) ;; (conns '()) ;; list of pcon structs, pop one off when calling the peer | > | 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | (cnum 0) ;; cookie number (mboxes (make-hash-table)) ;; for the replies (avail-cmboxes '()) ;; list of (<cookie> . <mbox>) for re-use ;; threads (numthreads 50) (cmd-thread #f) (work-queue-thread #f) (num-threads-running 0) ) ;; ;; struct for keeping track of others we are talking to ;; ;; ;; (defstruct pdat ;; (host-port #f) ;; (conns '()) ;; list of pcon structs, pop one off when calling the peer |
︙ | ︙ | |||
201 202 203 204 205 206 207 | ;; 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)) (port (string->number (cadr parts)))) (if isme (ulex-handler udata dat) ;; no transmission needed | < < < | | | | | | | | | | | | | < < < < < < < < < < | < < < < < < < < < | < > > > > > > > > > > > > > > > | > | < | | < < | < | < > | > > | > > > > > > | 202 203 204 205 206 207 208 209 210 211 212 213 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 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | ;; 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)) (port (string->number (cadr parts)))) (if isme (ulex-handler udata dat) ;; no transmission needed (let-values (((inp oup)(tcp-connect host port))) (let ((res (if (and inp oup) (begin (serialize dat oup) (deserialize inp)) ;; yes, we always want an ack (begin (print "ERROR: send called but no receiver has been setup. Please call setup first!") #f)))) (close-input-port inp) (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 ;; ;; Reserved cmds; ack ping goodbye response ;; (define (ulex-handler uconn rdat) (assert (list? rdat) "FATAL: ulex-handler give rdat as not list") (match rdat ((rem-host-port qrykey cmd params) (do-work uconn rdat)) (else (print "BAD DATA? controldat=" rdat) 'bad-data) )) ;; given an already set up uconn start the cmd-loop ;; #;(define (ulex-cmd-loop uconn) (let* ((serv-listener (udat-socket uconn)) (server (make-tcp-server serv-listener (lambda () (let* ((rdat (deserialize)) ;; '(my-host-port qrykey cmd params) (resp (ulex-handler uconn rdat))) (if resp (serialize resp) (write resp))))))) (server))) ;; given an already set up uconn start the cmd-loop ;; (define (ulex-cmd-loop uconn) (let* ((serv-listener (udat-socket uconn)) (listener (lambda () (let loop ((state 'start)) (let-values (((inp oup)(tcp-accept serv-listener))) (let* ((rdat (deserialize inp)) ;; '(my-host-port qrykey cmd params) (resp (ulex-handler uconn rdat))) (serialize resp oup) (close-input-port inp) (close-output-port oup)) (loop state)))))) ;; start N of them (let loop ((thnum 0) (threads '())) (if (< thnum 100) (let* ((th (make-thread listener (conc "listener" thnum)))) (thread-start! th) (loop (+ thnum 1) (cons th threads))) (map thread-join! threads))))) ;; add a proc to the cmd list, these are done symetrically (i.e. in all instances) ;; so that the proc can be dereferenced remotely ;; (define (set-work-handler uconn proc) (udat-work-proc-set! uconn proc)) |
︙ | ︙ | |||
307 308 309 310 311 312 313 | (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)))) | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | (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 ;;====================================================================== (define (make-cookie uconn) (let ((newcnum (+ (udat-cnum uconn) 1))) (udat-cnum-set! uconn newcnum) |
︙ | ︙ |
Modified ulex.scm from [f004a2cedd] to [64369b6c76].
︙ | ︙ | |||
16 17 18 19 20 21 22 | ;; You should have received a copy of the GNU General Public License ;; along with Megatest. If not, see <http://www.gnu.org/licenses/>. ;;====================================================================== (declare (unit ulex)) | | | | 16 17 18 19 20 21 22 23 24 | ;; You should have received a copy of the GNU General Public License ;; along with Megatest. If not, see <http://www.gnu.org/licenses/>. ;;====================================================================== (declare (unit ulex)) ;; (include "ulex/ulex.scm") (include "ulex-simple/ulex.scm") |