FreeBSD Bugzilla – Attachment 21347 Details for
Bug 37439
Alfred's Patches to thttpd port to use sendfile
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
file.shar
file.shar (text/plain), 5.44 KB, created by
Nick Johnson
on 2002-04-25 04:20:01 UTC
(
hide
)
Description:
file.shar
Filename:
MIME Type:
Creator:
Nick Johnson
Created:
2002-04-25 04:20:01 UTC
Size:
5.44 KB
patch
obsolete
># This is a shell archive. Save it in a file, remove anything before ># this line, and then unpack it by entering "sh file". Note, it may ># create directories; files and directories will be owned by you and ># have default permissions. ># ># This archive contains: ># ># Makefile.patch ># files/patch-ae ># files/patch-af ># files/patch-ag ># files/patch-ah ># files/patch-ai ># >echo x - Makefile.patch >sed 's/^X//' >Makefile.patch << 'END-of-Makefile.patch' >X--- Makefile.orig Wed Apr 24 22:39:26 2002 >X+++ Makefile Wed Apr 24 22:36:18 2002 >X@@ -15,6 +15,8 @@ >X DIST_SUBDIR= ${PORTNAME} >X EXTRACT_ONLY= ${DISTNAME}${EXTRACT_SUFX} >X >X+CFLAGS:= ${CFLAGS} -DUSE_SENDFILE=1 >X+ >X MAINTAINER= anders@FreeBSD.org >X >X IGNOREFILES= notes.html >END-of-Makefile.patch >echo x - files/patch-ae >sed 's/^X//' >files/patch-ae << 'END-of-files/patch-ae' >X--- libhttpd.c.orig Wed Nov 14 22:32:12 2001 >X+++ libhttpd.c Wed Apr 24 22:24:27 2002 >X@@ -3692,6 +3692,9 @@ >X httpd_send_err( hc, 500, err500title, "", err500form, hc->encodedurl ); >X return -1; >X } >X+#ifdef USE_SENDFILE >X+ hc->file_fd = *((int *) hc->file_address); >X+#endif >X send_mime( >X hc, 200, ok200title, hc->encodings, "", hc->type, hc->sb.st_size, >X hc->sb.st_mtime ); >END-of-files/patch-ae >echo x - files/patch-af >sed 's/^X//' >files/patch-af << 'END-of-files/patch-af' >X--- ./libhttpd.h Tue Jun 13 11:48:56 2000 >X+++ /usr/ports/www/thttpd/work/thttpd-2.20b/libhttpd.h Fri Apr 20 03:50:30 2001 >X@@ -133,6 +133,9 @@ >X struct stat sb; >X int conn_fd; >X char* file_address; >X+#ifdef USE_SENDFILE >X+ int file_fd; >X+#endif >X } httpd_conn; >X >X /* Methods. */ >END-of-files/patch-af >echo x - files/patch-ag >sed 's/^X//' >files/patch-ag << 'END-of-files/patch-ag' >X--- mmc.c.orig Fri Apr 13 21:02:15 2001 >X+++ mmc.c Wed Apr 24 22:28:57 2002 >X@@ -66,6 +66,9 @@ >X time_t ctime; >X int refcount; >X time_t reftime; >X+#ifdef USE_SENDFILE >X+ int fd; >X+#endif >X void* addr; >X unsigned int hash; >X int hash_idx; >X@@ -130,7 +133,11 @@ >X /* Yep. Just return the existing map */ >X ++m->refcount; >X m->reftime = now; >X+#ifdef USE_SENDFILE >X+ return(&m->fd); >X+#else >X return m->addr; >X+#endif >X } >X >X /* Open the file. */ >X@@ -175,7 +182,9 @@ >X m->addr = (void*) 1; /* arbitrary non-NULL address */ >X else >X { >X-#ifdef HAVE_MMAP >X+#ifdef USE_SENDFILE >X+ m->fd = fd; >X+#elif defined(HAVE_MMAP) >X /* Map the file into memory. */ >X m->addr = mmap( 0, m->size, PROT_READ, MAP_SHARED, fd, 0 ); >X if ( m->addr == (void*) -1 ) >X@@ -207,8 +216,9 @@ >X } >X #endif /* HAVE_MMAP */ >X } >X+#ifndef USE_SENDFILE >X (void) close( fd ); >X- >X+#endif /* !USE_SENDFILE */ >X /* Put the Map into the hash table. */ >X if ( add_hash( m ) < 0 ) >X { >X@@ -223,8 +233,12 @@ >X maps = m; >X ++map_count; >X >X+#ifdef USE_SENDFILE >X+ return (&m->fd); >X+#else >X /* And return the address. */ >X return m->addr; >X+#endif >X } >X >X >X@@ -309,7 +323,9 @@ >X m = *mm; >X if ( m->size != 0 ) >X { >X-#ifdef HAVE_MMAP >X+#ifdef USE_SENDFILE >X+ close(m->fd); >X+#elif defined(HAVE_MMAP) >X if ( munmap( m->addr, m->size ) < 0 ) >X syslog( LOG_ERR, "munmap - %m" ); >X #else /* HAVE_MMAP */ >END-of-files/patch-ag >echo x - files/patch-ah >sed 's/^X//' >files/patch-ah << 'END-of-files/patch-ah' >X--- ./thttpd.c Wed Sep 27 12:31:48 2000 >X+++ /usr/ports/www/thttpd/work/thttpd-2.20b/thttpd.c Fri Apr 20 03:50:30 2001 >X@@ -1366,12 +1366,45 @@ >X if ( hc->responselen == 0 ) >X { >X /* No, just write the file. */ >X+#ifdef USE_SENDFILE >X+ off_t sbytes; >X+ >X+ sz = sendfile( >X+ hc->file_fd, hc->conn_fd, c->bytes_sent, >X+ MIN( c->bytes_to_send - c->bytes_sent, c->limit ), >X+ NULL, &sbytes, 0 ); >X+ if (sz == -1 && errno == EAGAIN) >X+ sz = sbytes > 0 ? sbytes : -1; >X+ else if (sz == 0) >X+ sz = sbytes; >X+#else >X sz = write( >X hc->conn_fd, &(hc->file_address[c->bytes_sent]), >X MIN( c->bytes_to_send - c->bytes_sent, c->limit ) ); >X+#endif >X } >X else >X { >X+#ifdef USE_SENDFILE >X+ struct sf_hdtr sf; >X+ struct iovec iv; >X+ off_t sbytes; >X+ >X+ iv.iov_base = hc->response; >X+ iv.iov_len = hc->responselen; >X+ sf.headers = &iv; >X+ sf.hdr_cnt = 1; >X+ sf.trailers = NULL; >X+ sf.trl_cnt = 0; >X+ sz = sendfile( >X+ hc->file_fd, hc->conn_fd, c->bytes_sent, >X+ MIN( c->bytes_to_send - c->bytes_sent, c->limit ), >X+ &sf, &sbytes, 0 ); >X+ if (sz == -1 && errno == EAGAIN) >X+ sz = sbytes > 0 ? sbytes : -1; >X+ else if (sz == 0) >X+ sz = sbytes; >X+#else >X /* Yes. We'll combine headers and file into a single writev(), >X ** hoping that this generates a single packet. >X */ >X@@ -1382,6 +1415,7 @@ >X iv[1].iov_base = &(hc->file_address[c->bytes_sent]); >X iv[1].iov_len = MIN( c->bytes_to_send - c->bytes_sent, c->limit ); >X sz = writev( hc->conn_fd, iv, 2 ); >X+#endif >X } >X >X if ( sz == 0 || >END-of-files/patch-ah >echo x - files/patch-ai >sed 's/^X//' >files/patch-ai << 'END-of-files/patch-ai' >X--- version.h.orig Wed Nov 14 20:27:41 2001 >X+++ version.h Wed Apr 24 22:33:23 2002 >X@@ -3,7 +3,14 @@ >X #ifndef _VERSION_H_ >X #define _VERSION_H_ >X >X-#define SERVER_SOFTWARE "thttpd/2.22beta4 14nov2001" >X+#define SERVER_SOFTWARE_BASE "thttpd/2.22beta4 14nov2001" >X+ >X+#ifdef USE_SENDFILE >X+#define SERVER_SOFTWARE SERVER_SOFTWARE_BASE " (+FreeBSD sendfile)" >X+#else /* USE_SENDFILE */ >X+#define SERVER_SOFTWARE SERVER_SOFTWARE_BASE >X+#endif >X+ >X #define SERVER_ADDRESS "http://www.acme.com/software/thttpd/" >X >X #endif /* _VERSION_H_ */ >END-of-files/patch-ai >exit
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 37439
: 21347