From nobody@FreeBSD.org  Sun Jan 15 22:35:14 2006
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 0BC4916A41F
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 15 Jan 2006 22:35:14 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id AB0E243D45
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 15 Jan 2006 22:35:13 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id k0FMZDl3058978
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 15 Jan 2006 22:35:13 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id k0FMZDwa058977;
	Sun, 15 Jan 2006 22:35:13 GMT
	(envelope-from nobody)
Message-Id: <200601152235.k0FMZDwa058977@www.freebsd.org>
Date: Sun, 15 Jan 2006 22:35:13 GMT
From: Ben Goetter <goetter@mazama.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] thttpd with USE_SENDFILE generates ENOTCONN noise in syslog
X-Send-Pr-Version: www-2.3

>Number:         91843
>Category:       ports
>Synopsis:       [patch] thttpd with USE_SENDFILE generates ENOTCONN noise in syslog
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    anders
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jan 15 22:40:03 GMT 2006
>Closed-Date:    Sun Jun 17 19:40:56 GMT 2007
>Last-Modified:  Sun Jun 17 19:50:02 GMT 2007
>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@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:
Responsible-Changed-From-To: freebsd-ports-bugs->anders 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Sun Jan 15 22:45:14 UTC 2006 
Responsible-Changed-Why:  
Over to maintainer 

http://www.freebsd.org/cgi/query-pr.cgi?pr=91843 
State-Changed-From-To: open->closed 
State-Changed-By: anders 
State-Changed-When: Sun Jun 17 19:40:01 UTC 2007 
State-Changed-Why:  
Committed (with whitespace-changes removed), thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=91843 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/91843: commit references a PR
Date: Sun, 17 Jun 2007 19:37:17 +0000 (UTC)

 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"
 
>Unformatted:
