diff options
author | Dmitry Stogov <dmitry@zend.com> | 2014-07-07 19:21:23 +0400 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2014-07-07 19:21:23 +0400 |
commit | bce6a36c8a13d718cc308e4e48724c799863459a (patch) | |
tree | 26f2a9eab1d102dc5c9d9bb7ec54280d6ae17c01 /main/streams/memory.c | |
parent | 477bd49ccab2a10c421a51f512d593251ef7adef (diff) | |
parent | f0499b86a8b83204eab14e25eb7cb15536f9e69f (diff) | |
download | php-git-bce6a36c8a13d718cc308e4e48724c799863459a.tar.gz |
Merge branch 'master' into test
* master: (48 commits)
change locale - looks like not everybody has sl_SI
Fix bug #66921 - Wrong argument type hint for function intltz_from_date_time_zone
fix format
Fix bug #67052 (NumberFormatter::parse() resets LC_NUMERIC setting)
Make sure the generator script also creates a newline at the end of file
Add newline at end of file to prevent compilation warning
Fix handling of session user module custom handlers.
Reference bug report instead of github issue in NEWS file
add more exts for Travis
Update NEWS
Fix phpdbg.1 man page installation when build != src directory
BFN for bug #67551 (php://input temp file will be located in sys_temp_dir instead of upload_tmp_dir)
reorder
restore API compatibility
finish
refactor php_stream_temp_create{,_ex} and use it for the php://input stream
refactor _php_stream_fopen_{temporary_,tmp}file()
fix length overflow of HTTP_RAW_POST_DATA
Update NEWS
Fixed bug #67215 (php-cgi work with opcache, may be segmentation fault happen)
...
Conflicts:
ext/opcache/zend_accelerator_util_funcs.c
ext/session/mod_user.c
ext/spl/spl_array.c
ext/spl/spl_dllist.c
ext/standard/file.c
ext/standard/streamsfuncs.c
ext/standard/string.c
main/streams/memory.c
Diffstat (limited to 'main/streams/memory.c')
-rw-r--r-- | main/streams/memory.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/main/streams/memory.c b/main/streams/memory.c index 89bd59e215..5da0c8decd 100644 --- a/main/streams/memory.c +++ b/main/streams/memory.c @@ -352,6 +352,7 @@ typedef struct { size_t smax; int mode; zval meta; + char* tmpdir; } php_stream_temp_data; @@ -369,7 +370,7 @@ static size_t php_stream_temp_write(php_stream *stream, const char *buf, size_t char *membuf = php_stream_memory_get_buffer(ts->innerstream, &memsize); if (memsize + count >= ts->smax) { - php_stream *file = php_stream_fopen_tmpfile(); + php_stream *file = php_stream_fopen_temporary_file(ts->tmpdir, "php", NULL); php_stream_write(file, membuf, memsize); php_stream_free_enclosed(ts->innerstream, PHP_STREAM_FREE_CLOSE); ts->innerstream = file; @@ -418,6 +419,10 @@ static int php_stream_temp_close(php_stream *stream, int close_handle TSRMLS_DC) zval_ptr_dtor(&ts->meta); + if (ts->tmpdir) { + efree(ts->tmpdir); + } + efree(ts); return ret; @@ -545,8 +550,8 @@ PHPAPI php_stream_ops php_stream_temp_ops = { /* }}} */ -/* {{{ _php_stream_temp_create */ -PHPAPI php_stream *_php_stream_temp_create(int mode, size_t max_memory_usage STREAMS_DC TSRMLS_DC) +/* {{{ _php_stream_temp_create_ex */ +PHPAPI php_stream *_php_stream_temp_create_ex(int mode, size_t max_memory_usage, const char *tmpdir STREAMS_DC TSRMLS_DC) { php_stream_temp_data *self; php_stream *stream; @@ -555,6 +560,9 @@ PHPAPI php_stream *_php_stream_temp_create(int mode, size_t max_memory_usage STR self->smax = max_memory_usage; self->mode = mode; ZVAL_UNDEF(&self->meta); + if (tmpdir) { + self->tmpdir = estrdup(tmpdir); + } stream = php_stream_alloc_rel(&php_stream_temp_ops, self, 0, mode & TEMP_STREAM_READONLY ? "rb" : "w+b"); stream->flags |= PHP_STREAM_FLAG_NO_BUFFER; self->innerstream = php_stream_memory_create_rel(mode); @@ -564,6 +572,12 @@ PHPAPI php_stream *_php_stream_temp_create(int mode, size_t max_memory_usage STR } /* }}} */ +/* {{{ _php_stream_temp_create */ +PHPAPI php_stream *_php_stream_temp_create(int mode, size_t max_memory_usage STREAMS_DC TSRMLS_DC) +{ + return php_stream_temp_create_ex(mode, max_memory_usage, NULL); +} +/* }}} */ /* {{{ _php_stream_temp_open */ PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, char *buf, size_t length STREAMS_DC TSRMLS_DC) |