Skip to content

Commit f3cec08

Browse files
committed
increase the internal post data buffer
This brings speedup and fixes issues with var parsing. Default BUFSIZ on Windows is 512 bytes which causes too much reallocation work.
1 parent 0bc3a74 commit f3cec08

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

main/php_variables.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,11 @@ static inline int add_post_vars(zval *arr, post_var_data_t *vars, zend_bool eof
310310
return SUCCESS;
311311
}
312312

313+
#ifdef PHP_WIN32
314+
#define SAPI_POST_HANDLER_BUFSIZ 16384
315+
#else
316+
# define SAPI_POST_HANDLER_BUFSIZ BUFSIZ
317+
#endif
313318
SAPI_API SAPI_POST_HANDLER_FUNC(php_std_post_handler)
314319
{
315320
zval *arr = (zval *) arg;
@@ -320,8 +325,8 @@ SAPI_API SAPI_POST_HANDLER_FUNC(php_std_post_handler)
320325
memset(&post_data, 0, sizeof(post_data));
321326

322327
while (!php_stream_eof(s)) {
323-
char buf[BUFSIZ] = {0};
324-
size_t len = php_stream_read(s, buf, BUFSIZ);
328+
char buf[SAPI_POST_HANDLER_BUFSIZ] = {0};
329+
size_t len = php_stream_read(s, buf, SAPI_POST_HANDLER_BUFSIZ);
325330

326331
if (len && len != (size_t) -1) {
327332
smart_str_appendl(&post_data.str, buf, len);
@@ -334,7 +339,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(php_std_post_handler)
334339
}
335340
}
336341

337-
if (len != BUFSIZ){
342+
if (len != SAPI_POST_HANDLER_BUFSIZ){
338343
break;
339344
}
340345
}
@@ -345,6 +350,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(php_std_post_handler)
345350
}
346351
}
347352
}
353+
#undef SAPI_POST_HANDLER_BUFSIZ
348354

349355
SAPI_API SAPI_INPUT_FILTER_FUNC(php_default_input_filter)
350356
{

0 commit comments

Comments
 (0)