This patch cleans up a lot of unneeded errors that fill up boa error log. Basically the patch is a must have for a production server. Another thing that this patch changes is the default umask of boa process, allowing logs to be access not only by owner of the file. diff -ur boa-0.94.14rc21/src/boa.c boa-0.94.14rc21-gf/src/boa.c --- boa-0.94.14rc21/src/boa.c 2007-07-05 18:29:41.000000000 +0300 +++ boa-0.94.14rc21-gf/src/boa.c 2007-07-05 18:29:42.000000000 +0300 @@ -56,7 +56,7 @@ /* set umask to u+rw, u-x, go-rwx */ /* according to the man page, umask always succeeds */ - umask(077); + umask(022); /* but first, update timestamp, because log_error_time uses it */ (void) time(¤t_time); diff -ur boa-0.94.14rc21/src/buffer.c boa-0.94.14rc21-gf/src/buffer.c --- boa-0.94.14rc21/src/buffer.c 2007-07-05 18:29:41.000000000 +0300 +++ boa-0.94.14rc21-gf/src/buffer.c 2007-07-05 18:50:43.000000000 +0300 @@ -222,14 +222,6 @@ return -1; /* request blocked at the pipe level, but keep going */ else { req->buffer_start = req->buffer_end = 0; - /* OK to disable if your logs get too big */ -#ifdef QUIET_DISCONNECT - if (errno != ECONNRESET && errno != EPIPE) -#endif - { - log_error_doc(req); - perror("buffer flush"); - } req->status = DEAD; req->buffer_end = 0; return -2; diff -ur boa-0.94.14rc21/src/defines.h boa-0.94.14rc21-gf/src/defines.h --- boa-0.94.14rc21/src/defines.h 2007-07-05 18:29:41.000000000 +0300 +++ boa-0.94.14rc21-gf/src/defines.h 2007-07-05 18:29:41.000000000 +0300 @@ -35,7 +35,7 @@ * filled with messages about client disconnects, etc... */ -/* #define QUIET_DISCONNECT 1 */ +#define QUIET_DISCONNECT 1 /***** Change this via the CGIPath configuration value in boa.conf *****/ #define DEFAULT_PATH "/bin:/usr/bin:/usr/local/bin" @@ -52,13 +52,13 @@ #define SOCKETBUF_SIZE 32768 #define CLIENT_STREAM_SIZE 8192 #define BUFFER_SIZE 4096 -#define MAX_HEADER_LENGTH 1024 +#define MAX_HEADER_LENGTH 8192 #define MIME_HASHTABLE_SIZE 47 #define ALIAS_HASHTABLE_SIZE 17 #define PASSWD_HASHTABLE_SIZE 47 -#define REQUEST_TIMEOUT 60 +#define REQUEST_TIMEOUT 30 #define MIME_TYPES_DEFAULT "/etc/mime.types" #define CGI_MIME_TYPE "application/x-httpd-cgi" diff -ur boa-0.94.14rc21/src/get.c boa-0.94.14rc21-gf/src/get.c --- boa-0.94.14rc21/src/get.c 2007-07-05 18:29:41.000000000 +0300 +++ boa-0.94.14rc21-gf/src/get.c 2007-07-05 18:50:14.000000000 +0300 @@ -470,16 +470,6 @@ return -1; /* request blocked at the pipe level, but keep going */ else { -#ifdef QUIET_DISCONNECT - if (errno != EPIPE) { -#else - if (1) { -#endif - log_error_doc(req); - /* Can generate lots of log entries, */ - perror("write"); - /* OK to disable if your logs get too big */ - } req->status = DEAD; return 0; } diff -ur boa-0.94.14rc21/src/log.c boa-0.94.14rc21-gf/src/log.c --- boa-0.94.14rc21/src/log.c 2007-07-05 18:29:41.000000000 +0300 +++ boa-0.94.14rc21-gf/src/log.c 2007-07-05 18:29:42.000000000 +0300 @@ -187,11 +187,13 @@ (req->logline ? req->logline : "(null)"), (req->pathname ? req->pathname : "(null)")); } else { - fprintf(stderr, "%s - - %srequest \"%s\" (\"%s\"): ", - req->remote_ip_addr, - get_commonlog_time(), - (req->logline ? req->logline : "(null)"), - (req->pathname ? req->pathname : "(null)")); + if (req->logline && req->pathname) { + fprintf(stderr, "%s - - %srequest \"%s\" (\"%s\"): ", + req->remote_ip_addr, + get_commonlog_time(), + (req->logline ? req->logline : "(null)"), + (req->pathname ? req->pathname : "(null)")); + } } errno = errno_save; diff -ur boa-0.94.14rc21/src/pipe.c boa-0.94.14rc21-gf/src/pipe.c --- boa-0.94.14rc21/src/pipe.c 2007-07-05 18:29:41.000000000 +0300 +++ boa-0.94.14rc21-gf/src/pipe.c 2007-07-05 18:51:57.000000000 +0300 @@ -75,8 +75,6 @@ return -1; /* request blocked at the pipe level, but keep going */ else { req->status = DEAD; - log_error_doc(req); - perror("pipe read"); return 0; } } @@ -149,8 +147,6 @@ return 1; else { req->status = DEAD; - log_error_doc(req); - perror("pipe write"); return 0; } } @@ -221,15 +217,6 @@ goto retrysendfile; } else { req->status = DEAD; -#ifdef QUIET_DISCONNECT - if (0) -#else - if (errno != EPIPE && errno != ECONNRESET) -#endif - { - log_error_doc(req); - perror("sendfile write"); - } } return 0; } else if (bytes_written == 0) { diff -ur boa-0.94.14rc21/src/poll.c boa-0.94.14rc21-gf/src/poll.c --- boa-0.94.14rc21/src/poll.c 2007-07-05 18:29:41.000000000 +0300 +++ boa-0.94.14rc21-gf/src/poll.c 2007-07-05 18:47:26.000000000 +0300 @@ -184,14 +184,10 @@ revents & POLLERR ? "POLLERR ":""); current->status = DEAD; } else if (time_since > REQUEST_TIMEOUT) { - log_error_doc(current); - fputs("connection timed out\n", stderr); current->status = TIMED_OUT; /* connection timed out */ } else if (current->kacount < ka_max && /* we *are* in a keepalive */ (time_since >= ka_timeout) && /* ka timeout has passed */ !current->logline) { /* haven't read anything yet */ - log_error_doc(current); - fputs("connection timed out\n", stderr); current->status = TIMED_OUT; /* connection timed out */ } else if (revents == 0) { /* still blocked */ pfd1[pfd_len].fd = pfds[current->pollfd_id].fd; diff -ur boa-0.94.14rc21/src/read.c boa-0.94.14rc21-gf/src/read.c --- boa-0.94.14rc21/src/read.c 2007-07-05 18:29:41.000000000 +0300 +++ boa-0.94.14rc21-gf/src/read.c 2007-07-05 18:57:03.000000000 +0300 @@ -62,8 +62,6 @@ uc = *check; if (uc != '\r' && uc != '\n' && uc != '\t' && (uc < 32 || uc > 127)) { - log_error_doc(req); - fprintf(stderr, "Illegal character (%d) in stream.\n", (unsigned int) uc); send_r_bad_request(req); return 0; } @@ -244,8 +242,6 @@ return 1; else if (errno == EAGAIN || errno == EWOULDBLOCK) /* request blocked */ return -1; - log_error_doc(req); - perror("header read"); /* don't need to save errno because log_error_doc does */ req->response_status = 400; return 0; } else if (bytes == 0) { @@ -257,11 +253,6 @@ * Ignore. */ ; - } else { -#ifndef QUIET_DISCONNECT - log_error_doc(req); - fputs("client unexpectedly closed connection.\n", stderr); -#endif } req->response_status = 400; return 0; @@ -329,7 +320,6 @@ if (errno == EWOULDBLOCK || errno == EAGAIN) { return -1; } else { - boa_perror(req, "read body"); req->response_status = 400; return 0; } @@ -393,10 +383,8 @@ /* 20010520 - Alfred Fluckiger */ /* No test was originally done in this case, which might */ /* lead to a "no space left on device" error. */ - boa_perror(req, "write body"); /* OK to disable if your logs get too big */ return 0; } else { - boa_perror(req, "write body"); /* OK to disable if your logs get too big */ return 0; } } diff -ur boa-0.94.14rc21/src/select.c boa-0.94.14rc21-gf/src/select.c --- boa-0.94.14rc21/src/select.c 2007-07-05 18:29:41.000000000 +0300 +++ boa-0.94.14rc21-gf/src/select.c 2007-07-05 18:47:17.000000000 +0300 @@ -164,12 +164,8 @@ if (current->kacount < ka_max && /* we *are* in a keepalive */ (time_since >= ka_timeout) && /* ka timeout */ !current->logline) { /* haven't read anything yet */ - log_error_doc(current); - fputs("connection timed out\n", stderr); current->status = TIMED_OUT; /* connection timed out */ } else if (time_since > REQUEST_TIMEOUT) { - log_error_doc(current); - fputs("connection timed out\n", stderr); current->status = TIMED_OUT; /* connection timed out */ } if (current->buffer_end && /* there is data to write */