mirror of
https://github.com/tmate-io/tmate.git
synced 2025-01-11 00:18:55 +01:00
Tidy function a little by using a temporary variable.
This commit is contained in:
parent
90f8151ffd
commit
e985629440
16
client.c
16
client.c
@ -43,7 +43,7 @@ client_init(char *path, struct client_ctx *cctx, int cmdflags, int flags)
|
|||||||
struct msg_identify_data data;
|
struct msg_identify_data data;
|
||||||
struct winsize ws;
|
struct winsize ws;
|
||||||
size_t size;
|
size_t size;
|
||||||
int mode;
|
int fd, mode;
|
||||||
char *name, *term;
|
char *name, *term;
|
||||||
char rpathbuf[MAXPATHLEN];
|
char rpathbuf[MAXPATHLEN];
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ client_init(char *path, struct client_ctx *cctx, int cmdflags, int flags)
|
|||||||
|
|
||||||
if (lstat(path, &sb) != 0) {
|
if (lstat(path, &sb) != 0) {
|
||||||
if (cmdflags & CMD_STARTSERVER && errno == ENOENT) {
|
if (cmdflags & CMD_STARTSERVER && errno == ENOENT) {
|
||||||
if ((cctx->srv_fd = server_start(path)) == -1)
|
if ((fd = server_start(path)) == -1)
|
||||||
goto start_failed;
|
goto start_failed;
|
||||||
goto server_started;
|
goto server_started;
|
||||||
}
|
}
|
||||||
@ -72,15 +72,14 @@ client_init(char *path, struct client_ctx *cctx, int cmdflags, int flags)
|
|||||||
goto not_found;
|
goto not_found;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((cctx->srv_fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
|
if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
|
||||||
fatal("socket");
|
fatal("socket");
|
||||||
|
|
||||||
if (connect(
|
if (connect(fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) == -1) {
|
||||||
cctx->srv_fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) == -1) {
|
|
||||||
if (errno == ECONNREFUSED) {
|
if (errno == ECONNREFUSED) {
|
||||||
if (unlink(path) != 0 || !(cmdflags & CMD_STARTSERVER))
|
if (unlink(path) != 0 || !(cmdflags & CMD_STARTSERVER))
|
||||||
goto not_found;
|
goto not_found;
|
||||||
if ((cctx->srv_fd = server_start(path)) == -1)
|
if ((fd = server_start(path)) == -1)
|
||||||
goto start_failed;
|
goto start_failed;
|
||||||
goto server_started;
|
goto server_started;
|
||||||
}
|
}
|
||||||
@ -88,10 +87,11 @@ client_init(char *path, struct client_ctx *cctx, int cmdflags, int flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
server_started:
|
server_started:
|
||||||
if ((mode = fcntl(cctx->srv_fd, F_GETFL)) == -1)
|
if ((mode = fcntl(fd, F_GETFL)) == -1)
|
||||||
fatal("fcntl failed");
|
fatal("fcntl failed");
|
||||||
if (fcntl(cctx->srv_fd, F_SETFL, mode|O_NONBLOCK) == -1)
|
if (fcntl(fd, F_SETFL, mode|O_NONBLOCK) == -1)
|
||||||
fatal("fcntl failed");
|
fatal("fcntl failed");
|
||||||
|
cctx->srv_fd = fd;
|
||||||
cctx->srv_in = buffer_create(BUFSIZ);
|
cctx->srv_in = buffer_create(BUFSIZ);
|
||||||
cctx->srv_out = buffer_create(BUFSIZ);
|
cctx->srv_out = buffer_create(BUFSIZ);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user