diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-08-12 10:45:43 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-08-12 10:45:43 +0200 |
commit | 1a9a5f995c273b57ef1b42a8c68bcd736110b4a7 (patch) | |
tree | bd99b36210bfbd6173ba21e4fca19be8afe0c12c | |
parent | 9f95d68ca3be3a798a033b3fc53d4c2a4e53d368 (diff) | |
parent | a18ad194c470156f03a5ea2cb9174cc26bc5e618 (diff) | |
download | php-git-1a9a5f995c273b57ef1b42a8c68bcd736110b4a7.tar.gz |
Merge branch 'PHP-7.4'
-rw-r--r-- | Zend/tests/bug78396.phpt | 18 | ||||
-rw-r--r-- | Zend/zend_execute_API.c | 1 | ||||
-rw-r--r-- | Zend/zend_globals.h | 1 | ||||
-rw-r--r-- | main/streams/streams.c | 2 |
4 files changed, 21 insertions, 1 deletions
diff --git a/Zend/tests/bug78396.phpt b/Zend/tests/bug78396.phpt new file mode 100644 index 0000000000..1f08a47dc4 --- /dev/null +++ b/Zend/tests/bug78396.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #78396: Second file_put_contents in Shutdown hangs script +--FILE-- +<?php + +register_shutdown_function(function () { + file_put_contents(__DIR__ . '/bug78396.txt', '1', FILE_APPEND | LOCK_EX); + file_put_contents(__DIR__ . '/bug78396.txt', '2', FILE_APPEND | LOCK_EX); + echo "Done\n"; +}); + +?> +--CLEAN-- +<?php +unlink(__DIR__ . '/bug78396.txt'); +?> +--EXPECT-- +Done diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index a3dfac39a6..f960d856b0 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -263,6 +263,7 @@ void shutdown_executor(void) /* {{{ */ zend_llist_destroy(&CG(open_files)); } zend_end_try(); + EG(flags) |= EG_FLAGS_IN_RESOURCE_SHUTDOWN; zend_try { zend_close_rsrc_list(&EG(regular_list)); } zend_end_try(); diff --git a/Zend/zend_globals.h b/Zend/zend_globals.h index 62ff68b877..9a55924f42 100644 --- a/Zend/zend_globals.h +++ b/Zend/zend_globals.h @@ -242,6 +242,7 @@ struct _zend_executor_globals { #define EG_FLAGS_INITIAL (0) #define EG_FLAGS_IN_SHUTDOWN (1<<0) #define EG_FLAGS_OBJECT_STORE_NO_REUSE (1<<1) +#define EG_FLAGS_IN_RESOURCE_SHUTDOWN (1<<2) struct _zend_ini_scanner_globals { zend_file_handle *yy_in; diff --git a/main/streams/streams.c b/main/streams/streams.c index 7d81644724..566cdcde08 100644 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -370,7 +370,7 @@ PHPAPI int _php_stream_free(php_stream *stream, int close_options) /* {{{ */ * stream free operations in shutdown unless they come from the resource list destruction, * or by freeing an enclosed stream (in which case resource list destruction will not have * freed it). */ - if ((EG(flags) & EG_FLAGS_IN_SHUTDOWN) && + if ((EG(flags) & EG_FLAGS_IN_RESOURCE_SHUTDOWN) && !(close_options & (PHP_STREAM_FREE_RSRC_DTOR|PHP_STREAM_FREE_IGNORE_ENCLOSING))) { return 1; } |