Index: rmtmod.scm ================================================================== --- rmtmod.scm +++ rmtmod.scm @@ -81,11 +81,10 @@ typed-records uri-common z3 apimod - clientmod commonmod configfmod dbmod debugprint itemsmod @@ -218,13 +217,13 @@ ))) (if the-srv ;; yes, we have a server, now try connecting to it (let* ((srv-addr (server-address the-srv)) (ipaddr (alist-ref 'ipaddr the-srv)) (port (alist-ref 'port the-srv)) - (srv-key (alist-ref 'srvkey the-srv)) + (srvkey (alist-ref 'Z the-srv)) (fullpath (db:dbname->path apath dbname)) - (srvready (server-ready? ipaddr port fullpath))) + (srvready (server-ready? ipaddr port srvkey))) (if srvready (begin (hash-table-set! (rmt:remote-conns remote) dbname ;; fullpath ;; yes, I'd prefer it to be fullpath - FIXME later (make-rmt:conn @@ -233,11 +232,11 @@ fullname: fullpath hostport: srv-addr ipaddr: ipaddr port: port srvpkt: the-srv - srvkey: srv-key ;; not the same as signature + srvkey: srvkey ;; not the same as signature? lastmsg: (current-seconds) expires: (+ (current-seconds) 60) ;; this needs to be gathered during the ping )) #t) (start-main-srv))) @@ -1519,11 +1518,11 @@ ;; ;; NOTE: This is NOT called directly from clients as not all transports support a client running ;; in the same process as the server. ;; (define (server:ping host port server-id #!key (do-exit #f)) - (server-ready? host port "nokey yet")) + (server-ready? host port server-id)) ;;====================================================================== ;; http-transportmod.scm contents moved here ;;====================================================================== @@ -1800,11 +1799,11 @@ (begin (write `((cmd . ping) (key . ,key) (params . ())) o) (let ((res (with-input-from-port i - read))) + read-string))) (close-output-port o) (close-input-port i) (if (string? res) (string->sexpr res) res))) @@ -1849,12 +1848,13 @@ #f (let* ((spkt (car tail)) (host (alist-ref 'ipaddr spkt)) (port (alist-ref 'port spkt)) (dbpth (alist-ref 'dbpath spkt)) + (srvkey (alist-ref 'Z spkt)) ;; (alist-ref 'srvkey spkt)) (addr (server-address spkt))) - (if (server-ready? host port (conc apath"/"dbpth)) + (if (server-ready? host port srvkey) spkt (loop (cdr tail))))))) ;; am I the "first" in line server? I.e. my D card is smallest ;; use Z card as tie breaker @@ -1920,11 +1920,11 @@ (register-server pkts-dir *srvpktspec* (get-host-name) (servdat-port sdat) server-key (servdat-host sdat) db-file)) - + (set! *my-signature* (servdat-uuid sdat)) ;; replace with Z ;; now read pkts and see if we are a contender (let* ((all-pkts (get-all-server-pkts pkts-dir *srvpktspec*)) (viables (get-viable-servers all-pkts db-file)) (best-srv (get-best-candidate viables db-file)) (best-srv-key (if best-srv (alist-ref 'servkey best-srv) #f))) Index: tests/unittests/basicserver.scm ================================================================== --- tests/unittests/basicserver.scm +++ tests/unittests/basicserver.scm @@ -71,10 +71,11 @@ (define apath *toppath*) (define dbname ".db/2.db") (define remote *rmt:remote*) (define keyvals '(("SYSTEM" "a")("RELEASE" "b"))) +(test #f '() (string->sexpr "()")) (test #f 'server-started (api:execute-requests *db* 'get-server (list *toppath* ".db/2.db"))) (set! *dbstruct-db* #f) (exit)