sendfile(2) returns ENOTCONN when a client drops a connection. thttpd with USE_SENDFILE is syslogging every such drop. This generates a lot of spurious traffic in the log. thttpd already filters ECONNRESET returns from write/writev() as uninteresting. If USE_SENDFILE, it should likewise filter ENOTCONN returns. Fix: See the last eight lines of the following diff: [goetter:/usr/ports/www/thttpd/work/thttpd-2.25b]$ diff thttpd.c.orig thttpd.c 1725a1726,1737 > #ifdef USE_SENDFILE > off_t sbytes; > > sz = sendfile( > hc->file_fd, hc->conn_fd, c->next_byte_index, > MIN( c->end_byte_index - c->next_byte_index, max_bytes ), > NULL, &sbytes, 0 ); > if (sz == -1 && errno == EAGAIN) > sz = sbytes > 0 ? sbytes : -1; > else if (sz == 0) > sz = sbytes; > #else 1728a1741 > #endif 1731a1745,1764 > #ifdef USE_SENDFILE > struct sf_hdtr sf; > struct iovec iv; > off_t sbytes; > > iv.iov_base = hc->response; > iv.iov_len = hc->responselen; > sf.headers = &iv; > sf.hdr_cnt = 1; > sf.trailers = NULL; > sf.trl_cnt = 0; > sz = sendfile( > hc->file_fd, hc->conn_fd, c->next_byte_index, > MIN( c->end_byte_index - c->next_byte_index, max_bytes ), > &sf, &sbytes, 0 ); > if (sz == -1 && errno == EAGAIN) > sz = sbytes > 0 ? sbytes : -1; > else if (sz == 0) > sz = sbytes; > #else 1741a1775 > #endif 1789c1823,1827 < if ( errno != EPIPE && errno != EINVAL && errno != ECONNRESET ) --- > if ( errno != EPIPE && errno != EINVAL && errno != ECONNRESET > #ifdef USE_SENDFILE > && errno != ENOTCONN > #endif > ) How-To-Repeat: Let a spider (e.g. msnbot) crawl a directory containing a number of large application/octet-stream objects. Peruse the resulting log entries (/var/log/thttpd.log, console, ...)
Responsible Changed From-To: freebsd-ports-bugs->anders Over to maintainer
anders 2007-06-17 19:37:11 UTC FreeBSD ports repository Modified files: www/thttpd Makefile www/thttpd/files patch-thttpd.c Log: Do not log sendfile calls that return with ENOTCONN when USE_SENDFILE is used, it is not interesting. Bump PORTREVISION. PR: ports/91843 Submitted by: Ben Goetter <goetter@mazama.net> Revision Changes Path 1.41 +1 -1 ports/www/thttpd/Makefile 1.4 +15 -2 ports/www/thttpd/files/patch-thttpd.c _______________________________________________ cvs-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/cvs-all To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
State Changed From-To: open->closed Committed (with whitespace-changes removed), thanks!