]> git.eshelyaron.com Git - emacs.git/commitdiff
Sleep less in update-game-score
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 21 Mar 2023 21:38:23 +0000 (14:38 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 21 Mar 2023 21:42:18 +0000 (14:42 -0700)
This is mostly to avoid interface hassles with time/srand/rand.
* lib-src/update-game-score.c (main): Don’t use ‘srand’ or ‘time’.
(lock_file): Don’t sleep if we unlocked the lock file.  When
sleeping, always just sleep 1 s.  This avoids the need for calling
‘time’ and ‘rand’, the utility of which was dubious anyway.

lib-src/update-game-score.c

index 83167f59b8ad07f49162011b28442ec203064223..4592e14d1d64aa7bfebedd9d8e97f0aba11912cc 100644 (file)
@@ -185,8 +185,6 @@ main (int argc, char **argv)
   ptrdiff_t scorecount, scorealloc;
   ptrdiff_t max_scores = MAX_SCORES;
 
-  srand (time (0));
-
   while ((c = getopt (argc, argv, "hrm:d:")) != -1)
     switch (c)
       {
@@ -485,8 +483,8 @@ lock_file (const char *filename, void **state)
            return -1;
          attempts = 0;
        }
-
-      sleep ((rand () & 1) + 1);
+      else
+       sleep (1);
     }
 
   close (fd);