diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-11-02 13:41:26 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-11-02 13:41:26 +0000 |
commit | 881cd4c711fc52430ee51f2b71ea77d61fb1d63e (patch) | |
tree | a712bd721d2e51bd3c0e9e91e3e5e0fb5cd46e95 /usr.bin/tmux | |
parent | 32a0513a08ae35837d14099c08a452328e6f1977 (diff) |
There isn't much point in doing lstat before connect so instead just do connect
and handle ENOENT from it which is a little tidier.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r-- | usr.bin/tmux/client.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/usr.bin/tmux/client.c b/usr.bin/tmux/client.c index 32afa8c4bd6..bebe61e786f 100644 --- a/usr.bin/tmux/client.c +++ b/usr.bin/tmux/client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.27 2009/10/26 21:38:18 nicm Exp $ */ +/* $OpenBSD: client.c,v 1.28 2009/11/02 13:41:25 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -55,19 +55,6 @@ client_init(char *path, int cmdflags, int flags) strlcpy(rpathbuf, path, sizeof rpathbuf); setproctitle("client (%s)", rpathbuf); - if (lstat(path, &sb) != 0) { - if (cmdflags & CMD_STARTSERVER && errno == ENOENT) { - if ((fd = server_start(path)) == -1) - goto start_failed; - goto server_started; - } - goto not_found; - } - if (!S_ISSOCK(sb.st_mode)) { - errno = ENOTSOCK; - goto not_found; - } - memset(&sa, 0, sizeof sa); sa.sun_family = AF_UNIX; size = strlcpy(sa.sun_path, path, sizeof sa.sun_path); @@ -80,9 +67,14 @@ client_init(char *path, int cmdflags, int flags) fatal("socket failed"); if (connect(fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) == -1) { - if (errno == ECONNREFUSED) { - if (unlink(path) != 0 || !(cmdflags & CMD_STARTSERVER)) + if (!(cmdflags & CMD_STARTSERVER)) + goto not_found; + switch (errno) { + case ECONNREFUSED: + if (unlink(path) != 0) goto not_found; + /* FALLTHROUGH */ + case ENOENT: if ((fd = server_start(path)) == -1) goto start_failed; goto server_started; |