Index: db.scm ================================================================== --- db.scm +++ db.scm @@ -39,11 +39,11 @@ (import commonmod (prefix mtargs args:)) (use (srfi 18) extras - tcp + ;; tcp stack (prefix sqlite3 sqlite3:) srfi-1 posix regex Index: megatest.scm ================================================================== --- megatest.scm +++ megatest.scm @@ -83,13 +83,13 @@ (include "key_records.scm") (include "db_records.scm") (include "run_records.scm") (include "megatest-fossil-hash.scm") -(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 tcp-server tcp) +(use (prefix sqlite3 sqlite3:) srfi-1 posix regex regex-case srfi-69 (prefix base64 base64:)) +(use readline apropos json http-client directory-utils typed-records) +(use http-client srfi-18 extras format tcp-server tcp) ;; Added for csv stuff - will be removed ;; (use sparse-vectors) Index: portlogger.scm ================================================================== --- portlogger.scm +++ portlogger.scm @@ -25,11 +25,11 @@ (module portlogger * (import scheme chicken data-structures) (import srfi-1 posix srfi-69 hostinfo dot-locking z3 - (srfi 18) extras tcp s11n) + (srfi 18) extras s11n) (import (prefix sqlite3 sqlite3:)) (import debugprint dbmod) ;; lsof -i (define (portlogger:open-db fname) Index: server.scm ================================================================== --- server.scm +++ server.scm @@ -27,15 +27,13 @@ ;;(declare (uses rpc-transport)) (declare (uses launch)) ;; (declare (uses daemon)) (declare (uses mtargs)) -(require-extension (srfi 18) extras tcp s11n) - -(use srfi-1 posix regex regex-case srfi-69 hostinfo md5 message-digest - directory-utils posix-extras matchable utils) - +(use (srfi 18) extras s11n) +(use srfi-1 posix regex regex-case srfi-69 hostinfo md5 message-digest) +(use directory-utils posix-extras matchable utils) (use spiffy uri-common intarweb http-client spiffy-request-vars) (import commonmod debugprint (prefix mtargs args:)) Index: tcp-transportmod.scm ================================================================== --- tcp-transportmod.scm +++ tcp-transportmod.scm @@ -23,11 +23,11 @@ (declare (uses commonmod)) (declare (uses dbfile)) (declare (uses dbmod)) (declare (uses portlogger)) -(use address-info) +(use address-info tcp) (module tcp-transportmod * (import scheme @@ -182,11 +182,11 @@ (tt-last-serv-start-set! ttdat (current-seconds)))) (thread-sleep! 1) (tt:client-connect-to-server ttdat dbfname run-id testsuite))))))) (define (tt:ping host port server-id #!optional (tries-left 5)) - (let* ((res (tt:send-receive-direct host port `(ping #f #f #f))) ;; please send me your server-id + (let* ((res (tt:send-receive-direct host port `(ping #f #f #f) ping-mode: #t)) ;; please send me your server-id (try-again (lambda () (if (> tries-left 0) (begin (thread-sleep! 1) (tt:ping host port server-id (- tries-left 1))) @@ -323,25 +323,48 @@ (host (tt-conn-host conn)) (port (tt-conn-port conn)) (dat (list cmd run-id params #f))) ;; no meta data yet (tt:send-receive-direct host port dat))) -(define (tt:send-receive-direct host port dat) +(define (tt:send-receive-direct host port dat #!key (ping-mode #f)(tries-remaining 25)) (assert (number? port) "FATAL: tt:send-receive-direct called with port not a number "port) - (handle-exceptions - exn - #f ;; Add condition-case or better handling here - (let-values (((inp oup)(tcp-connect host port))) - (let ((res (if (and inp oup) - (begin - (serialize dat oup) - (close-output-port oup) - (deserialize inp)) - ))) - (close-input-port inp) - res)))) - + (let* ((retry (lambda () + (tt:send-receive-direct host port dat tries-remaining: (- tries-remaining 1)))) + (full-err-print (lambda (exn) + (pp (condition->list exn) *default-log-port*) + (pp dat *default-log-port*) + (debug:print 0 *default-log-port* + ", error: " ((condition-property-accessor 'exn 'message) exn) + ", arguments: " ((condition-property-accessor 'exn 'arguments) exn) + ", location: " ((condition-property-accessor 'exn 'location) exn) + )))) + (condition-case + (let-values (((inp oup)(tcp-connect host port))) + (let ((res (if (and inp oup) + (begin + (serialize dat oup) + (close-output-port oup) + (deserialize inp)) + ))) + (close-input-port inp) + res)) + (exn (io-error) + (full-err-print exn) + (debug:print 0 *default-log-port* exn "ERROR: i/o error") + #f) + (exn (i/o net) + (if ping-mode + #f + (if (>= tries-remaining 0) + (let* ((backoff-delay (* (- 26 tries-remaining) 0.5))) + (debug:print 0 *default-log-port* "WARNING: TCP overload, trying again in "backoff-delay"s.") + (thread-sleep! backoff-delay) + (retry)) + (assert #f "FATAL: Too many retries in tt:send-receive-direct")))) + (exn () + (full-err-print exn) + #f)))) ;;====================================================================== ;; server ;;====================================================================== @@ -701,11 +724,11 @@ (connect-listener uconn port)))) (define (connect-listener uconn port) ;; (tcp-listener-socket LISTENER)(socket-name so) ;; sockaddr-address, sockaddr-port, sockaddr->string - (let* ((tlsn (tcp-listen port 1000 #f)) ;; (tcp-listen TCPPORT [BACKLOG [HOST]]) + (let* ((tlsn (tcp-listen port 10000 #f)) ;; (tcp-listen TCPPORT [BACKLOG [HOST]]) (addr (tt:get-best-guess-address (get-host-name)))) ;; (get-my-best-address))) ;; (hostinfo-addresses (host-information (current-hostname))) (tt-port-set! uconn port) (tt-host-set! uconn addr) (tt-host-port-set! uconn (conc addr":"port)) (tt-socket-set! uconn tlsn) Index: tests.scm ================================================================== --- tests.scm +++ tests.scm @@ -32,16 +32,13 @@ (declare (uses runconfig)) (declare (uses server)) (declare (uses mtargs)) (declare (uses rmtmod)) -(use sqlite3 srfi-1 posix regex regex-case srfi-69 dot-locking tcp directory-utils) +(use sqlite3 srfi-1 posix regex regex-case srfi-69 dot-locking directory-utils) (import (prefix sqlite3 sqlite3:)) -(import commonmod - (prefix mtargs args:) - debugprint - rmtmod) +(import commonmod (prefix mtargs args:) debugprint rmtmod) (require-library stml) (include "common_records.scm") (include "key_records.scm") (include "db_records.scm")