]> git.ipfire.org Git - thirdparty/rng-tools.git/commitdiff
Removed timeout option, leaving poll unlimited
authorBrad Hill <richard.b.hill@intel.com>
Thu, 26 Jul 2012 13:51:59 +0000 (09:51 -0400)
committerJeff Garzik <jgarzik@redhat.com>
Thu, 26 Jul 2012 13:51:59 +0000 (09:51 -0400)
Removed timeout variables, parameters, and argument.  Poll is now called
with -1 as the timeout.

rngd.8.in
rngd.c
rngd.h
rngd_linux.c
rngd_linux.h

index 2fd357fe2dde2b057f74cbe2c72fef900a5c24c9..2615df9a4dda7a2a526386be4371afb5cfd2ae18 100644 (file)
--- a/rngd.8.in
+++ b/rngd.8.in
@@ -17,7 +17,6 @@ rngd \- Check and feed random data from hardware device to kernel random device
 [\fB\-n\fR, \fB\-\-no-tpm=\fI1|0\fR]
 [\fB\-q\fR, \fB\-\-quiet\fR]
 [\fB\-v\fR, \fB\-\-verbose\fR]
-[\fB\-t\fR, \fB\-\-timeout=\fInnn\fR]
 [\fB\-?\fR, \fB\-\-help\fR]
 [\fB\-V\fR, \fB\-\-version\fR]
 .RI
@@ -81,9 +80,6 @@ Suppress error messages
 \fB\-v\fR, \fB\-\-verbose\fR
 Report available entropy sources
 .TP
-\fB\-t\fI nnn\fR, \fB\-\-timeout=\fInnn\fR
-Interval written to random-device when the entropy pool is full, in seconds, or 0 to disable (default: 60)
-.TP
 \fB\-?\fR, \fB\-\-help\fR
 Give a short summary of all program options.
 .TP
diff --git a/rngd.c b/rngd.c
index f83c562aff0eba7ba288b45aa076379ab384a3e1..46ae23a904398e23e23a4d7c72b158713e4e412d 100644 (file)
--- a/rngd.c
+++ b/rngd.c
@@ -99,8 +99,6 @@ static struct argp_option options[] = {
 
        { "verbose" ,'v', 0, 0, "Report available entropy sources" },
 
-       { "timeout", 't', "nnn", 0,
-         "Interval written to random-device when the entropy pool is full, in seconds, or 0 to disable (default: 60)" },
        { "no-tpm", 'n', "1|0", 0,
          "do not use tpm as a source of random number input (default: 0)" },
 
@@ -110,7 +108,6 @@ static struct argp_option options[] = {
 static struct arguments default_arguments = {
        .random_name    = "/dev/random",
        .pid_file       = "/var/run/rngd.pid",
-       .poll_timeout   = 60,
        .random_step    = 64,
        .fill_watermark = 2048,
        .daemon         = true,
@@ -149,15 +146,6 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state)
        case 'r':
                rng_default.rng_name = arg;
                break;
-       case 't': {
-               float f;
-               if (sscanf(arg, "%f", &f) == 0)
-                       argp_usage(state);
-               else
-                       arguments->poll_timeout = f;
-               break;
-       }
-
        case 'f':
                arguments->daemon = false;
                break;
@@ -201,7 +189,7 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state)
 static struct argp argp = { options, parse_opt, NULL, doc };
 
 
-static int update_kernel_random(int random_step, double poll_timeout,
+static int update_kernel_random(int random_step,
        unsigned char *buf, fips_ctx_t *fipsctx_in)
 {
        unsigned char *p;
@@ -217,12 +205,12 @@ static int update_kernel_random(int random_step, double poll_timeout,
        for (p = buf; p + random_step <= &buf[FIPS_RNG_BUFFER_SIZE];
                 p += random_step) {
                random_add_entropy(p, random_step);
-               random_sleep(poll_timeout);
+               random_sleep();
        }
        return 0;
 }
 
-static void do_loop(int random_step, double poll_timeout)
+static void do_loop(int random_step)
 {
        unsigned char buf[FIPS_RNG_BUFFER_SIZE];
        int retval = 0;
@@ -250,8 +238,7 @@ static void do_loop(int random_step, double poll_timeout)
                        work_done = true;
 
                        rc = update_kernel_random(random_step,
-                                            poll_timeout, buf,
-                                            iter->fipsctx);
+                                            buf, iter->fipsctx);
                        if (rc == 0)
                                continue;       /* succeeded, work done */
 
@@ -344,8 +331,7 @@ int main(int argc, char **argv)
                signal(SIGTERM, term_signal);
        }
 
-       do_loop(arguments->random_step,
-               arguments->poll_timeout ? : -1.0);
+       do_loop(arguments->random_step);
 
        if (pid_fd >= 0)
                unlink(arguments->pid_file);
diff --git a/rngd.h b/rngd.h
index 3ac495f9d110f2960cac655bd7c8d81241b670fb..69343e97f204cdbf28c7613a0916fa3f3c2fbd68 100644 (file)
--- a/rngd.h
+++ b/rngd.h
@@ -44,7 +44,6 @@ struct arguments {
 
        int random_step;
        int fill_watermark;
-       double poll_timeout;
 
        bool quiet;
        bool verbose;
index 173a3158fbd309427428c849d4080a4dda6beb95..9b76198490aec56cba3c50ae8d43b54e63d10516 100644 (file)
@@ -89,7 +89,7 @@ void random_add_entropy(void *buf, size_t size)
        }
 }
 
-void random_sleep(double poll_timeout)
+void random_sleep()
 {
        int ent_count;
        struct pollfd pfd = {
@@ -97,11 +97,7 @@ void random_sleep(double poll_timeout)
                events: POLLOUT,
        };
 
-       if (ioctl(random_fd, RNDGETENTCNT, &ent_count) == 0 &&
-           ent_count < arguments->fill_watermark)
-               return;
-
-       poll(&pfd, 1, 1000.0 * poll_timeout);
+       poll(&pfd, 1, -1);
 }
 
 void src_list_add(struct rng *ent_src)
index d16644b1cc279d78c19514138f5d95ae2f7790ee..b5438272446883a0a54ad98f9eaee5a84ed77691 100644 (file)
@@ -38,7 +38,7 @@ extern void init_kernel_rng(const char* randomdev);
 extern void random_add_entropy(void *buf, size_t size);
 
 /* Sleep until the kernel is hungry for entropy */
-extern void random_sleep(double poll_timeout);
+extern void random_sleep();
 
 #endif /* RNGD_LINUX__H */