diff options
author | Pierre-Yves Ritschard <pyr@cvs.openbsd.org> | 2007-01-30 10:09:03 +0000 |
---|---|---|
committer | Pierre-Yves Ritschard <pyr@cvs.openbsd.org> | 2007-01-30 10:09:03 +0000 |
commit | f3cec9f6c5accc4ced273cfdf9a530e5ce142727 (patch) | |
tree | f18012b4da963c49a94354a4b3c07d4a8537bd6c /usr.sbin | |
parent | 3cdaaaa00b23364a0b69c019302f2dec95e5ab93 (diff) |
style changes.
ok reyk@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/hoststated/check_tcp.c | 43 | ||||
-rw-r--r-- | usr.sbin/relayd/check_tcp.c | 43 |
2 files changed, 46 insertions, 40 deletions
diff --git a/usr.sbin/hoststated/check_tcp.c b/usr.sbin/hoststated/check_tcp.c index a3ebc23c563..e9a9293e0f5 100644 --- a/usr.sbin/hoststated/check_tcp.c +++ b/usr.sbin/hoststated/check_tcp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: check_tcp.c,v 1.12 2007/01/29 14:23:31 pyr Exp $ */ +/* $OpenBSD: check_tcp.c,v 1.13 2007/01/30 10:09:02 pyr Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org> @@ -79,8 +79,9 @@ check_tcp(struct ctl_tcp_event *cte) if (connect(s, (struct sockaddr *)&cte->host->ss, len) == -1) { if (errno != EINPROGRESS) goto bad; - } else - cte->host->up = HOST_UP; + } + + cte->host->up = HOST_UP; event_set(&cte->ev, s, EV_TIMEOUT|EV_WRITE, tcp_write, cte); event_add(&cte->ev, &tv); return; @@ -220,14 +221,15 @@ tcp_read_buf(int s, short event, void *arg) log_debug("reading"); bzero(rbuf, sizeof(rbuf)); br = read(s, rbuf, sizeof(rbuf) - 1); - if (br == -1) { + switch (br) { + case -1: if (errno == EAGAIN || errno == EINTR) goto retry; cte->host->up = HOST_DOWN; buf_free(cte->buf); hce_notify_done(cte->host, "tcp_read_buf: read failed"); - return; - } else if (br == 0) { + return;; + case 0: cte->host->up = HOST_DOWN; (void)cte->validate_close(cte); close(cte->s); @@ -237,23 +239,24 @@ tcp_read_buf(int s, short event, void *arg) else hce_notify_done(cte->host, "check failed"); return; - } - buf_add(cte->buf, rbuf, br); - if (cte->validate_read != NULL) { - log_debug("calling check"); - if (cte->validate_read(cte) != 0) - goto retry; + default: + buf_add(cte->buf, rbuf, br); + if (cte->validate_read != NULL) { + log_debug("calling check"); + if (cte->validate_read(cte) != 0) + goto retry; - close(cte->s); - buf_free(cte->buf); - if (cte->host->up == HOST_UP) - hce_notify_done(cte->host, "check succeeded"); - else - hce_notify_done(cte->host, "check failed"); - return; + close(cte->s); + buf_free(cte->buf); + if (cte->host->up == HOST_UP) + hce_notify_done(cte->host, "check succeeded"); + else + hce_notify_done(cte->host, "check failed"); + return; + } + break; /* retry */ } retry: event_again(&cte->ev, s, EV_TIMEOUT|EV_READ, tcp_read_buf, &cte->tv_start, &cte->table->timeout, cte); - } diff --git a/usr.sbin/relayd/check_tcp.c b/usr.sbin/relayd/check_tcp.c index a3ebc23c563..e9a9293e0f5 100644 --- a/usr.sbin/relayd/check_tcp.c +++ b/usr.sbin/relayd/check_tcp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: check_tcp.c,v 1.12 2007/01/29 14:23:31 pyr Exp $ */ +/* $OpenBSD: check_tcp.c,v 1.13 2007/01/30 10:09:02 pyr Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org> @@ -79,8 +79,9 @@ check_tcp(struct ctl_tcp_event *cte) if (connect(s, (struct sockaddr *)&cte->host->ss, len) == -1) { if (errno != EINPROGRESS) goto bad; - } else - cte->host->up = HOST_UP; + } + + cte->host->up = HOST_UP; event_set(&cte->ev, s, EV_TIMEOUT|EV_WRITE, tcp_write, cte); event_add(&cte->ev, &tv); return; @@ -220,14 +221,15 @@ tcp_read_buf(int s, short event, void *arg) log_debug("reading"); bzero(rbuf, sizeof(rbuf)); br = read(s, rbuf, sizeof(rbuf) - 1); - if (br == -1) { + switch (br) { + case -1: if (errno == EAGAIN || errno == EINTR) goto retry; cte->host->up = HOST_DOWN; buf_free(cte->buf); hce_notify_done(cte->host, "tcp_read_buf: read failed"); - return; - } else if (br == 0) { + return;; + case 0: cte->host->up = HOST_DOWN; (void)cte->validate_close(cte); close(cte->s); @@ -237,23 +239,24 @@ tcp_read_buf(int s, short event, void *arg) else hce_notify_done(cte->host, "check failed"); return; - } - buf_add(cte->buf, rbuf, br); - if (cte->validate_read != NULL) { - log_debug("calling check"); - if (cte->validate_read(cte) != 0) - goto retry; + default: + buf_add(cte->buf, rbuf, br); + if (cte->validate_read != NULL) { + log_debug("calling check"); + if (cte->validate_read(cte) != 0) + goto retry; - close(cte->s); - buf_free(cte->buf); - if (cte->host->up == HOST_UP) - hce_notify_done(cte->host, "check succeeded"); - else - hce_notify_done(cte->host, "check failed"); - return; + close(cte->s); + buf_free(cte->buf); + if (cte->host->up == HOST_UP) + hce_notify_done(cte->host, "check succeeded"); + else + hce_notify_done(cte->host, "check failed"); + return; + } + break; /* retry */ } retry: event_again(&cte->ev, s, EV_TIMEOUT|EV_READ, tcp_read_buf, &cte->tv_start, &cte->table->timeout, cte); - } |