summaryrefslogtreecommitdiffstats
path: root/client.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2008-06-07 07:27:28 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2008-06-07 07:27:28 +0000
commitd51f075a4e71cbde5f25cd22cf07d0b7691d4c6c (patch)
tree0ca61a4abde7bd4d524dee67ed15dee37fe9f5f8 /client.c
parent958069575dc663595d37a37a8273db73a4e99aa1 (diff)
Use a socketpair to synchronise server startup.
Diffstat (limited to 'client.c')
-rw-r--r--client.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/client.c b/client.c
index 59e69875..49041461 100644
--- a/client.c
+++ b/client.c
@@ -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);