diff options
author | Antony Dovgal <tony2001@php.net> | 2008-07-11 10:25:15 +0000 |
---|---|---|
committer | Antony Dovgal <tony2001@php.net> | 2008-07-11 10:25:15 +0000 |
commit | cf7e15c3a0fb44f57298c1761a373ca08a6d4a9d (patch) | |
tree | 01f29a896bb67c620cb1a02d1ea28506c71c34a4 /ext/standard/streamsfuncs.c | |
parent | 46f41aded18fe844e00385fb670a321bf2a75837 (diff) | |
download | php-git-cf7e15c3a0fb44f57298c1761a373ca08a6d4a9d.tar.gz |
MFH: manage references of stream context properly
Diffstat (limited to 'ext/standard/streamsfuncs.c')
-rw-r--r-- | ext/standard/streamsfuncs.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index 6649ec4cd6..279dd09ca0 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -100,6 +100,10 @@ PHP_FUNCTION(stream_socket_client) context = php_stream_context_from_zval(zcontext, flags & PHP_FILE_NO_DEFAULT_CONTEXT); + if (context) { + zend_list_addref(context->rsrc_id); + } + if (flags & PHP_STREAM_CLIENT_PERSISTENT) { spprintf(&hashkey, 0, "stream_socket_client__%s", host); } @@ -155,10 +159,7 @@ PHP_FUNCTION(stream_socket_client) } php_stream_to_zval(stream, return_value); - - if (zcontext) { - zend_list_addref(Z_RESVAL_P(zcontext)); - } + } /* }}} */ @@ -182,6 +183,10 @@ PHP_FUNCTION(stream_socket_server) } context = php_stream_context_from_zval(zcontext, flags & PHP_FILE_NO_DEFAULT_CONTEXT); + + if (context) { + zend_list_addref(context->rsrc_id); + } if (zerrno) { zval_dtor(zerrno); @@ -220,10 +225,6 @@ PHP_FUNCTION(stream_socket_server) } php_stream_to_zval(stream, return_value); - - if (zcontext) { - zend_list_addref(Z_RESVAL_P(zcontext)); - } } /* }}} */ @@ -1032,7 +1033,7 @@ PHP_FUNCTION(stream_context_get_default) FG(default_context) = php_stream_context_alloc(); } context = FG(default_context); - + if (params) { parse_context_options(context, params TSRMLS_CC); } @@ -1062,7 +1063,7 @@ PHP_FUNCTION(stream_context_create) parse_context_params(context, params TSRMLS_CC); } - php_stream_context_to_zval(context, return_value); + RETURN_RESOURCE(context->rsrc_id); } /* }}} */ |