ports/91843: [patch] thttpd with USE_SENDFILE generates ENOTCONN noise in syslog

Ben Goetter goetter at mazama.net
Sun Jan 15 22:40:10 UTC 2006


>Number:         91843
>Category:       ports
>Synopsis:       [patch] thttpd with USE_SENDFILE generates ENOTCONN noise in syslog
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jan 15 22:40:03 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator:     Ben Goetter
>Release:        FreeBSD 5.4-RELEASE-p8
>Organization:
>Environment:
FreeBSD bgkh-household.seattle.mazama.net 5.4-RELEASE-p8 FreeBSD 5.4-RELEASE-p8 #1: Thu Dec 22 11:49:41 PST 2005     goetter at bgkh-household.seattle.mazama.net:/usr/obj/usr/src/sys/BGKH-HOUSEHOLD  i386
>Description:
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.
>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, ...)
>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
>       )

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list