[721aaa]: sighttpd-stdinbuffersize.patch Maximize Restore History

Download this file

sighttpd-stdinbuffersize.patch    108 lines (92 with data), 3.3 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
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);