Skip to content

Commit 06dda61

Browse files
committed
Clear persistent stream request pointers after shutdown
1 parent 9c460bb commit 06dda61

3 files changed

Lines changed: 7 additions & 9 deletions

File tree

‎ext/standard/basic_functions.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ zend_module_entry basic_functions_module = { /* {{{ */
157157
PHP_RSHUTDOWN(basic), /* request shutdown */
158158
PHP_MINFO(basic), /* extension info */
159159
PHP_STANDARD_VERSION, /* extension version */
160-
STANDARD_MODULE_PROPERTIES
160+
NO_MODULE_GLOBALS,
161+
ZEND_MODULE_POST_ZEND_DEACTIVATE_N(streams),
162+
STANDARD_MODULE_PROPERTIES_EX
161163
};
162164
/* }}} */
163165

@@ -463,7 +465,6 @@ PHP_RSHUTDOWN_FUNCTION(basic) /* {{{ */
463465
#endif
464466
BASIC_RSHUTDOWN_SUBMODULE(assert)
465467
BASIC_RSHUTDOWN_SUBMODULE(url_scanner_ex)
466-
BASIC_RSHUTDOWN_SUBMODULE(streams)
467468
#ifdef PHP_WIN32
468469
BASIC_RSHUTDOWN_SUBMODULE(win32_core_globals)
469470
#endif

‎main/php_streams.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ END_EXTERN_C()
586586
int php_init_stream_wrappers(int module_number);
587587
void php_shutdown_stream_wrappers(int module_number);
588588
void php_shutdown_stream_hashes(void);
589-
PHP_RSHUTDOWN_FUNCTION(streams);
589+
ZEND_MODULE_POST_ZEND_DEACTIVATE_D(streams);
590590

591591
BEGIN_EXTERN_C()
592592
PHPAPI zend_result php_register_url_stream_wrapper(const char *protocol, const php_stream_wrapper *wrapper);

‎main/streams/streams.c‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,14 @@ static int forget_persistent_resource_id_numbers(zval *el)
7979
fprintf(stderr, "forget_persistent: %s:%p\n", stream->ops->label, stream);
8080
#endif
8181

82+
/* Request resources have been destroyed; clear their stale pointers. */
8283
stream->res = NULL;
83-
84-
if (stream->ctx) {
85-
zend_list_delete(stream->ctx);
86-
stream->ctx = NULL;
87-
}
84+
stream->ctx = NULL;
8885

8986
return 0;
9087
}
9188

92-
PHP_RSHUTDOWN_FUNCTION(streams)
89+
ZEND_MODULE_POST_ZEND_DEACTIVATE_D(streams)
9390
{
9491
zval *el;
9592

0 commit comments

Comments
 (0)