Index: ulex-simple/dbmgr.scm ================================================================== --- ulex-simple/dbmgr.scm +++ ulex-simple/dbmgr.scm @@ -332,19 +332,32 @@ ;; db is at apath/.db/dbname, rid is an intermediary solution and will be removed ;; sometime in the future ;; (define (rmt:send-receive-real sinfo apath dbname cmd params) (let* ((cdat (rmt:get-conn sinfo apath dbname))) - (assert cdat "FATAL: rmt:send-receive-real called without the needed channels opened") - (let* ((uconn (servdat-uconn sinfo)) ;; get the interface to ulex - ;; then send-receive using the ulex layer to host-port stored in cdat - (res (send-receive uconn (conndat-hostport cdat) cmd params))) - ;; since we accessed the server we can bump the expires time up - (conndat-expires-set! cdat (+ (current-seconds) - (server:expiration-timeout) - -2)) ;; two second margin for network time misalignments etc. - res))) + (if (> (current-seconds)(conndat-expires cdat)) + (begin + (debug:print-info 0 *default-log-port* "Connection to "apath"/"dbname" expired, reconnecting.") + (rmt:drop-conn sinfo apath dbname) + (rmt:send-receive-real sinfo apath dbname cmd params)) + (begin + (assert cdat "FATAL: rmt:send-receive-real called without the needed channels opened") + (let* ((uconn (servdat-uconn sinfo)) ;; get the interface to ulex + ;; then send-receive using the ulex layer to host-port stored in cdat + (res (condition-case + (send-receive uconn (conndat-hostport cdat) cmd params) + ((exn i/o net timeout) + ;; here we need to close and reconnect + (rmt:drop-conn sinfo apath dbname) + (rmt:general-open-connection sinfo apath dbname) + (rmt:send-receive-real sinfo apath dbname cmd params) + )))) + ;; since we accessed the server we can bump the expires time up + (conndat-expires-set! cdat (+ (current-seconds) + (server:expiration-timeout) + -2)) ;; two second margin for network time misalignments etc. + res))))) ; ;; db is at apath/.db/dbname, rid is an intermediary solution and will be removed ;; sometime in the future. ;;