GNU bug report logs -
#36380
service urandom-seed takes too long on boot
Previous Next
Full log
View this message in rfc822 format
```scheme
(define (get-bytevector-n-timed port count max-time)
"Read COUNT octets from PORT, blocking as necessary and return a
bytevector containing the octets read, and taking no more than
MAX-TIME seconds. If fewer bytes are available, a bytevector
smaller than COUNT is returned."
(define (get-time)
(let* ((pair (gettimeofday))
(secs (car pair))
(usecs (cdr pair)))
(+ secs (* 0.000001 usecs))))
(let* ((start-time (get-time))
(end-time (+ start-time max-time))
(buf (make-bytevector count)))
(let loop ((offset 0))
(let ((current-time (get-time)))
(cond
((= offset count)
buf)
((>= current-time end-time)
(let ((newbuf (make-bytevector offset)))
(bytevector-copy! buf 0 newbuf 0 offset)
newbuf))
(else
(let* ((result (select (list port) '() '() (- end-time current-time)))
(readable? (not (null? (car result)))))
(if readable?
(begin
;; read only one byte at a time, as we cannot be sure
;; that the given port will have more than one byte
;; available and that ports will not block if we ask
;; for more than one byte.
(get-bytevector-n! port buf offset 1)
(loop (+ offset 1)))
(loop offset)))))))))
```
This bug report was last modified 4 years and 126 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.