Index: apimod.scm ================================================================== --- apimod.scm +++ apimod.scm @@ -405,36 +405,27 @@ ;; ;; NB// Runs on the server as part of the server loop ;; (define (api:process-request dbstruct $) ;; the $ is the request vars proc (debug:print 0 *default-log-port* "server-id:" *server-id*) - (let* ((cmd ($ 'cmd)) + (let* ((cmd-in ($ 'cmd)) + (cmd (if (string? cmd-in)(string->symbol cmd-in) cmd-in)) (params (string->sexpr ($ 'params))) (key ($ 'key)) ;; TODO - add this back ) (debug:print 0 *default-log-port* "cmd:" cmd " with params " params "key " key) (if (equal? key "nokey") ;; *server-id*) ;; TODO - get real key involved (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) - (if (not success) + (let* ((res (api:execute-requests dbstruct cmd params))) + (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)) - ;; This can be here but needs controls to ensure it doesn't run more than every 4 seconds - ;; (rmt:dat->json-str - ;; (if (or (string? res) - ;; (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))) + (sexpr->string res))) (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))))) + (sexpr->string (conc "Server refused to process request server-id mismatch: " key ", " *server-id*)))))) ) Index: fullrununit.sh ================================================================== --- fullrununit.sh +++ fullrununit.sh @@ -1,6 +1,6 @@ #!/bin/bash (killall mtest -v;sleep 1;killall mtest -v -9;rm tests/simplerun/logs/*;rm tests/basicserver.log) & -ck5 make install -wait +ck5 make install && +wait && ck5 make unit Index: rmtmod.scm ================================================================== --- rmtmod.scm +++ rmtmod.scm @@ -246,11 +246,11 @@ (begin (rmt:open-main-connection remote apath) (thread-sleep! 1) (rmt:general-open-connection remote apath dbname)) ;; we have a connection to main, ask for contact info for dbname - (let* ((res (rmt:send-receive mainconn "querykeyhere" 'get-server `(,apath ,dbname)))) + (let* ((res (rmt:send-receive 'get-server #f `(,apath ,dbname)))) (print "rmt:general-open-connection got res="res) res)))) ;;====================================================================== Index: tests/unittests/basicserver.scm ================================================================== --- tests/unittests/basicserver.scm +++ tests/unittests/basicserver.scm @@ -25,12 +25,12 @@ (import rmtmod trace http-transportmod http-client apimod dbmod) (trace-call-sites #t) (trace ;; db:get-dbdat ;; rmt:find-main-server - rmt:send-receive-real - sexpr->string + ;; rmt:send-receive-real + ;; sexpr->string ) (test #f #t (rmt:remote? (let ((r (make-rmt:remote))) (set! *rmt:remote* r) r))) @@ -45,21 +45,21 @@ (for-each (lambda (tdat) (test #f tdat (loop-test (rmt:conn-ipaddr *main*) (rmt:conn-port *main*) tdat))) (list 'a '(a "b" 123 1.23 ))) -(test #f #f (rmt:send-receive 'ping #f 'hello)) +(test #f #t (number? (rmt:send-receive 'ping #f 'hello))) (trace - rmt:send-receive - with-input-from-request - rmt:get-connection - with-input-from-request + ;; rmt:send-receive + ;; with-input-from-request + ;; rmt:get-connection + ;; with-input-from-request ) (define *db* (db:setup #f)) (test #f 'server-started (api:execute-requests *db* 'get-server (list *toppath* ".db/1.db"))) -(test #f #f (rmt:general-open-connection *rmt:remote* *toppath* ".db/1.db")) +(test #f 'server-started (rmt:general-open-connection *rmt:remote* *toppath* ".db/1.db")) ;; (delete-file* "logs/1.log") ;; (define run-id 1) ;; (test "setup for run" #t (begin (launch:setup)