Skip to content

Instantly share code, notes, and snippets.

@m6w6
Created January 30, 2015 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m6w6/628c03b8271d8c8ab120 to your computer and use it in GitHub Desktop.
Save m6w6/628c03b8271d8c8ab120 to your computer and use it in GitHub Desktop.
diff --git a/main/streams/streams.c b/main/streams/streams.c
index 204c33b..fe42cf2 100644
--- a/main/streams/streams.c
+++ b/main/streams/streams.c
@@ -397,8 +397,9 @@ PHPAPI int _php_stream_free(php_stream *stream, int close_options) /* {{{ */
#if STREAM_DEBUG
{
char out[200] = "";
- fprintf(stderr, "stream_free: %s:%p[%s] in_free=%d opts=%s\n",
- stream->ops->label, stream, stream->orig_path, stream->in_free, _php_stream_pretty_free_options(close_
+ fprintf(stderr, "stream_free: %s:%p[%s] in_free=%d opts=%s refc=%u encl=%p\n",
+ stream->ops->label, stream, stream->orig_path, stream->in_free,
+ _php_stream_pretty_free_options(close_options, out), GC_REFCOUNT(stream->res), stream->enclosing_strea
}
#endif
@@ -463,13 +464,11 @@ fprintf(stderr, "stream_free: %s:%p[%s] preserve_handle=%d release_cast=%d remov
* the resource list, otherwise the resource will point to invalid memory.
* In any case, let's always completely delete it from the resource list,
* not only when PHP_STREAM_FREE_RELEASE_STREAM is set */
-//??? while (zend_list_delete(stream->res) == SUCCESS) {}
-//??? stream->res->gc.refcount = 0;
zend_list_close(stream->res);
- if (!stream->__exposed) {
+ if (close_options & PHP_STREAM_FREE_IGNORE_ENCLOSING) {
zend_list_delete(stream->res);
- stream->res = NULL;
}
+ stream->res = NULL;
}
if (close_options & PHP_STREAM_FREE_CALL_DTOR) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment