@@ -16,10 +16,11 @@ (declare (unit server)) (declare (uses common)) (declare (uses db)) +(declare (uses tests)) (include "common_records.scm") (include "db_records.scm") ;; procstr is the name of the procedure to be called as a string @@ -185,10 +186,15 @@ (rpc:publish-procedure! 'rdb:delete-test-records (lambda (test-id) (db:delete-test-records db test-id))) + (rpc:publish-procedure! + 'rtests:register-test + (lambda (run-id test-name item-path) + (tests:register-test db run-id test-name item-path))) + (set! *rpc:listener* rpc:listener) (on-exit (lambda () (sqlite3:execute db "DELETE FROM metadat WHERE var='SERVER' and val=?;" host:port) (sqlite3:finalize! db))) (thread-start! th1) @@ -202,28 +208,30 @@ (server:find-free-port-and-open (+ port 1))) (rpc:default-server-port port) (tcp-listen (rpc:default-server-port)))) (define (server:client-setup db) - (let* ((hostinfo (db:get-var db "SERVER")) - (hostdat (if hostinfo (string-split hostinfo ":"))) - (host (if hostinfo (car hostdat))) - (port (if (and hostinfo (> (length hostdat) 1))(cadr hostdat) #f))) - (if (and port - (string->number port)) - (let ((portn (string->number port))) - (debug:print 2 "INFO: Setting up to connect to host " host ":" port) - (handle-exceptions - exn - (begin - (print "Exception: " exn) - (set! *runremote* #f)) - (if (and (not (args:get-arg "-server")) ;; no point in the server using the server using the server - ((rpc:procedure 'serve:login host portn) *toppath*)) - (begin - (debug:print 2 "INFO: Connected to " host ":" port) - (set! *runremote* (vector host portn))) - (begin - (debug:print 2 "INFO: Failed to connect to " host ":" port) - (set! *runremote* #f))))) - (debug:print 2 "INFO: no server available")))) + (if *runremote* + (debug:print 0 "ERROR: Attempt to connect to server but already connected") + (let* ((hostinfo (db:get-var db "SERVER")) + (hostdat (if hostinfo (string-split hostinfo ":"))) + (host (if hostinfo (car hostdat))) + (port (if (and hostinfo (> (length hostdat) 1))(cadr hostdat) #f))) + (if (and port + (string->number port)) + (let ((portn (string->number port))) + (debug:print 2 "INFO: Setting up to connect to host " host ":" port) + (handle-exceptions + exn + (begin + (print "Exception: " exn) + (set! *runremote* #f)) + (if (and (not (args:get-arg "-server")) ;; no point in the server using the server using the server + ((rpc:procedure 'serve:login host portn) *toppath*)) + (begin + (debug:print 2 "INFO: Connected to " host ":" port) + (set! *runremote* (vector host portn))) + (begin + (debug:print 2 "INFO: Failed to connect to " host ":" port) + (set! *runremote* #f))))) + (debug:print 2 "INFO: no server available")))))