diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2007-09-26 18:12:19 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2007-09-26 18:12:19 +0000 |
commit | b1822f6a72841cf547d749cf6dbf811c983a7528 (patch) | |
tree | 3a2438b602f74f49986ff4b6108b9d14ee2091c9 | |
parent | 302a35da85c223aae29b4d356787ee492c9b56d7 (diff) | |
download | rtmux-b1822f6a72841cf547d749cf6dbf811c983a7528.tar.gz rtmux-b1822f6a72841cf547d749cf6dbf811c983a7528.tar.bz2 rtmux-b1822f6a72841cf547d749cf6dbf811c983a7528.zip |
Unlink and retry if server socket connect fails.
-rw-r--r-- | client.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -1,4 +1,4 @@ -/* $Id: client.c,v 1.1 2007-09-26 13:43:15 nicm Exp $ */ +/* $Id: client.c,v 1.2 2007-09-26 18:12:19 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -42,12 +42,14 @@ client_init(char *path, struct client_ctx *cctx, int ws) struct stat sb; size_t sz; int mode; + u_int retries; if (path == NULL) { xasprintf(&path, "%s/%s-%lu", _PATH_TMP, __progname, (u_long) getuid()); } + retries = 0; retry: if (stat(path, &sb) != 0) { if (errno != ENOENT) { @@ -94,6 +96,14 @@ retry: } if (connect( cctx->srv_fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) == -1) { + if (errno == ECONNREFUSED && retries < 5) { + if (unlink(path) != 0) { + log_warn("%s: unlink", path); + return (-1); + } + retries++; + goto retry; + } log_warn("%s: connect", path); return (-1); } |