httpd: use full size of iobuf[] when piping CGI data
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
af6012a1a7
commit
1c356948f1
@ -259,18 +259,11 @@
|
|||||||
#if ENABLE_FEATURE_USE_SENDFILE
|
#if ENABLE_FEATURE_USE_SENDFILE
|
||||||
# include <sys/sendfile.h>
|
# include <sys/sendfile.h>
|
||||||
#endif
|
#endif
|
||||||
/* amount of buffering in a pipe */
|
|
||||||
#ifndef PIPE_BUF
|
|
||||||
# define PIPE_BUF 4096
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define DEBUG 0
|
#define DEBUG 0
|
||||||
|
|
||||||
#define IOBUF_SIZE 8192
|
#define IOBUF_SIZE 8192
|
||||||
#define MAX_HTTP_HEADERS_SIZE ((8*1024) - 16)
|
#define MAX_HTTP_HEADERS_SIZE (32*1024)
|
||||||
#if PIPE_BUF >= IOBUF_SIZE
|
|
||||||
# error "PIPE_BUF >= IOBUF_SIZE"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define HEADER_READ_TIMEOUT 60
|
#define HEADER_READ_TIMEOUT 60
|
||||||
|
|
||||||
@ -1413,10 +1406,10 @@ static NOINLINE void cgi_io_loop_and_exit(int fromCgi_rd, int toCgi_wr, int post
|
|||||||
* CGI may output a few first bytes and then wait
|
* CGI may output a few first bytes and then wait
|
||||||
* for POSTDATA without closing stdout.
|
* for POSTDATA without closing stdout.
|
||||||
* With full_read we may wait here forever. */
|
* With full_read we may wait here forever. */
|
||||||
count = safe_read(fromCgi_rd, rbuf + out_cnt, PIPE_BUF - 8);
|
count = safe_read(fromCgi_rd, rbuf + out_cnt, IOBUF_SIZE - 8);
|
||||||
if (count <= 0) {
|
if (count <= 0) {
|
||||||
/* eof (or error) and there was no "HTTP",
|
/* eof (or error) and there was no "HTTP",
|
||||||
* so write it, then write received data */
|
* send "HTTP/1.0 200 OK\r\n", then send received data */
|
||||||
if (out_cnt) {
|
if (out_cnt) {
|
||||||
full_write(STDOUT_FILENO, HTTP_200, sizeof(HTTP_200)-1);
|
full_write(STDOUT_FILENO, HTTP_200, sizeof(HTTP_200)-1);
|
||||||
full_write(STDOUT_FILENO, rbuf, out_cnt);
|
full_write(STDOUT_FILENO, rbuf, out_cnt);
|
||||||
@ -1454,7 +1447,7 @@ static NOINLINE void cgi_io_loop_and_exit(int fromCgi_rd, int toCgi_wr, int post
|
|||||||
out_cnt = -1; /* buffering off */
|
out_cnt = -1; /* buffering off */
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
count = safe_read(fromCgi_rd, rbuf, PIPE_BUF);
|
count = safe_read(fromCgi_rd, rbuf, IOBUF_SIZE);
|
||||||
if (count <= 0)
|
if (count <= 0)
|
||||||
break; /* eof (or error) */
|
break; /* eof (or error) */
|
||||||
}
|
}
|
||||||
|
@ -363,9 +363,6 @@
|
|||||||
#ifndef F_DUPFD_CLOEXEC
|
#ifndef F_DUPFD_CLOEXEC
|
||||||
# define F_DUPFD_CLOEXEC F_DUPFD
|
# define F_DUPFD_CLOEXEC F_DUPFD
|
||||||
#endif
|
#endif
|
||||||
#ifndef PIPE_BUF
|
|
||||||
# define PIPE_BUF 4096 /* amount of buffering in a pipe */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ENABLE_FEATURE_SH_EMBEDDED_SCRIPTS && !(ENABLE_ASH || ENABLE_SH_IS_ASH || ENABLE_BASH_IS_ASH)
|
#if ENABLE_FEATURE_SH_EMBEDDED_SCRIPTS && !(ENABLE_ASH || ENABLE_SH_IS_ASH || ENABLE_BASH_IS_ASH)
|
||||||
# include "embedded_scripts.h"
|
# include "embedded_scripts.h"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user