X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=eightsync%2Fagenda.scm;h=1bfc0a3a941ac148d4214b014b8e1878d23c5e85;hb=555743be477968b12562c5b6c92000ecfe9556f2;hp=8905c1b6c46241d4f1aac9dfe4d4a14a2077d5c3;hpb=060e7509ca51307b6ebcb6d8c5bc22451db3a384;p=8sync.git diff --git a/eightsync/agenda.scm b/eightsync/agenda.scm index 8905c1b..1bfc0a3 100644 --- a/eightsync/agenda.scm +++ b/eightsync/agenda.scm @@ -61,7 +61,7 @@ port-request-port port-request-read port-request-write port-request-except - run-it wrap run run-at run-delay + run-it wrap wrap-apply run run-at run-delay %port-request %run %run-at %run-delay 8port-request 8run 8run-at 8run-delay @@ -248,13 +248,13 @@ Will produce (0 . 0) instead of a negative number, if needed." "Subtract TIME2 from TIME1" (time-carry-correct (cons (- (car time1) (car time2)) - (- (cdr time2) (cdr time2))))) + (- (cdr time1) (cdr time2))))) (define (time-plus time1 time2) "Add TIME1 and TIME2" (time-carry-correct (cons (+ (car time1) (car time2)) - (+ (cdr time2) (cdr time2))))) + (+ (cdr time1) (cdr time2))))) (define-record-type @@ -382,6 +382,12 @@ Will produce (0 . 0) instead of a negative number, if needed." (lambda () body ...)) +(define-syntax-rule (wrap-apply body) + "Wrap possibly multi-value function in a procedure, applies all arguments" + (lambda args + (apply body args))) + + ;; @@: Do we really want `body ...' here? ;; what about just `body'? (define-syntax-rule (run body ...) @@ -554,10 +560,17 @@ return the wrong thing via (8sync) and trip themselves up." ;; TODO: support usecond wait time too (match (get-wait-time) ((sec . usec) - (select (hash-keys (agenda-read-port-map agenda)) - (hash-keys (agenda-write-port-map agenda)) - (hash-keys (agenda-except-port-map agenda)) - sec usec)))) + (catch 'system-error + (lambda () + (select (hash-keys (agenda-read-port-map agenda)) + (hash-keys (agenda-write-port-map agenda)) + (hash-keys (agenda-except-port-map agenda)) + sec usec)) + (lambda (key . rest-args) + (match rest-args + ((_ _ _ (EINTR)) + '(() () ())) + (_ (error "Unhandled error in select!" key rest-args)))))))) (define (get-procs-to-run) (define (ports->procs ports port-map) (lambda (initial-procs)