OSDN Git Service

libuuid: Only try to start the uuidd daemon a limited number of times
authorTheodore Ts'o <tytso@mit.edu>
Mon, 17 Dec 2007 20:26:47 +0000 (15:26 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 17 Dec 2007 20:26:47 +0000 (15:26 -0500)
If we fail to create the uuidd daemon after 5 or 6 tries, another
10,000 tries probably won't be successful.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/uuid/gen_uuid.c

index 1918b3b..397a207 100644 (file)
@@ -394,6 +394,7 @@ static int get_uuid_via_daemon(int op, uuid_t out, int *num)
        pid_t pid;
        static const char *uuidd_path = UUIDD_PATH;
        static int access_ret = -2;
+       static int start_attempts = 0;
 
        if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
                return -1;
@@ -405,7 +406,7 @@ static int get_uuid_via_daemon(int op, uuid_t out, int *num)
                    sizeof(struct sockaddr_un)) < 0) {
                if (access_ret == -2)
                        access_ret = access(uuidd_path, X_OK);
-               if (access_ret == 0) {
+               if (access_ret == 0 && start_attempts++ < 5) {
                        if ((pid = fork()) == 0) {
                                execl(uuidd_path, "uuidd", "-qT", "300", 0);
                                exit(1);