From: raid5atemyhomework via Bug reports for GNU Guix <bug-guix@gnu.org>
To: "36380@debbugs.gnu.org" <36380@debbugs.gnu.org>
Subject: bug#36380: service urandom-seed takes too long on boot
Date: Sun, 07 Feb 2021 15:23:13 +0000 [thread overview]
Message-ID: <WNVyEQuIt5aHwSlkxpYNZx49vGxO5K8ABy-Vd4_g98Pr5B-IHsJmu5qlsnAq2z_YSuJ8l5giKdR0NcuUMsQzUX6OJ6Hb7D-Bjcb3aR9WmuI=@protonmail.com> (raw)
In-Reply-To: <F88CEF04-9BFA-4886-8A2D-AD84AE278D07@vllmrt.net>
```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)))))))))
```
prev parent reply other threads:[~2021-02-07 15:24 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-25 18:12 bug#36380: service urandom-seed takes too long on boot Robert Vollmert
2019-06-26 9:41 ` Alex Sassmannshausen
2019-06-26 15:47 ` Leo Famulari
2019-06-26 16:02 ` Robert Vollmert
2019-06-27 19:19 ` Leo Famulari
2019-06-27 15:20 ` Ludovic Courtès
2019-06-27 19:03 ` Leo Famulari
2019-06-27 20:00 ` Ludovic Courtès
2019-06-28 6:47 ` Robert Vollmert
2019-06-28 17:24 ` Leo Famulari
2019-07-11 17:44 ` Leo Famulari
2019-07-11 21:33 ` Ludovic Courtès
2019-07-17 21:04 ` bug#36380: related article (Debian) Robert Vollmert
2020-03-22 8:43 ` bug#36380: service urandom-seed takes too long on boot Brice Waegeneire
2020-03-22 20:19 ` Leo Famulari
2020-12-27 15:00 ` Stefan
2020-12-27 23:09 ` Leo Famulari
2020-12-27 23:28 ` Stefan
2020-12-29 2:51 ` Leo Famulari
2021-02-07 15:23 ` raid5atemyhomework via Bug reports for GNU Guix [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='WNVyEQuIt5aHwSlkxpYNZx49vGxO5K8ABy-Vd4_g98Pr5B-IHsJmu5qlsnAq2z_YSuJ8l5giKdR0NcuUMsQzUX6OJ6Hb7D-Bjcb3aR9WmuI=@protonmail.com' \
--to=bug-guix@gnu.org \
--cc=36380@debbugs.gnu.org \
--cc=raid5atemyhomework@protonmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).