diff options
-rw-r--r-- | usr.sbin/hoststated/check_tcp.c | 18 | ||||
-rw-r--r-- | usr.sbin/hoststated/ssl.c | 21 | ||||
-rw-r--r-- | usr.sbin/relayd/check_tcp.c | 18 | ||||
-rw-r--r-- | usr.sbin/relayd/ssl.c | 21 |
4 files changed, 36 insertions, 42 deletions
diff --git a/usr.sbin/hoststated/check_tcp.c b/usr.sbin/hoststated/check_tcp.c index 010ad66fd18..2d480546c7a 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.16 2007/02/06 10:26:13 pyr Exp $ */ +/* $OpenBSD: check_tcp.c,v 1.17 2007/02/06 10:27:33 reyk Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org> @@ -124,7 +124,7 @@ tcp_write(int s, short event, void *arg) tcp_host_up(s, cte); else { close(s); - hce_notify_done(cte->host, "connect failed"); + hce_notify_done(cte->host, "tcp_write: connect failed"); } } @@ -138,7 +138,7 @@ tcp_host_up(int s, struct ctl_tcp_event *cte) if (cte->table->flags & F_SSL) break; close(s); - hce_notify_done(cte->host, "tcp_host_up: connect successfull"); + hce_notify_done(cte->host, "tcp_host_up: connect successful"); return; case CHECK_HTTP_CODE: cte->validate_read = NULL; @@ -242,9 +242,11 @@ tcp_read_buf(int s, short event, void *arg) close(cte->s); buf_free(cte->buf); if (cte->host->up == HOST_UP) - hce_notify_done(cte->host, "check succeeded"); + hce_notify_done(cte->host, + "tcp_read_buf: check succeeded"); else - hce_notify_done(cte->host, "check failed"); + hce_notify_done(cte->host, + "tcp_read_buf: check failed"); return; default: buf_add(cte->buf, rbuf, br); @@ -256,9 +258,11 @@ tcp_read_buf(int s, short event, void *arg) close(cte->s); buf_free(cte->buf); if (cte->host->up == HOST_UP) - hce_notify_done(cte->host, "check succeeded"); + hce_notify_done(cte->host, + "tcp_read_buf: check succeeded"); else - hce_notify_done(cte->host, "check failed"); + hce_notify_done(cte->host, + "tcp_read_buf: check failed"); return; } break; /* retry */ diff --git a/usr.sbin/hoststated/ssl.c b/usr.sbin/hoststated/ssl.c index 1068bc5b19f..7f23bea3040 100644 --- a/usr.sbin/hoststated/ssl.c +++ b/usr.sbin/hoststated/ssl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl.c,v 1.3 2007/02/06 10:06:55 reyk Exp $ */ +/* $OpenBSD: ssl.c,v 1.4 2007/02/06 10:27:33 reyk Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org> @@ -55,23 +55,19 @@ ssl_read(int s, short event, void *arg) hce_notify_done(cte->host, "ssl_read: timeout"); return; } - log_debug("ssl_read: event occurred"); bzero(rbuf, sizeof(rbuf)); ssl_err = 0; retry_flag = EV_READ; ret = SSL_read(cte->ssl, rbuf, sizeof(rbuf)); - if (ret <= 0) { ssl_err = SSL_get_error(cte->ssl, ret); switch (ssl_err) { case SSL_ERROR_WANT_READ: - log_debug("ssl_read: want read"); retry_flag = EV_READ; goto retry; case SSL_ERROR_WANT_WRITE: - log_debug("ssl_read: want read"); retry_flag = EV_WRITE; goto retry; case SSL_ERROR_ZERO_RETURN: /* FALLTHROUGH */ @@ -136,21 +132,17 @@ ssl_write(int s, short event, void *arg) return; } - log_debug("ssl_write: event occurred"); len = strlen(cte->table->sendbuf); retry_flag = EV_WRITE; ret = SSL_write(cte->ssl, cte->table->sendbuf, len); - if (ret <= 0) { ssl_err = SSL_get_error(cte->ssl, ret); switch (ssl_err) { case SSL_ERROR_WANT_READ: - log_debug("ssl_write: want read"); retry_flag = EV_READ; goto retry; case SSL_ERROR_WANT_WRITE: - log_debug("ssl_write: want write"); retry_flag = EV_WRITE; goto retry; default: @@ -192,16 +184,13 @@ ssl_connect(int s, short event, void *arg) retry_flag = ssl_err = 0; ret = SSL_connect(cte->ssl); - if (ret <= 0) { ssl_err = SSL_get_error(cte->ssl, ret); switch (ssl_err) { case SSL_ERROR_WANT_READ: - log_debug("ssl_connect: want read"); retry_flag = EV_READ; goto retry; case SSL_ERROR_WANT_WRITE: - log_debug("ssl_connect: want write"); retry_flag = EV_WRITE; goto retry; default: @@ -257,7 +246,10 @@ ssl_error(const char *where, const char *what) { unsigned long code; char errbuf[128]; - + extern int debug; + + if (!debug) + return; for (; (code = ERR_get_error()) != 0 ;) { ERR_error_string_n(code, errbuf, sizeof(errbuf)); log_debug("SSL library error: %s: %s: %s", where, what, errbuf); @@ -284,7 +276,8 @@ ssl_transaction(struct ctl_tcp_event *cte) cte->host->up = HOST_UNKNOWN; ssl_error(cte->host->name, "cannot set fd"); ssl_cleanup(cte); - hce_notify_done(cte->host, "cannot set SSL fd"); + hce_notify_done(cte->host, + "ssl_transaction: cannot set SSL fd"); return; } SSL_set_connect_state(cte->ssl); diff --git a/usr.sbin/relayd/check_tcp.c b/usr.sbin/relayd/check_tcp.c index 010ad66fd18..2d480546c7a 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.16 2007/02/06 10:26:13 pyr Exp $ */ +/* $OpenBSD: check_tcp.c,v 1.17 2007/02/06 10:27:33 reyk Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org> @@ -124,7 +124,7 @@ tcp_write(int s, short event, void *arg) tcp_host_up(s, cte); else { close(s); - hce_notify_done(cte->host, "connect failed"); + hce_notify_done(cte->host, "tcp_write: connect failed"); } } @@ -138,7 +138,7 @@ tcp_host_up(int s, struct ctl_tcp_event *cte) if (cte->table->flags & F_SSL) break; close(s); - hce_notify_done(cte->host, "tcp_host_up: connect successfull"); + hce_notify_done(cte->host, "tcp_host_up: connect successful"); return; case CHECK_HTTP_CODE: cte->validate_read = NULL; @@ -242,9 +242,11 @@ tcp_read_buf(int s, short event, void *arg) close(cte->s); buf_free(cte->buf); if (cte->host->up == HOST_UP) - hce_notify_done(cte->host, "check succeeded"); + hce_notify_done(cte->host, + "tcp_read_buf: check succeeded"); else - hce_notify_done(cte->host, "check failed"); + hce_notify_done(cte->host, + "tcp_read_buf: check failed"); return; default: buf_add(cte->buf, rbuf, br); @@ -256,9 +258,11 @@ tcp_read_buf(int s, short event, void *arg) close(cte->s); buf_free(cte->buf); if (cte->host->up == HOST_UP) - hce_notify_done(cte->host, "check succeeded"); + hce_notify_done(cte->host, + "tcp_read_buf: check succeeded"); else - hce_notify_done(cte->host, "check failed"); + hce_notify_done(cte->host, + "tcp_read_buf: check failed"); return; } break; /* retry */ diff --git a/usr.sbin/relayd/ssl.c b/usr.sbin/relayd/ssl.c index 1068bc5b19f..7f23bea3040 100644 --- a/usr.sbin/relayd/ssl.c +++ b/usr.sbin/relayd/ssl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl.c,v 1.3 2007/02/06 10:06:55 reyk Exp $ */ +/* $OpenBSD: ssl.c,v 1.4 2007/02/06 10:27:33 reyk Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org> @@ -55,23 +55,19 @@ ssl_read(int s, short event, void *arg) hce_notify_done(cte->host, "ssl_read: timeout"); return; } - log_debug("ssl_read: event occurred"); bzero(rbuf, sizeof(rbuf)); ssl_err = 0; retry_flag = EV_READ; ret = SSL_read(cte->ssl, rbuf, sizeof(rbuf)); - if (ret <= 0) { ssl_err = SSL_get_error(cte->ssl, ret); switch (ssl_err) { case SSL_ERROR_WANT_READ: - log_debug("ssl_read: want read"); retry_flag = EV_READ; goto retry; case SSL_ERROR_WANT_WRITE: - log_debug("ssl_read: want read"); retry_flag = EV_WRITE; goto retry; case SSL_ERROR_ZERO_RETURN: /* FALLTHROUGH */ @@ -136,21 +132,17 @@ ssl_write(int s, short event, void *arg) return; } - log_debug("ssl_write: event occurred"); len = strlen(cte->table->sendbuf); retry_flag = EV_WRITE; ret = SSL_write(cte->ssl, cte->table->sendbuf, len); - if (ret <= 0) { ssl_err = SSL_get_error(cte->ssl, ret); switch (ssl_err) { case SSL_ERROR_WANT_READ: - log_debug("ssl_write: want read"); retry_flag = EV_READ; goto retry; case SSL_ERROR_WANT_WRITE: - log_debug("ssl_write: want write"); retry_flag = EV_WRITE; goto retry; default: @@ -192,16 +184,13 @@ ssl_connect(int s, short event, void *arg) retry_flag = ssl_err = 0; ret = SSL_connect(cte->ssl); - if (ret <= 0) { ssl_err = SSL_get_error(cte->ssl, ret); switch (ssl_err) { case SSL_ERROR_WANT_READ: - log_debug("ssl_connect: want read"); retry_flag = EV_READ; goto retry; case SSL_ERROR_WANT_WRITE: - log_debug("ssl_connect: want write"); retry_flag = EV_WRITE; goto retry; default: @@ -257,7 +246,10 @@ ssl_error(const char *where, const char *what) { unsigned long code; char errbuf[128]; - + extern int debug; + + if (!debug) + return; for (; (code = ERR_get_error()) != 0 ;) { ERR_error_string_n(code, errbuf, sizeof(errbuf)); log_debug("SSL library error: %s: %s: %s", where, what, errbuf); @@ -284,7 +276,8 @@ ssl_transaction(struct ctl_tcp_event *cte) cte->host->up = HOST_UNKNOWN; ssl_error(cte->host->name, "cannot set fd"); ssl_cleanup(cte); - hce_notify_done(cte->host, "cannot set SSL fd"); + hce_notify_done(cte->host, + "ssl_transaction: cannot set SSL fd"); return; } SSL_set_connect_state(cte->ssl); |