From owner-svn-src-all@freebsd.org Sun Jul 19 16:05:32 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5E3EB9A5E8F; Sun, 19 Jul 2015 16:05:32 +0000 (UTC) (envelope-from markm@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2A5A616EA; Sun, 19 Jul 2015 16:05:32 +0000 (UTC) (envelope-from markm@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.14.9/8.14.9) with ESMTP id t6JG5Vi8038573; Sun, 19 Jul 2015 16:05:31 GMT (envelope-from markm@FreeBSD.org) Received: (from markm@localhost) by repo.freebsd.org (8.14.9/8.14.9/Submit) id t6JG5V3o038572; Sun, 19 Jul 2015 16:05:31 GMT (envelope-from markm@FreeBSD.org) Message-Id: <201507191605.t6JG5V3o038572@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markm set sender to markm@FreeBSD.org using -f From: Mark Murray Date: Sun, 19 Jul 2015 16:05:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r285692 - head/sys/dev/random X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Jul 2015 16:05:32 -0000 Author: markm Date: Sun Jul 19 16:05:30 2015 New Revision: 285692 URL: https://svnweb.freebsd.org/changeset/base/285692 Log: Fix the read blocking so that it is interruptable and slow down the rate of console warning spamming while blocked. Approved by: so (/dev/random blanket) Modified: head/sys/dev/random/randomdev.c Modified: head/sys/dev/random/randomdev.c ============================================================================== --- head/sys/dev/random/randomdev.c Sun Jul 19 16:05:26 2015 (r285691) +++ head/sys/dev/random/randomdev.c Sun Jul 19 16:05:30 2015 (r285692) @@ -163,22 +163,28 @@ int read_random_uio(struct uio *uio, bool nonblock) { uint8_t *random_buf; - int error; + int error, spamcount; ssize_t read_len, total_read, c; random_buf = malloc(PAGE_SIZE, M_ENTROPY, M_WAITOK); random_alg_context.ra_pre_read(); - /* (Un)Blocking logic */ error = 0; + spamcount = 0; + /* (Un)Blocking logic */ while (!random_alg_context.ra_seeded()) { if (nonblock) { error = EWOULDBLOCK; break; } - tsleep(&random_alg_context, 0, "randseed", hz/10); /* keep tapping away at the pre-read until we seed/unblock. */ random_alg_context.ra_pre_read(); - printf("random: %s unblock wait\n", __func__); + /* Only bother the console every 10 seconds or so */ + if (spamcount == 0) + printf("random: %s unblock wait\n", __func__); + spamcount = (spamcount + 1)%100; + error = tsleep(&random_alg_context, PCATCH, "randseed", hz/10); + if ((error == ERESTART | error == EINTR)) + break; } if (error == 0) { #if !defined(RANDOM_DUMMY)