Bug 91843

Summary: [patch] thttpd with USE_SENDFILE generates ENOTCONN noise in syslog
Product: Ports & Packages Reporter: Ben Goetter <goetter>
Component: Individual Port(s)Assignee: Anders Nordby <anders>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   

Description Ben Goetter 2006-01-15 22:40:03 UTC
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, ...)
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2006-01-15 22:45:14 UTC
Responsible Changed
From-To: freebsd-ports-bugs->anders

Over to maintainer
Comment 2 dfilter service freebsd_committer freebsd_triage 2007-06-17 20:37:17 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"
Comment 3 Anders Nordby freebsd_committer freebsd_triage 2007-06-17 20:40:01 UTC
State Changed
From-To: open->closed

Committed (with whitespace-changes removed), thanks!