Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Diff of /sighttpd-stdinbuffersize.patch [000000] .. [4e2dfa] Maximize Restore

  Switch to side-by-side view

--- a
+++ b/sighttpd-stdinbuffersize.patch
@@ -0,0 +1,107 @@
+diff -rupN sighttpd-1.1.0-before2ndbufferpatch//src/fdstream.c sighttpd-1.1.0/src/fdstream.c
+--- sighttpd-1.1.0-before2ndbufferpatch//src/fdstream.c	2013-09-27 17:46:05.231951459 +0200
++++ sighttpd-1.1.0/src/fdstream.c	2013-09-27 18:03:06.363449138 +0200
+@@ -7,6 +7,7 @@
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <fcntl.h>
++#include <errno.h>
+ #include <unistd.h> /* STDIN_FILENO */
+ 
+ #include "http-reqline.h"
+@@ -90,7 +91,7 @@ fdstream_delete (void * data)
+ }
+ 
+ struct resource *
+-fdstream_resource (const char * path, int fd, const char * content_type)
++fdstream_resource (const char * path, int fd, const char * content_type, size_t len)
+ {
+ 	struct fdstream * st;
+ 
+@@ -110,7 +111,7 @@ fdstream_resource (const char * path, in
+ 		return NULL;
+ 	}
+ 
+-	st->stream = stream_open (fd);
++	st->stream = stream_open (fd, len);
+ 	if (st->stream == NULL) {
+ 		free (st);
+ 		free ((char *)st->path);
+@@ -125,11 +126,12 @@ struct resource *
+ fdstream_resource_open (const char * urlpath, const char * filepath, const char * content_type)
+ {
+         int fd;
++	size_t len = 4096*16*32;
+ 
+         if ((fd = open (filepath, O_RDONLY)) == -1)
+ 		return NULL;
+ 
+-	return fdstream_resource (urlpath, fd, content_type);
++	return fdstream_resource (urlpath, fd, content_type, len);
+ }
+ 
+ list_t *
+@@ -138,17 +140,32 @@ fdstream_resources (Dictionary * config)
+ 	list_t * l;
+ 	const char * path;
+ 	const char * ctype;
++	const char * buffersize;
++	size_t len;
+ 	struct resource * r;
+ 
+ 	l = list_new();
+ 
+ 	path = dictionary_lookup (config, "Path");
+ 	ctype = dictionary_lookup (config, "Type");
++	buffersize = dictionary_lookup (config, "BufferSize");
+ 
+ 	if (!ctype) ctype = DEFAULT_CONTENT_TYPE;
+ 
++	if(!buffersize) 
++	{
++		len = 4096*16*32;
++	} else { 
++		errno = 0;
++		len = (size_t)strtol(buffersize,NULL,10);
++		if(errno == ERANGE)
++			len = 4096*16*32;
++		if(len > (4096*4)) len = 4096*4;
++		len += len % (4096*4);
++	} 
++
+ 	if (path) {
+-		if ((r = fdstream_resource (path, STDIN_FILENO, ctype)) != NULL)
++		if ((r = fdstream_resource (path, STDIN_FILENO, ctype, len)) != NULL)
+ 			l = list_append (l, r);
+ 	}
+ 
+diff -rupN sighttpd-1.1.0-before2ndbufferpatch//src/stream.c sighttpd-1.1.0/src/stream.c
+--- sighttpd-1.1.0-before2ndbufferpatch//src/stream.c	2013-09-27 17:46:05.231951459 +0200
++++ sighttpd-1.1.0/src/stream.c	2013-09-27 17:47:22.782065204 +0200
+@@ -47,12 +47,12 @@ stream_writer (struct stream * stream)
+ }
+ 
+ struct stream *
+-stream_open (int fd)
++stream_open (int fd, size_t len)
+ {
+         struct stream * stream;
+ 	pthread_t child;
+         unsigned char * data;
+-        size_t len = 4096*16*32;
++
+ 
+         if ((stream = malloc (sizeof(*stream))) == NULL)
+                 return NULL;
+diff -rupN sighttpd-1.1.0-before2ndbufferpatch//src/stream.h sighttpd-1.1.0/src/stream.h
+--- sighttpd-1.1.0-before2ndbufferpatch//src/stream.h	2013-09-27 17:46:05.231951459 +0200
++++ sighttpd-1.1.0/src/stream.h	2013-09-27 17:47:45.642098727 +0200
+@@ -10,7 +10,7 @@ struct stream {
+         struct ringbuffer rb;
+ };
+ 
+-struct stream * stream_open (int fd);
++struct stream * stream_open (int fd, size_t len);
+ void stream_close (struct stream * stream);
+ params_t * stream_append_headers (params_t * response_headers, struct stream * stream);
+ int stream_stream_body (int fd, struct stream * stream);