Index: api.scm ================================================================== --- api.scm +++ api.scm @@ -378,22 +378,23 @@ ;; db:* ;; ;; NB// Runs on the server as part of the server loop ;; (define (api:process-request dbstruct $) ;; the $ is the request vars proc - (set! *api-process-request-count* (+ *api-process-request-count* 1)) (debug:print 4 *default-log-port* "server-id:" *server-id*) (let* ((cmd ($ 'cmd)) (paramsj ($ 'params)) (key ($ 'key)) (params (db:string->obj paramsj transport: 'http))) ;; incoming data from the POST (or is it a GET?) - (debug:print 4 *default-log-port* "cmd:" cmd " with params " params "key " key) + (debug:print 0 *default-log-port* "cmd:" cmd " with params " params "key " key) (if (equal? key *server-id*) - (let* ((resdat (api:execute-requests dbstruct (vector cmd params))) ;; process the request, resdat = #( flag result ) + (begin + (set! *api-process-request-count* (+ *api-process-request-count* 1)) + (let* ((resdat (api:execute-requests dbstruct (vector cmd params))) ;; process the request, resdat = #( flag result ) (success (vector-ref resdat 0)) (res (vector-ref resdat 1))) ;; (vector flag payload), get the payload, ignore the flag (why?) - (debug:print 4 *default-log-port* "res:" res) + (debug:print 0 *default-log-port* "res:" res) (if (not success) (debug:print 0 *default-log-port* "ERROR: success flag is #f for " cmd " with params " params)) (if (> *api-process-request-count* *max-api-process-requests*) (set! *max-api-process-requests* *api-process-request-count*)) (set! *api-process-request-count* (- *api-process-request-count* 1)) @@ -403,10 +404,10 @@ ;; (list? res) ;; (number? res) ;; (boolean? res)) ;; res ;; (list "ERROR, not string, list, number or boolean" 1 cmd params res))))) - (db:obj->string res transport: 'http)) + (db:obj->string res transport: 'http))) (begin (debug:print 0 *default-log-port* "Server refused to process request. Sever id mismatch. recived " key " expected: " *server-id* ".\nOther arguments recived: cmd=" cmd " params = " params) (db:obj->string (conc "Server refused to process request server-id mismatch: " key ", " *server-id*) transport: 'http))))) Index: common.scm ================================================================== --- common.scm +++ common.scm @@ -298,11 +298,11 @@ (defstruct remote (hh-dat (common:get-homehost)) ;; homehost record ( addr . hhflag ) (server-url #f) ;; (server:check-if-running *toppath*) #f)) (server-id #f) - (server-info (if *toppath* (server:check-if-running *toppath*))) + (server-info (if *toppath* (server:check-if-running *toppath*) #f)) (last-server-check 0) ;; last time we checked to see if the server was alive (conndat #f) (transport *transport-type*) (server-timeout (server:expiration-timeout)) (force-server #f) Index: http-transport.scm ================================================================== --- http-transport.scm +++ http-transport.scm @@ -292,11 +292,11 @@ ;;; (make-property-condition 'commfail 'message "failed to connect to server"))) ;;; "communications failed" (db:obj->string #f)) (with-input-from-request ;; was dat fullurl - (list (cons 'key (or server-id "thekey")) + (list (cons 'key (or server-id "thekey")) (cons 'cmd cmd) (cons 'params sparams)) read-string)) transport: 'http) 0)) ;; added this speculatively @@ -314,12 +314,18 @@ (thread-start! th2) (thread-join! th1) (vector-set! res 0 success) (thread-terminate! th2) (if (vector? res) - (if (vector-ref res 0) ;; this is the first flag or the second flag? - res ;; this is the *inner* vector? seriously? why? + (if (vector-ref res 0) ;; this is the first flag or the second flag? + (let* ((res-dat (vector-ref res 1))) + (if (and (string? res-dat) (string-contains res-dat "server-id mismatch")) + (signal (make-composite-condition + (make-property-condition + 'servermismatch + 'message (vector-ref res 1)))) + res)) ;; this is the *inner* vector? seriously? why? (if (debug:debug-mode 11) (let ((call-chain (get-call-chain))) ;; note: this code also called in nmsg-transport - consider consolidating it (print-call-chain (current-error-port)) (debug:print-error 11 *default-log-port* "error above occured at server, res=" res) ;; " message: " ((condition-property-accessor 'exn 'message) exn)) (debug:print 11 *default-log-port* " server call chain:") Index: rmt.scm ================================================================== --- rmt.scm +++ rmt.scm @@ -275,10 +275,11 @@ ;; attemtped ;; communication to ;; servers that have gone ;; away (http-transport:client-api-send-receive 0 conninfo cmd params) + ((servermismatch) (vector #f "Server id mismatch" )) ((commfail)(vector #f "communications fail")) ((exn)(vector #f "other fail" (print-call-chain))))) (else (debug:print 0 *default-log-port* "ERROR: transport " (remote-transport runremote) " not supported") (exit)))) @@ -322,11 +323,13 @@ (mutex-unlock! *rmt-mutex*) (if success ;; success only tells us that the transport was ;; successful, have to examine the data to see if ;; there was a detected issue at the other end (extras-transport-succeded *default-log-port* *rmt-mutex* attemptnum runremote res params rid cmd) - (extras-transport-failed *default-log-port* *rmt-mutex* attemptnum runremote cmd rid params) + (begin + (debug:print-error 0 *default-log-port* " dat=" dat) + (extras-transport-failed *default-log-port* *rmt-mutex* attemptnum runremote cmd rid params)) ))) (define (rmt:print-db-stats) (let ((fmtstr "~40a~7-d~9-d~20,2-f")) ;; "~20,2-f" (debug:print 18 *default-log-port* "DB Stats\n========") Index: server.scm ================================================================== --- server.scm +++ server.scm @@ -320,11 +320,11 @@ (define (server:record->id servr) (handle-exceptions exn (begin - (debug:print-info 0 *default-log-port* "failed to get server id from " server ", exn=" exn) + (debug:print-info 0 *default-log-port* "failed to get server id from " servr ", exn=" exn) #f) (match-let (((mod-time host port start-time server-id pid) servr)) (if server-id server-id @@ -332,11 +332,11 @@ (define (server:record->url servr) (handle-exceptions exn (begin - (debug:print-info 0 *default-log-port* "failed to get server url from " server ", exn=" exn) + (debug:print-info 0 *default-log-port* "failed to get server url from " servr ", exn=" exn) #f) (match-let (((mod-time host port start-time server-id pid) servr)) (if (and host port) (conc host ":" port) @@ -462,11 +462,11 @@ (define (server:kill servr) (handle-exceptions exn (begin - (debug:print-info 0 *default-log-port* "failed to get host and/or port from " server ", exn=" exn) + (debug:print-info 0 *default-log-port* "failed to get host and/or port from " servr ", exn=" exn) #f) (match-let (((mod-time hostname port start-time pid) servr)) (tasks:kill-server hostname pid))))