Retry syscalls when interrupted.
This commit is contained in:
parent
75bad52dfe
commit
d472115b34
|
@ -95,8 +95,9 @@
|
||||||
(define (lock-region/no-block fdes lock)
|
(define (lock-region/no-block fdes lock)
|
||||||
(cond ((call-lock-region %set-lock fcntl/set-record-lock-noblock fdes lock)
|
(cond ((call-lock-region %set-lock fcntl/set-record-lock-noblock fdes lock)
|
||||||
=> (lambda (errno)
|
=> (lambda (errno)
|
||||||
(if (= errno errno/again) #f
|
(cond ((= errno errno/again) #f)
|
||||||
(errno-error errno lock-region/no-block fdes lock))))
|
((= errno errno/intr) (lock-region/no-block fdes lock))
|
||||||
|
(else (errno-error errno lock-region/no-block fdes lock)))))
|
||||||
(else #t)))
|
(else #t)))
|
||||||
|
|
||||||
|
|
||||||
|
@ -105,15 +106,15 @@
|
||||||
(define (get-lock-region fdes lock)
|
(define (get-lock-region fdes lock)
|
||||||
(receive (err type whence start len pid)
|
(receive (err type whence start len pid)
|
||||||
(call-lock-region %get-lock fcntl/get-record-lock fdes lock)
|
(call-lock-region %get-lock fcntl/get-record-lock fdes lock)
|
||||||
(if err (errno-error err get-lock-region fdes lock)
|
(cond ((not err)
|
||||||
(and (not (= type lock/release))
|
(and (not (= type lock/release))
|
||||||
(make-%lock-region (= type lock/write) start len whence pid)))))
|
(make-%lock-region (= type lock/write) start len whence pid)))
|
||||||
|
((= err errno/intr) (get-lock-region fdes lock))
|
||||||
|
(else (errno-error err get-lock-region fdes lock)))))
|
||||||
|
|
||||||
|
|
||||||
|
(define-errno-syscall (unlock-region fdes lock)
|
||||||
(define (unlock-region fdes lock)
|
(lambda (fdes lock) (call-lock-region %set-lock lock/release fdes lock)))
|
||||||
(cond ((call-lock-region %set-lock lock/release fdes lock) =>
|
|
||||||
(lambda (errno) (errno-error errno unlock-region fdes lock)))))
|
|
||||||
|
|
||||||
|
|
||||||
;;; Locks with dynamic extent -- with and without sugar
|
;;; Locks with dynamic extent -- with and without sugar
|
||||||
|
|
|
@ -118,6 +118,7 @@
|
||||||
fixnum) ; lo secs
|
fixnum) ; lo secs
|
||||||
|
|
||||||
(define (time . args) ; optional arg [date]
|
(define (time . args) ; optional arg [date]
|
||||||
|
(let lp ()
|
||||||
(receive (err hi-secs lo-secs)
|
(receive (err hi-secs lo-secs)
|
||||||
(if (null? args)
|
(if (null? args)
|
||||||
(%time/errno) ; Fast path for (time).
|
(%time/errno) ; Fast path for (time).
|
||||||
|
@ -132,8 +133,9 @@
|
||||||
(date:tz-secs date) ; #f or int
|
(date:tz-secs date) ; #f or int
|
||||||
(date:summer? date))))
|
(date:summer? date))))
|
||||||
|
|
||||||
(if err (apply errno-error err time args)
|
(cond ((not err) (compose-8/24 hi-secs lo-secs)) ; Win.
|
||||||
(compose-8/24 hi-secs lo-secs))))
|
((= errno/intr err) (lp)) ; Retry.
|
||||||
|
(else (apply errno-error err time args)))))); Lose.
|
||||||
|
|
||||||
|
|
||||||
;;; Date
|
;;; Date
|
||||||
|
@ -162,14 +164,17 @@
|
||||||
(zone (check-arg time-zone?
|
(zone (check-arg time-zone?
|
||||||
(and (pair? args) (:optional (cdr args) #f))
|
(and (pair? args) (:optional (cdr args) #f))
|
||||||
date)))
|
date)))
|
||||||
|
(let lp ()
|
||||||
(receive (err seconds minute hour month-day month
|
(receive (err seconds minute hour month-day month
|
||||||
year tz-name tz-secs summer? week-day year-day)
|
year tz-name tz-secs summer? week-day year-day)
|
||||||
(%time->date (hi8 time) (lo24 time) zone)
|
(%time->date (hi8 time) (lo24 time) zone)
|
||||||
(if err (errno-error err date time zone)
|
(cond ((not err)
|
||||||
(make-%date seconds minute hour month-day month
|
(make-%date seconds minute hour month-day month
|
||||||
year
|
year
|
||||||
(format-time-zone (or tz-name "UTC") tz-secs)
|
(format-time-zone (or tz-name "UTC") tz-secs)
|
||||||
tz-secs summer? week-day year-day)))))
|
tz-secs summer? week-day year-day))
|
||||||
|
((= errno/intr err) (lp))
|
||||||
|
(errno-error err date time zone))))))
|
||||||
|
|
||||||
|
|
||||||
;;; Formatting date strings
|
;;; Formatting date strings
|
||||||
|
@ -194,8 +199,9 @@
|
||||||
(date:summer? date)
|
(date:summer? date)
|
||||||
(date:week-day date)
|
(date:week-day date)
|
||||||
(date:year-day date))
|
(date:year-day date))
|
||||||
(if err (errno-error err format-date fmt date)
|
(cond ((not err) result)
|
||||||
result)))
|
((= errno/intr err) (format-date fmt date))
|
||||||
|
(else (errno-error err format-date fmt date)))))
|
||||||
|
|
||||||
(define-foreign %format-date/errno (format_date (string fmt)
|
(define-foreign %format-date/errno (format_date (string fmt)
|
||||||
(fixnum seconds)
|
(fixnum seconds)
|
||||||
|
|
12
scsh/tty.scm
12
scsh/tty.scm
|
@ -345,17 +345,19 @@
|
||||||
|
|
||||||
(define (open-control-tty ttyname . maybe-flags)
|
(define (open-control-tty ttyname . maybe-flags)
|
||||||
(let ((flags (:optional maybe-flags open/read+write)))
|
(let ((flags (:optional maybe-flags open/read+write)))
|
||||||
|
(let lp ()
|
||||||
(receive (errno fd) (open-control-tty/errno ttyname flags)
|
(receive (errno fd) (open-control-tty/errno ttyname flags)
|
||||||
(if errno
|
(cond ((not errno)
|
||||||
(errno-error errno open-control-tty ttyname flags)
|
|
||||||
|
|
||||||
(let* ((access (bitwise-and flags open/access-mask))
|
(let* ((access (bitwise-and flags open/access-mask))
|
||||||
(port ((if (or (= access open/read) (= access open/read+write))
|
(port ((if (or (= access open/read)
|
||||||
|
(= access open/read+write))
|
||||||
make-input-fdport
|
make-input-fdport
|
||||||
make-output-fdport)
|
make-output-fdport)
|
||||||
fd)))
|
fd)))
|
||||||
(%install-port fd port)
|
(%install-port fd port)
|
||||||
port)))))
|
port))
|
||||||
|
((= errno/intr errno) (lp))
|
||||||
|
(else (errno-error errno open-control-tty ttyname flags)))))))
|
||||||
|
|
||||||
(define-foreign open-control-tty/errno (open_ctty (string ttyname)
|
(define-foreign open-control-tty/errno (open_ctty (string ttyname)
|
||||||
(fixnum flags))
|
(fixnum flags))
|
||||||
|
|
Loading…
Reference in New Issue