Overview
Comment: | Adjusted receive for new usage (was copied from mtut.scm |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | v1.6584-nanomsg |
Files: | files | file ages | folders |
SHA1: |
f70db69e667c557be054cf9779a857be |
User & Date: | matt on 2021-06-07 08:59:59 |
Other Links: | branch diff | manifest | tags |
Context
2021-06-09
| ||
09:02 | wip check-in: 29dd9489e5 user: matt tags: v1.6584-nanomsg | |
2021-06-07
| ||
08:59 | Adjusted receive for new usage (was copied from mtut.scm check-in: f70db69e66 user: matt tags: v1.6584-nanomsg | |
08:46 | wip. check-in: 96feeca725 user: matt tags: v1.6584-nanomsg | |
Changes
Modified rmtmod.scm from [7f26d483f5] to [cd84ed1c84].
︙ | ︙ | |||
1543 1544 1545 1546 1547 1548 1549 | #f (conc "http://" (car hostport) ":" (cadr hostport)))) ;;====================================================================== ;; S E R V E R ;; ====================================================================== | < < < < < < < < < < < < < < < < < < < < < < < < < | 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 | #f (conc "http://" (car hostport) ":" (cadr hostport)))) ;;====================================================================== ;; S E R V E R ;; ====================================================================== (define (http-get-function fnkey) (hash-table-ref/default *http-functions* fnkey (lambda () "nothing here yet"))) (define (rmt:run hostn) ;; ;; Configurations for server ;; (tcp-buffer-size 2048) ;; (max-connections 2048) (debug:print 2 *default-log-port* "Attempting to start the server ...") (let* ((db #f) ;; (open-db)) ;; we don't want the server to be opening and closing the db unnecesarily (hostname (get-host-name)) |
︙ | ︙ | |||
1603 1604 1605 1606 1607 1608 1609 | (let loop ((instr (nn-recv rep))) (let* ((data (string->sexpr instr)) (res (api:process-request *dbstruct-db* data)) (resdat (sexpr->string res))) (set! *db-last-access* (current-seconds)) (nn-send rep resdat) (loop (nn-recv rep))))) | < < < < < < < < < < < < < < < | 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 | (let loop ((instr (nn-recv rep))) (let* ((data (string->sexpr instr)) (res (api:process-request *dbstruct-db* data)) (resdat (sexpr->string res))) (set! *db-last-access* (current-seconds)) (nn-send rep resdat) (loop (nn-recv rep))))) (let* ((portnum (servdat-port *server-info*))) (portlogger:open-run-close portlogger:set-port portnum "released") (debug:print 1 *default-log-port* "INFO: server has been stopped")))) (define (rmt:try-start-server ipaddrstr portnum) (if *server-info* ;; update the server info as we might be trying next port (begin (servdat-host-set! *server-info* ipaddrstr) (servdat-port-set! *server-info* portnum) (servdat-status-set! *server-info* 'trying-port) (servdat-trynum-set! *server-info* (+ (servdat-trynum *server-info*) 1))) (set! *server-info* (make-servdat host: ipaddrstr port: portnum))) (debug:print-info 0 *default-log-port* "rmt:try-start-server time=" (seconds->time-string (current-seconds)) " ipaddrsstr=" ipaddrstr " portnum=" portnum) (if (is-port-in-use portnum) (begin (portlogger:open-run-close portlogger:set-failed portnum) (debug:print 0 *default-log-port* "WARNING: failed to start on portnum: " portnum ", trying next port") ;; (thread-sleep! 0.1) (rmt:try-start-server ipaddrstr (portlogger:open-run-close |
︙ | ︙ | |||
2312 2313 2314 2315 2316 2317 2318 | ;; (print "Request Sent") ;; receive code here ;;(print (nn-recv req)) (let* ((th1 (make-thread (lambda () (let ((resp (nn-recv req))) (nn-close req) (print resp) | | < < | 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 | ;; (print "Request Sent") ;; receive code here ;;(print (nn-recv req)) (let* ((th1 (make-thread (lambda () (let ((resp (nn-recv req))) (nn-close req) (print resp) (set! res resp))) "recv thread")) (th2 (make-thread (lambda () (thread-sleep! timeout) (thread-terminate! th1)) "timer thread"))) (thread-start! th1) (thread-start! th2) |
︙ | ︙ |