diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2008-06-07 07:27:28 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2008-06-07 07:27:28 +0000 |
commit | d51f075a4e71cbde5f25cd22cf07d0b7691d4c6c (patch) | |
tree | 0ca61a4abde7bd4d524dee67ed15dee37fe9f5f8 /client.c | |
parent | 958069575dc663595d37a37a8273db73a4e99aa1 (diff) |
Use a socketpair to synchronise server startup.
Diffstat (limited to 'client.c')
-rw-r--r-- | client.c | 19 |
1 files changed, 10 insertions, 9 deletions
@@ -1,4 +1,4 @@ -/* $Id: client.c,v 1.28 2008-06-02 21:08:36 nicm Exp $ */ +/* $Id: client.c,v 1.29 2008-06-07 07:27:28 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -51,11 +51,9 @@ client_init(const char *path, struct client_ctx *cctx, int start_server) retries = 0; retry: if (stat(path, &sb) != 0) { - if (start_server && errno == ENOENT && retries < 10) { - if (pid == 0) - pid = server_start(path); - usleep(10000); - retries++; + if (start_server && errno == ENOENT) { + if (server_start(path) != 0) + goto no_start; goto retry; } goto fail; @@ -81,9 +79,8 @@ retry: if (start_server && errno == ECONNREFUSED && retries < 10) { if (unlink(path) != 0) goto fail; - usleep(10000); - retries++; - goto retry; + if (server_start(path) != 0) + goto no_start; } goto fail; } @@ -112,6 +109,10 @@ retry: return (0); +no_start: + log_warnx("server failed to start"); + return (1); + fail: log_warn("server not found"); return (1); |