version 1.27, 2009/10/26 21:38:18 |
version 1.28, 2009/11/02 13:41:25 |
|
|
strlcpy(rpathbuf, path, sizeof rpathbuf); |
strlcpy(rpathbuf, path, sizeof rpathbuf); |
setproctitle("client (%s)", 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); |
memset(&sa, 0, sizeof sa); |
sa.sun_family = AF_UNIX; |
sa.sun_family = AF_UNIX; |
size = strlcpy(sa.sun_path, path, sizeof sa.sun_path); |
size = strlcpy(sa.sun_path, path, sizeof sa.sun_path); |
|
|
fatal("socket failed"); |
fatal("socket failed"); |
|
|
if (connect(fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) == -1) { |
if (connect(fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) == -1) { |
if (errno == ECONNREFUSED) { |
if (!(cmdflags & CMD_STARTSERVER)) |
if (unlink(path) != 0 || !(cmdflags & CMD_STARTSERVER)) |
goto not_found; |
|
switch (errno) { |
|
case ECONNREFUSED: |
|
if (unlink(path) != 0) |
goto not_found; |
goto not_found; |
|
/* FALLTHROUGH */ |
|
case ENOENT: |
if ((fd = server_start(path)) == -1) |
if ((fd = server_start(path)) == -1) |
goto start_failed; |
goto start_failed; |
goto server_started; |
goto server_started; |