diff options
| author | Ondřej Surý <ondrej@sury.org> | 2010-03-09 11:57:54 +0100 |
|---|---|---|
| committer | Ondřej Surý <ondrej@sury.org> | 2010-03-09 11:57:54 +0100 |
| commit | 855a09f4eded707941180c9d90acd17c25e29447 (patch) | |
| tree | a40947efaa9876f31b6ee3956c3f3775768143bb /main/streams | |
| parent | c852c28a88fccf6e34a2cb091fdfa72bce2b59c7 (diff) | |
| download | php-upstream/5.3.2.tar.gz | |
Imported Upstream version 5.3.2upstream/5.3.2
Diffstat (limited to 'main/streams')
| -rw-r--r-- | main/streams/cast.c | 22 | ||||
| -rw-r--r-- | main/streams/filter.c | 4 | ||||
| -rwxr-xr-x | main/streams/glob_wrapper.c | 4 | ||||
| -rw-r--r-- | main/streams/memory.c | 4 | ||||
| -rw-r--r-- | main/streams/mmap.c | 4 | ||||
| -rw-r--r-- | main/streams/php_stream_context.h | 4 | ||||
| -rw-r--r-- | main/streams/php_stream_filter_api.h | 4 | ||||
| -rwxr-xr-x | main/streams/php_stream_glob_wrapper.h | 4 | ||||
| -rw-r--r-- | main/streams/php_stream_mmap.h | 4 | ||||
| -rw-r--r-- | main/streams/php_stream_plain_wrapper.h | 4 | ||||
| -rw-r--r-- | main/streams/php_stream_transport.h | 4 | ||||
| -rw-r--r-- | main/streams/php_stream_userspace.h | 4 | ||||
| -rw-r--r-- | main/streams/php_streams_int.h | 9 | ||||
| -rw-r--r-- | main/streams/plain_wrapper.c | 48 | ||||
| -rwxr-xr-x | main/streams/streams.c | 29 | ||||
| -rw-r--r-- | main/streams/transports.c | 6 | ||||
| -rw-r--r-- | main/streams/userspace.c | 4 | ||||
| -rw-r--r-- | main/streams/xp_socket.c | 12 |
18 files changed, 107 insertions, 67 deletions
diff --git a/main/streams/cast.c b/main/streams/cast.c index f42494601..2e9ad810c 100644 --- a/main/streams/cast.c +++ b/main/streams/cast.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | + | Copyright (c) 1997-2010 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: cast.c 279036 2009-04-20 08:28:44Z pajoye $ */ +/* $Id: cast.c 294462 2010-02-03 20:49:03Z pajoye $ */ #define _GNU_SOURCE #include "php.h" @@ -30,7 +30,7 @@ #include "php_streams_int.h" /* Under BSD, emulate fopencookie using funopen */ -#if HAVE_FUNOPEN +#if defined(HAVE_FUNOPEN) && !defined(HAVE_FOPENCOOKIE) typedef struct { int (*reader)(void *, char *, int); int (*writer)(void *, const char *, int); @@ -43,13 +43,14 @@ FILE *fopencookie(void *cookie, const char *mode, COOKIE_IO_FUNCTIONS_T *funcs) return funopen(cookie, funcs->reader, funcs->writer, funcs->seeker, funcs->closer); } # define HAVE_FOPENCOOKIE 1 +# define PHP_EMULATE_FOPENCOOKIE 1 # define PHP_STREAM_COOKIE_FUNCTIONS &stream_cookie_functions -#elif HAVE_FOPENCOOKIE +#elif defined(HAVE_FOPENCOOKIE) # define PHP_STREAM_COOKIE_FUNCTIONS stream_cookie_functions #endif /* {{{ STDIO with fopencookie */ -#if HAVE_FUNOPEN +#if defined(PHP_EMULATE_FOPENCOOKIE) /* use our fopencookie emulation */ static int stream_cookie_reader(void *cookie, char *buffer, int size) { @@ -80,8 +81,7 @@ static int stream_cookie_closer(void *cookie) stream->fclose_stdiocast = PHP_STREAM_FCLOSE_NONE; return php_stream_close(stream); } - -#elif HAVE_FOPENCOOKIE +#elif defined(HAVE_FOPENCOOKIE) static ssize_t stream_cookie_reader(void *cookie, char *buffer, size_t size) { ssize_t ret; @@ -96,7 +96,7 @@ static ssize_t stream_cookie_writer(void *cookie, const char *buffer, size_t siz return php_stream_write(((php_stream *)cookie), (char *)buffer, size); } -#ifdef COOKIE_SEEKER_USES_OFF64_T +# ifdef COOKIE_SEEKER_USES_OFF64_T static int stream_cookie_seeker(void *cookie, __off64_t *position, int whence) { TSRMLS_FETCH(); @@ -107,13 +107,13 @@ static int stream_cookie_seeker(void *cookie, __off64_t *position, int whence) return -1; return 0; } -#else +# else static int stream_cookie_seeker(void *cookie, off_t position, int whence) { TSRMLS_FETCH(); return php_stream_seek((php_stream *)cookie, position, whence); } -#endif +# endif static int stream_cookie_closer(void *cookie) { @@ -124,7 +124,7 @@ static int stream_cookie_closer(void *cookie) stream->fclose_stdiocast = PHP_STREAM_FCLOSE_NONE; return php_stream_close(stream); } -#endif /* elif HAVE_FOPENCOOKIE */ +#endif /* elif defined(HAVE_FOPENCOOKIE) */ #if HAVE_FOPENCOOKIE static COOKIE_IO_FUNCTIONS_T stream_cookie_functions = diff --git a/main/streams/filter.c b/main/streams/filter.c index e08efe643..02aaf644f 100644 --- a/main/streams/filter.c +++ b/main/streams/filter.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | + | Copyright (c) 1997-2010 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: filter.c 273087 2009-01-08 17:01:58Z lbarnaud $ */ +/* $Id: filter.c 293036 2010-01-03 09:23:27Z sebastian $ */ #include "php.h" #include "php_globals.h" diff --git a/main/streams/glob_wrapper.c b/main/streams/glob_wrapper.c index 955aa806f..cf5976738 100755 --- a/main/streams/glob_wrapper.c +++ b/main/streams/glob_wrapper.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | + | Copyright (c) 1997-2010 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: glob_wrapper.c 272370 2008-12-31 11:15:49Z sebastian $ */ +/* $Id: glob_wrapper.c 293036 2010-01-03 09:23:27Z sebastian $ */ #include "php.h" #include "php_streams_int.h" diff --git a/main/streams/memory.c b/main/streams/memory.c index 062524649..099194719 100644 --- a/main/streams/memory.c +++ b/main/streams/memory.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | + | Copyright (c) 1997-2010 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: memory.c 289437 2009-10-09 17:45:03Z pajoye $ */ +/* $Id: memory.c 293036 2010-01-03 09:23:27Z sebastian $ */ #define _GNU_SOURCE #include "php.h" diff --git a/main/streams/mmap.c b/main/streams/mmap.c index 78d8a66ea..2e75aad8a 100644 --- a/main/streams/mmap.c +++ b/main/streams/mmap.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | + | Copyright (c) 1997-2010 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mmap.c 280678 2009-05-17 14:58:10Z lbarnaud $ */ +/* $Id: mmap.c 293036 2010-01-03 09:23:27Z sebastian $ */ /* Memory Mapping interface for streams */ #include "php.h" diff --git a/main/streams/php_stream_context.h b/main/streams/php_stream_context.h index a45808b25..fb244266e 100644 --- a/main/streams/php_stream_context.h +++ b/main/streams/php_stream_context.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | + | Copyright (c) 1997-2010 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_stream_context.h 272370 2008-12-31 11:15:49Z sebastian $ */ +/* $Id: php_stream_context.h 293036 2010-01-03 09:23:27Z sebastian $ */ /* Stream context and status notification related definitions */ diff --git a/main/streams/php_stream_filter_api.h b/main/streams/php_stream_filter_api.h index 4f1477008..7eb36935c 100644 --- a/main/streams/php_stream_filter_api.h +++ b/main/streams/php_stream_filter_api.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | + | Copyright (c) 1997-2010 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_stream_filter_api.h 273087 2009-01-08 17:01:58Z lbarnaud $ */ +/* $Id: php_stream_filter_api.h 293036 2010-01-03 09:23:27Z sebastian $ */ /* The filter API works on the principle of "Bucket-Brigades". This is * partially inspired by the Apache 2 method of doing things, although diff --git a/main/streams/php_stream_glob_wrapper.h b/main/streams/php_stream_glob_wrapper.h index 63b4cf076..67fd2dd7e 100755 --- a/main/streams/php_stream_glob_wrapper.h +++ b/main/streams/php_stream_glob_wrapper.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | + | Copyright (c) 1997-2010 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_stream_glob_wrapper.h 272370 2008-12-31 11:15:49Z sebastian $ */ +/* $Id: php_stream_glob_wrapper.h 293036 2010-01-03 09:23:27Z sebastian $ */ PHPAPI extern php_stream_wrapper php_glob_stream_wrapper; PHPAPI extern php_stream_ops php_glob_stream_ops; diff --git a/main/streams/php_stream_mmap.h b/main/streams/php_stream_mmap.h index a3a2dbf6c..625eae01c 100644 --- a/main/streams/php_stream_mmap.h +++ b/main/streams/php_stream_mmap.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | + | Copyright (c) 1997-2010 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_stream_mmap.h 280678 2009-05-17 14:58:10Z lbarnaud $ */ +/* $Id: php_stream_mmap.h 293036 2010-01-03 09:23:27Z sebastian $ */ /* Memory Mapping interface for streams. * The intention is to provide a uniform interface over the most common diff --git a/main/streams/php_stream_plain_wrapper.h b/main/streams/php_stream_plain_wrapper.h index 36031719b..a6532872b 100644 --- a/main/streams/php_stream_plain_wrapper.h +++ b/main/streams/php_stream_plain_wrapper.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | + | Copyright (c) 1997-2010 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_stream_plain_wrapper.h 272370 2008-12-31 11:15:49Z sebastian $ */ +/* $Id: php_stream_plain_wrapper.h 293036 2010-01-03 09:23:27Z sebastian $ */ /* definitions for the plain files wrapper */ diff --git a/main/streams/php_stream_transport.h b/main/streams/php_stream_transport.h index ec32b1eb6..1cc378690 100644 --- a/main/streams/php_stream_transport.h +++ b/main/streams/php_stream_transport.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | + | Copyright (c) 1997-2010 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_stream_transport.h 275024 2009-02-02 09:41:46Z pajoye $ */ +/* $Id: php_stream_transport.h 293036 2010-01-03 09:23:27Z sebastian $ */ #ifdef PHP_WIN32 #include "config.w32.h" #include <Ws2tcpip.h> diff --git a/main/streams/php_stream_userspace.h b/main/streams/php_stream_userspace.h index 625c22b21..7147a4b0e 100644 --- a/main/streams/php_stream_userspace.h +++ b/main/streams/php_stream_userspace.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | + | Copyright (c) 1997-2010 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_stream_userspace.h 272370 2008-12-31 11:15:49Z sebastian $ */ +/* $Id: php_stream_userspace.h 293036 2010-01-03 09:23:27Z sebastian $ */ /* for user-space streams */ diff --git a/main/streams/php_streams_int.h b/main/streams/php_streams_int.h index b0a1f3327..113c518aa 100644 --- a/main/streams/php_streams_int.h +++ b/main/streams/php_streams_int.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | + | Copyright (c) 1997-2010 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_streams_int.h 272370 2008-12-31 11:15:49Z sebastian $ */ +/* $Id: php_streams_int.h 293036 2010-01-03 09:23:27Z sebastian $ */ #if ZEND_DEBUG @@ -49,7 +49,10 @@ #define CHUNK_SIZE 8192 #ifdef PHP_WIN32 -#define EWOULDBLOCK WSAEWOULDBLOCK +# ifdef EWOULDBLOCK +# undef EWOULDBLOCK +# endif +# define EWOULDBLOCK WSAEWOULDBLOCK #endif #ifndef S_ISREG diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index 549d38292..e7642d9d4 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | + | Copyright (c) 1997-2010 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: plain_wrapper.c 290578 2009-11-12 15:05:03Z johannes $ */ +/* $Id: plain_wrapper.c 295417 2010-02-23 15:04:29Z pajoye $ */ #include "php.h" #include "php_globals.h" @@ -39,6 +39,9 @@ #include "SAPI.h" #include "php_streams_int.h" +#ifdef PHP_WIN32 +# include "win32/winutil.h" +#endif #define php_stream_fopen_from_fd_int(fd, mode, persistent_id) _php_stream_fopen_from_fd_int((fd), (mode), (persistent_id) STREAMS_CC TSRMLS_CC) #define php_stream_fopen_from_fd_int_rel(fd, mode, persistent_id) _php_stream_fopen_from_fd_int((fd), (mode), (persistent_id) STREAMS_REL_CC TSRMLS_CC) @@ -387,9 +390,6 @@ static int php_stdiop_close(php_stream *stream, int close_handle TSRMLS_DC) #endif if (close_handle) { - if (data->lock_flag != LOCK_UN) { - php_stream_lock(stream, LOCK_UN); - } if (data->file) { if (data->is_process_pipe) { errno = 0; @@ -866,6 +866,10 @@ static php_stream *php_plain_files_dir_opener(php_stream_wrapper *wrapper, char dir = VCWD_OPENDIR(path); #ifdef PHP_WIN32 + if (!dir) { + php_win32_docref2_from_error(GetLastError(), path, path TSRMLS_CC); + } + if (dir && dir->finished) { closedir(dir); dir = NULL; @@ -1063,6 +1067,17 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, char *url_from, c return 0; } +#ifdef PHP_WIN32 + if (!php_win32_check_trailing_space(url_from, strlen(url_from))) { + php_win32_docref2_from_error(ERROR_INVALID_NAME, url_from, url_to TSRMLS_CC); + return 0; + } + if (!php_win32_check_trailing_space(url_to, strlen(url_to))) { + php_win32_docref2_from_error(ERROR_INVALID_NAME, url_from, url_to TSRMLS_CC); + return 0; + } +#endif + if ((p = strstr(url_from, "://")) != NULL) { url_from = p + 3; } @@ -1083,12 +1098,13 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, char *url_from, c ret = VCWD_RENAME(url_from, url_to); if (ret == -1) { -#ifdef EXDEV +#ifndef PHP_WIN32 +# ifdef EXDEV if (errno == EXDEV) { struct stat sb; if (php_copy_file(url_from, url_to TSRMLS_CC) == SUCCESS) { if (VCWD_STAT(url_from, &sb) == 0) { -#if !defined(TSRM_WIN32) && !defined(NETWARE) +# if !defined(TSRM_WIN32) && !defined(NETWARE) if (VCWD_CHMOD(url_to, sb.st_mode)) { if (errno == EPERM) { php_error_docref2(NULL TSRMLS_CC, url_from, url_to, E_WARNING, "%s", strerror(errno)); @@ -1107,7 +1123,7 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, char *url_from, c php_error_docref2(NULL TSRMLS_CC, url_from, url_to, E_WARNING, "%s", strerror(errno)); return 0; } -#endif +# endif VCWD_UNLINK(url_from); return 1; } @@ -1115,8 +1131,14 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, char *url_from, c php_error_docref2(NULL TSRMLS_CC, url_from, url_to, E_WARNING, "%s", strerror(errno)); return 0; } +# endif #endif + +#ifdef PHP_WIN32 + php_win32_docref2_from_error(GetLastError(), url_from, url_to TSRMLS_CC); +#else php_error_docref2(NULL TSRMLS_CC, url_from, url_to, E_WARNING, "%s", strerror(errno)); +#endif return 0; } @@ -1221,6 +1243,9 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, char *dir, int mod static int php_plain_files_rmdir(php_stream_wrapper *wrapper, char *url, int options, php_stream_context *context TSRMLS_DC) { +#if PHP_WIN32 + int url_len = strlen(url); +#endif if (PG(safe_mode) &&(!php_checkuid(url, NULL, CHECKUID_CHECK_FILE_AND_DIR))) { return 0; } @@ -1229,6 +1254,13 @@ static int php_plain_files_rmdir(php_stream_wrapper *wrapper, char *url, int opt return 0; } +#if PHP_WIN32 + if (!php_win32_check_trailing_space(url, url_len)) { + php_error_docref1(NULL TSRMLS_CC, url, E_WARNING, "%s", strerror(ENOENT)); + return 0; + } +#endif + if (VCWD_RMDIR(url) < 0) { php_error_docref1(NULL TSRMLS_CC, url, E_WARNING, "%s", strerror(errno)); return 0; diff --git a/main/streams/streams.c b/main/streams/streams.c index c2b4e3f85..44843d25c 100755 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | + | Copyright (c) 1997-2010 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: streams.c 280678 2009-05-17 14:58:10Z lbarnaud $ */ +/* $Id: streams.c 294550 2010-02-05 00:39:31Z pajoye $ */ #define _GNU_SOURCE #include "php.h" @@ -1396,7 +1396,7 @@ PHPAPI size_t _php_stream_copy_to_stream_ex(php_stream *src, php_stream *dest, s /* we've got at least 1 byte to read. * less than 1 is an error */ - if (haveread > 0) { + if (haveread > 0 || src->eof) { return SUCCESS; } return FAILURE; @@ -1858,22 +1858,9 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(char *path, char *mode, int optio php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC, "wrapper does not support stream open"); } else { - /* refcount++ to make sure the context doesn't get destroyed - * if open() fails and stream is closed */ - if (context) { - zend_list_addref(context->rsrc_id); - } - stream = wrapper->wops->stream_opener(wrapper, path_to_open, mode, options ^ REPORT_ERRORS, opened_path, context STREAMS_REL_CC TSRMLS_CC); - - /* if open() succeeded and context was not used, do refcount-- - * XXX if a wrapper didn't actually use context (no way to know that) - * and open() failed, refcount will stay increased */ - if (context && stream && !stream->context) { - zend_list_delete(context->rsrc_id); - } } /* if the caller asked for a persistent stream but the wrapper did not @@ -1974,7 +1961,17 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(char *path, char *mode, int optio PHPAPI php_stream_context *php_stream_context_set(php_stream *stream, php_stream_context *context) { php_stream_context *oldcontext = stream->context; + TSRMLS_FETCH(); + stream->context = context; + + if (context) { + zend_list_addref(context->rsrc_id); + } + if (oldcontext) { + zend_list_delete(oldcontext->rsrc_id); + } + return oldcontext; } diff --git a/main/streams/transports.c b/main/streams/transports.c index 1ac6677d9..a35efb2df 100644 --- a/main/streams/transports.c +++ b/main/streams/transports.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | + | Copyright (c) 1997-2010 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: transports.c 272370 2008-12-31 11:15:49Z sebastian $ */ +/* $Id: transports.c 293036 2010-01-03 09:23:27Z sebastian $ */ #include "php.h" #include "php_streams_int.h" @@ -134,7 +134,7 @@ PHPAPI php_stream *_php_stream_xport_create(const char *name, long namelen, int context STREAMS_REL_CC TSRMLS_CC); if (stream) { - stream->context = context; + php_stream_context_set(stream, context); if ((flags & STREAM_XPORT_SERVER) == 0) { /* client */ diff --git a/main/streams/userspace.c b/main/streams/userspace.c index 74e2f9173..106cfe621 100644 --- a/main/streams/userspace.c +++ b/main/streams/userspace.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | + | Copyright (c) 1997-2010 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: userspace.c 280151 2009-05-08 11:35:12Z bjori $ */ +/* $Id: userspace.c 293036 2010-01-03 09:23:27Z sebastian $ */ #include "php.h" #include "php_globals.h" diff --git a/main/streams/xp_socket.c b/main/streams/xp_socket.c index 214c0118b..9b039ca93 100644 --- a/main/streams/xp_socket.c +++ b/main/streams/xp_socket.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | + | Copyright (c) 1997-2010 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: xp_socket.c 289416 2009-10-09 14:20:17Z pajoye $ */ +/* $Id: xp_socket.c 294453 2010-02-03 20:21:40Z pajoye $ */ #include "php.h" #include "ext/standard/file.h" @@ -223,7 +223,11 @@ static int php_sockop_flush(php_stream *stream TSRMLS_DC) static int php_sockop_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC) { php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract; +#if ZEND_WIN32 + return 0; +#else return fstat(sock->socket, &ssb->sb); +#endif } static inline int sock_sendto(php_netstream_data_t *sock, char *buf, size_t buflen, int flags, @@ -396,6 +400,10 @@ static int php_sockop_set_option(php_stream *stream, int option, int value, void } #endif + case PHP_STREAM_OPTION_WRITE_BUFFER: + php_stream_set_chunk_size(stream, (ptrparam ? *(size_t *)ptrparam : PHP_SOCK_CHUNK_SIZE)); + return PHP_STREAM_OPTION_RETURN_OK; + default: return PHP_STREAM_OPTION_RETURN_NOTIMPL; } |
