Sat, 21 Jan 2017 16:40:59 +0100
improves sessionhandler logging
--- a/src/server/daemon/event.h Sat Jan 21 15:31:17 2017 +0100 +++ b/src/server/daemon/event.h Sat Jan 21 16:40:59 2017 +0100 @@ -54,6 +54,7 @@ int events; int poll; void *cookie; + int error; }; typedef struct event_handler_conf {
--- a/src/server/daemon/event_linux.c Sat Jan 21 15:31:17 2017 +0100 +++ b/src/server/daemon/event_linux.c Sat Jan 21 16:40:59 2017 +0100 @@ -108,9 +108,11 @@ if(!event->fn(ev, event)) { // event fn returned 0 -> remove event from epoll if(epoll_ctl(ep, EPOLL_CTL_DEL, event->object, NULL)) { + event->error = 1; log_ereport( LOG_FAILURE, - "epoll_ctl failed: %s", + "epoll_ctl failed: fd: %d error: %s", + event->object, strerror(errno)); }
--- a/src/server/daemon/httplistener.c Sat Jan 21 15:31:17 2017 +0100 +++ b/src/server/daemon/httplistener.c Sat Jan 21 16:40:59 2017 +0100 @@ -407,7 +407,19 @@ int ssl_ar = SSL_accept(ssl); if(ssl_ar <= 0) { int error = SSL_get_error(ssl, ssl_ar); - log_ereport(LOG_INFORM, "SSL accept error: %d", error); + char *errstr; + switch(error) { + default: errstr = "unknown"; break; + case SSL_ERROR_ZERO_RETURN: errstr = "SSL_ERROR_ZERO_RETURN"; break; + case SSL_ERROR_WANT_READ: errstr = "SSL_ERROR_WANT_READ"; break; + case SSL_ERROR_WANT_WRITE: errstr = "SSL_ERROR_WANT_WRITE"; break; + case SSL_ERROR_WANT_CONNECT: errstr = "SSL_ERROR_WANT_CONNECT"; break; + case SSL_ERROR_WANT_ACCEPT: errstr = "SSL_ERROR_WANT_ACCEPT"; break; + case SSL_ERROR_WANT_X509_LOOKUP: errstr = "SSL_ERROR_WANT_X509_LOOKUP"; break; + case SSL_ERROR_SYSCALL: errstr = "SSL_ERROR_SYSCALL"; break; + case SSL_ERROR_SSL: errstr = "SL_ERROR_SSL"; break; + } + log_ereport(LOG_VERBOSE, "SSL accept error[%d]: %s", error, errstr); free(conn); conn = NULL; close(clientfd);
--- a/src/server/daemon/sessionhandler.c Sat Jan 21 15:31:17 2017 +0100 +++ b/src/server/daemon/sessionhandler.c Sat Jan 21 16:40:59 2017 +0100 @@ -42,6 +42,7 @@ typedef struct _event_http_io { HTTPRequest *request; HttpParser *parser; + int error; } EventHttpIO; @@ -212,6 +213,7 @@ } io->request = request; io->parser = parser; + io->error = 0; /* * to start the request handling, we begin with a poll on the socket, @@ -222,6 +224,7 @@ event_handler_t *ev = ((EventSessionHandler*)handler)->eventhandler; event_t *event = malloc(sizeof(event_t)); + ZERO(event, sizeof(event_t)); event->fn = evt_request_input; event->finish = evt_request_finish; event->cookie = io; @@ -263,6 +266,7 @@ } event->finish = evt_request_error; + io->error = 1; return 0; } //fwrite(buf->inbuf + buf->pos, 1, r, stdout); @@ -274,6 +278,7 @@ // parse error fatal_error(request, 400); event->finish = evt_request_error; + io->error = 2; return 0; } else if(state == 1) { /* @@ -294,6 +299,7 @@ if (fcntl(request->connection->fd, F_SETFL, flags & ~O_NONBLOCK) != 0) { // just close the connection if fcntl fails event->finish = evt_request_error; + io->error = 3; return 0; } @@ -332,11 +338,15 @@ return 0; } -int evt_request_error(event_handler_t *h, event_t *event) { +int evt_request_error(event_handler_t *h, event_t *event) { EventHttpIO *io = event->cookie; HttpParser *parser = io->parser; HTTPRequest *request = io->request; + if(event->error) { + log_ereport(LOG_VERBOSE, "sessionhandler http io error: %d", io->error); + } + free(request->netbuf->inbuf); free(request->netbuf);