diff --git a/ext-src/php_swoole.h b/ext-src/php_swoole.h index 4eb04cd1566..313269d7832 100644 --- a/ext-src/php_swoole.h +++ b/ext-src/php_swoole.h @@ -425,6 +425,12 @@ extern ZEND_DECLARE_MODULE_GLOBALS(swoole); #endif /*}}}*/ +#if PHP_VERSION_ID < 70400 +typedef size_t php_stream_size_t; +#else +typedef ssize_t php_stream_size_t; +#endif + /* PHP 7 wrapper functions / macros */ //----------------------------------Zval API------------------------------------ diff --git a/ext-src/swoole_runtime.cc b/ext-src/swoole_runtime.cc index d7822fae42b..9f72fa4bcb8 100644 --- a/ext-src/swoole_runtime.cc +++ b/ext-src/swoole_runtime.cc @@ -37,12 +37,6 @@ #define HAVE_SEC_LEVEL 1 #endif -#if PHP_VERSION_ID < 70400 -typedef size_t php_stream_size_t; -#else -typedef ssize_t php_stream_size_t; -#endif - using swoole::Coroutine; using swoole::PHPCoroutine; using swoole::coroutine::Socket; diff --git a/thirdparty/php/streams/plain_wrapper.c b/thirdparty/php/streams/plain_wrapper.c index 4be72ac6ed8..de6257368b2 100644 --- a/thirdparty/php/streams/plain_wrapper.c +++ b/thirdparty/php/streams/plain_wrapper.c @@ -18,14 +18,12 @@ /* $Id$ */ -#include "php.h" -#include "php_globals.h" -#include "php_network.h" +#include "php_swoole.h" #include "php_open_temporary_file.h" #include "ext/standard/file.h" #include "ext/standard/flock_compat.h" #include "ext/standard/php_filestat.h" -#include + #include #if HAVE_SYS_WAIT_H #include @@ -36,15 +34,8 @@ #ifdef HAVE_SYS_MMAN_H #include #endif -#include "SAPI.h" #include "thirdparty/php/streams/php_streams_int.h" -#ifdef PHP_WIN32 -#include "win32/winutil.h" -#include "win32/time.h" -#include "win32/ioutil.h" -#include "win32/readdir.h" -#endif #include "swoole_file_hook.h" @@ -891,6 +882,9 @@ static php_stream *stream_opener(php_stream_wrapper *wrapper, if (options & STREAM_OPEN_FOR_INCLUDE) { _open_for_include: stream = php_stream_fopen_rel(path, mode, opened_path, options); + if (stream == NULL) { + return NULL; + } stream->ops = php_swoole_get_ori_php_stream_stdio_ops(); return stream; }