tony2001 Fri Jul 11 10:25:16 2008 UTC
Modified files: (Branch: PHP_5_3)
/php-src/ext/openssl xp_ssl.c
/php-src/ext/standard file.c streamsfuncs.c http_fopen_wrapper.c
/php-src/main/streams streams.c userspace.c xp_socket.c
Log:
MFH: manage references of stream context properly
http://cvs.php.net/viewvc.cgi/php-src/ext/openssl/xp_ssl.c?r1=1.22.2.3.2.9.2.5&r2=1.22.2.3.2.9.2.6&diff_format=u
Index: php-src/ext/openssl/xp_ssl.c
diff -u php-src/ext/openssl/xp_ssl.c:1.22.2.3.2.9.2.5
php-src/ext/openssl/xp_ssl.c:1.22.2.3.2.9.2.6
--- php-src/ext/openssl/xp_ssl.c:1.22.2.3.2.9.2.5 Mon Apr 14 12:16:07 2008
+++ php-src/ext/openssl/xp_ssl.c Fri Jul 11 10:25:15 2008
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: xp_ssl.c,v 1.22.2.3.2.9.2.5 2008/04/14 12:16:07 bjori Exp $ */
+/* $Id: xp_ssl.c,v 1.22.2.3.2.9.2.6 2008/07/11 10:25:15 tony2001 Exp $ */
#include "php.h"
#include "ext/standard/file.h"
@@ -556,7 +556,9 @@
xparam->outputs.client =
php_stream_alloc_rel(stream->ops, clisockdata, NULL, "r+");
if (xparam->outputs.client) {
- xparam->outputs.client->context =
stream->context;
+ if (stream->context) {
+
zend_list_addref(stream->context->rsrc_id);
+ }
}
}
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.409.2.6.2.28.2.15&r2=1.409.2.6.2.28.2.16&diff_format=u
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.409.2.6.2.28.2.15
php-src/ext/standard/file.c:1.409.2.6.2.28.2.16
--- php-src/ext/standard/file.c:1.409.2.6.2.28.2.15 Thu Jul 3 20:19:26 2008
+++ php-src/ext/standard/file.c Fri Jul 11 10:25:15 2008
@@ -21,7 +21,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: file.c,v 1.409.2.6.2.28.2.15 2008/07/03 20:19:26 ohill Exp $ */
+/* $Id: file.c,v 1.409.2.6.2.28.2.16 2008/07/11 10:25:15 tony2001 Exp $ */
/* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
@@ -884,10 +884,6 @@
}
php_stream_to_zval(stream, return_value);
-
- if (zcontext) {
- zend_list_addref(Z_RESVAL_P(zcontext));
- }
}
/* }}} */
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/streamsfuncs.c?r1=1.58.2.6.2.15.2.15&r2=1.58.2.6.2.15.2.16&diff_format=u
Index: php-src/ext/standard/streamsfuncs.c
diff -u php-src/ext/standard/streamsfuncs.c:1.58.2.6.2.15.2.15
php-src/ext/standard/streamsfuncs.c:1.58.2.6.2.15.2.16
--- php-src/ext/standard/streamsfuncs.c:1.58.2.6.2.15.2.15 Fri Jun 20
14:53:57 2008
+++ php-src/ext/standard/streamsfuncs.c Fri Jul 11 10:25:15 2008
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: streamsfuncs.c,v 1.58.2.6.2.15.2.15 2008/06/20 14:53:57 felipe Exp $ */
+/* $Id: streamsfuncs.c,v 1.58.2.6.2.15.2.16 2008/07/11 10:25:15 tony2001 Exp $
*/
#include "php.h"
#include "php_globals.h"
@@ -100,6 +100,10 @@
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_stream_to_zval(stream, return_value);
-
- if (zcontext) {
- zend_list_addref(Z_RESVAL_P(zcontext));
- }
+
}
/* }}} */
@@ -182,6 +183,10 @@
}
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_stream_to_zval(stream, return_value);
-
- if (zcontext) {
- zend_list_addref(Z_RESVAL_P(zcontext));
- }
}
/* }}} */
@@ -1032,7 +1033,7 @@
FG(default_context) = php_stream_context_alloc();
}
context = FG(default_context);
-
+
if (params) {
parse_context_options(context, params TSRMLS_CC);
}
@@ -1062,7 +1063,7 @@
parse_context_params(context, params TSRMLS_CC);
}
- php_stream_context_to_zval(context, return_value);
+ RETURN_RESOURCE(context->rsrc_id);
}
/* }}} */
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/http_fopen_wrapper.c?r1=1.99.2.12.2.9.2.7&r2=1.99.2.12.2.9.2.8&diff_format=u
Index: php-src/ext/standard/http_fopen_wrapper.c
diff -u php-src/ext/standard/http_fopen_wrapper.c:1.99.2.12.2.9.2.7
php-src/ext/standard/http_fopen_wrapper.c:1.99.2.12.2.9.2.8
--- php-src/ext/standard/http_fopen_wrapper.c:1.99.2.12.2.9.2.7 Tue Apr 29
08:15:20 2008
+++ php-src/ext/standard/http_fopen_wrapper.c Fri Jul 11 10:25:15 2008
@@ -19,7 +19,7 @@
| Sara Golemon <[EMAIL PROTECTED]> |
+----------------------------------------------------------------------+
*/
-/* $Id: http_fopen_wrapper.c,v 1.99.2.12.2.9.2.7 2008/04/29 08:15:20 dmitry
Exp $ */
+/* $Id: http_fopen_wrapper.c,v 1.99.2.12.2.9.2.8 2008/07/11 10:25:15 tony2001
Exp $ */
#include "php.h"
#include "php_globals.h"
@@ -611,6 +611,9 @@
if (location[0] != '\0')
php_stream_notify_info(context,
PHP_STREAM_NOTIFY_REDIRECTED, location, 0);
+ if (context) { /* keep the context for the next try */
+ zend_list_addref(context->rsrc_id);
+ }
php_stream_close(stream);
stream = NULL;
http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.82.2.6.2.18.2.10&r2=1.82.2.6.2.18.2.11&diff_format=u
Index: php-src/main/streams/streams.c
diff -u php-src/main/streams/streams.c:1.82.2.6.2.18.2.10
php-src/main/streams/streams.c:1.82.2.6.2.18.2.11
--- php-src/main/streams/streams.c:1.82.2.6.2.18.2.10 Wed Jun 11 09:01:56 2008
+++ php-src/main/streams/streams.c Fri Jul 11 10:25:15 2008
@@ -19,7 +19,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: streams.c,v 1.82.2.6.2.18.2.10 2008/06/11 09:01:56 dmitry Exp $ */
+/* $Id: streams.c,v 1.82.2.6.2.18.2.11 2008/07/11 10:25:15 tony2001 Exp $ */
#define _GNU_SOURCE
#include "php.h"
@@ -287,6 +287,7 @@
int remove_rsrc = 1;
int preserve_handle = close_options & PHP_STREAM_FREE_PRESERVE_HANDLE ?
1 : 0;
int release_cast = 1;
+ php_stream_context *context = stream->context;
if (stream->flags & PHP_STREAM_FLAG_NO_CLOSE) {
preserve_handle = 1;
@@ -427,6 +428,10 @@
#endif
}
+ if (context) {
+ zend_list_delete(context->rsrc_id);
+ }
+
return ret;
}
/* }}} */
@@ -1801,6 +1806,10 @@
opened_path, context STREAMS_REL_CC TSRMLS_CC);
}
+ if (context) {
+ zend_list_addref(context->rsrc_id);
+ }
+
/* if the caller asked for a persistent stream but the wrapper
did not
* return one, force an error here */
if (stream && (options & STREAM_OPEN_PERSISTENT) &&
!stream->is_persistent) {
http://cvs.php.net/viewvc.cgi/php-src/main/streams/userspace.c?r1=1.31.2.3.2.7.2.2&r2=1.31.2.3.2.7.2.3&diff_format=u
Index: php-src/main/streams/userspace.c
diff -u php-src/main/streams/userspace.c:1.31.2.3.2.7.2.2
php-src/main/streams/userspace.c:1.31.2.3.2.7.2.3
--- php-src/main/streams/userspace.c:1.31.2.3.2.7.2.2 Mon Dec 31 07:17:17 2007
+++ php-src/main/streams/userspace.c Fri Jul 11 10:25:15 2008
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: userspace.c,v 1.31.2.3.2.7.2.2 2007/12/31 07:17:17 sebastian Exp $ */
+/* $Id: userspace.c,v 1.31.2.3.2.7.2.3 2008/07/11 10:25:15 tony2001 Exp $ */
#include "php.h"
#include "php_globals.h"
@@ -215,7 +215,6 @@
zval **args[4];
int call_result;
php_stream *stream = NULL;
- zval *zcontext = NULL;
zend_bool old_in_user_include;
/* Try to catch bad usage without preventing flexibility */
@@ -281,12 +280,8 @@
}
if (context) {
- MAKE_STD_ZVAL(zcontext);
- php_stream_context_to_zval(context, zcontext);
- add_property_zval(us->object, "context", zcontext);
- /* The object property should be the only reference,
- 'get rid' of our local reference. */
- zval_ptr_dtor(&zcontext);
+ add_property_resource(us->object, "context", context->rsrc_id);
+ zend_list_addref(context->rsrc_id);
} else {
add_property_null(us->object, "context");
}
@@ -362,7 +357,7 @@
{
struct php_user_stream_wrapper *uwrap = (struct
php_user_stream_wrapper*)wrapper->abstract;
php_userstream_data_t *us;
- zval *zfilename, *zoptions, *zretval = NULL, *zfuncname, *zcontext;
+ zval *zfilename, *zoptions, *zretval = NULL, *zfuncname;
zval **args[2];
int call_result;
php_stream *stream = NULL;
@@ -384,12 +379,8 @@
Z_SET_ISREF_P(us->object);
if (context) {
- MAKE_STD_ZVAL(zcontext);
- php_stream_context_to_zval(context, zcontext);
- add_property_zval(us->object, "context", zcontext);
- /* The object property should be the only reference,
- 'get rid' of our local reference. */
- zval_ptr_dtor(&zcontext);
+ add_property_resource(us->object, "context", context->rsrc_id);
+ zend_list_addref(context->rsrc_id);
} else {
add_property_null(us->object, "context");
}
@@ -952,7 +943,7 @@
static int user_wrapper_unlink(php_stream_wrapper *wrapper, char *url, int
options, php_stream_context *context TSRMLS_DC)
{
struct php_user_stream_wrapper *uwrap = (struct
php_user_stream_wrapper*)wrapper->abstract;
- zval *zfilename, *zfuncname, *zretval, *zcontext;
+ zval *zfilename, *zfuncname, *zretval;
zval **args[1];
int call_result;
zval *object;
@@ -965,12 +956,8 @@
Z_SET_ISREF_P(object);
if (context) {
- MAKE_STD_ZVAL(zcontext);
- php_stream_context_to_zval(context, zcontext);
- add_property_zval(object, "context", zcontext);
- /* The object property should be the only reference,
- 'get rid' of our local reference. */
- zval_ptr_dtor(&zcontext);
+ add_property_resource(object, "context", context->rsrc_id);
+ zend_list_addref(context->rsrc_id);
} else {
add_property_null(object, "context");
}
@@ -1010,7 +997,7 @@
static int user_wrapper_rename(php_stream_wrapper *wrapper, char *url_from,
char *url_to, int options, php_stream_context *context TSRMLS_DC)
{
struct php_user_stream_wrapper *uwrap = (struct
php_user_stream_wrapper*)wrapper->abstract;
- zval *zold_name, *znew_name, *zfuncname, *zretval, *zcontext;
+ zval *zold_name, *znew_name, *zfuncname, *zretval;
zval **args[2];
int call_result;
zval *object;
@@ -1023,12 +1010,8 @@
Z_SET_ISREF_P(object);
if (context) {
- MAKE_STD_ZVAL(zcontext);
- php_stream_context_to_zval(context, zcontext);
- add_property_zval(object, "context", zcontext);
- /* The object property should be the only reference,
- 'get rid' of our local reference. */
- zval_ptr_dtor(&zcontext);
+ add_property_resource(object, "context", context->rsrc_id);
+ zend_list_addref(context->rsrc_id);
} else {
add_property_null(object, "context");
}
@@ -1073,7 +1056,7 @@
static int user_wrapper_mkdir(php_stream_wrapper *wrapper, char *url, int
mode, int options, php_stream_context *context TSRMLS_DC)
{
struct php_user_stream_wrapper *uwrap = (struct
php_user_stream_wrapper*)wrapper->abstract;
- zval *zfilename, *zmode, *zoptions, *zfuncname, *zretval, *zcontext;
+ zval *zfilename, *zmode, *zoptions, *zfuncname, *zretval;
zval **args[3];
int call_result;
zval *object;
@@ -1086,12 +1069,8 @@
Z_SET_ISREF_P(object);
if (context) {
- MAKE_STD_ZVAL(zcontext);
- php_stream_context_to_zval(context, zcontext);
- add_property_zval(object, "context", zcontext);
- /* The object property should be the only reference,
- 'get rid' of our local reference. */
- zval_ptr_dtor(&zcontext);
+ add_property_resource(object, "context", context->rsrc_id);
+ zend_list_addref(context->rsrc_id);
} else {
add_property_null(object, "context");
}
@@ -1142,7 +1121,7 @@
static int user_wrapper_rmdir(php_stream_wrapper *wrapper, char *url, int
options, php_stream_context *context TSRMLS_DC)
{
struct php_user_stream_wrapper *uwrap = (struct
php_user_stream_wrapper*)wrapper->abstract;
- zval *zfilename, *zoptions, *zfuncname, *zretval, *zcontext;
+ zval *zfilename, *zoptions, *zfuncname, *zretval;
zval **args[3];
int call_result;
zval *object;
@@ -1155,12 +1134,8 @@
Z_SET_ISREF_P(object);
if (context) {
- MAKE_STD_ZVAL(zcontext);
- php_stream_context_to_zval(context, zcontext);
- add_property_zval(object, "context", zcontext);
- /* The object property should be the only reference,
- 'get rid' of our local reference. */
- zval_ptr_dtor(&zcontext);
+ add_property_resource(object, "context", context->rsrc_id);
+ zend_list_addref(context->rsrc_id);
} else {
add_property_null(object, "context");
}
@@ -1206,7 +1181,7 @@
static int user_wrapper_stat_url(php_stream_wrapper *wrapper, char *url, int
flags, php_stream_statbuf *ssb, php_stream_context *context TSRMLS_DC)
{
struct php_user_stream_wrapper *uwrap = (struct
php_user_stream_wrapper*)wrapper->abstract;
- zval *zfilename, *zfuncname, *zretval, *zflags, *zcontext;
+ zval *zfilename, *zfuncname, *zretval, *zflags;
zval **args[2];
int call_result;
zval *object;
@@ -1219,12 +1194,8 @@
Z_SET_ISREF_P(object);
if (context) {
- MAKE_STD_ZVAL(zcontext);
- php_stream_context_to_zval(context, zcontext);
- add_property_zval(object, "context", zcontext);
- /* The object property should be the only reference,
- 'get rid' of our local reference. */
- zval_ptr_dtor(&zcontext);
+ add_property_resource(object, "context", context->rsrc_id);
+ zend_list_addref(context->rsrc_id);
} else {
add_property_null(object, "context");
}
http://cvs.php.net/viewvc.cgi/php-src/main/streams/xp_socket.c?r1=1.33.2.2.2.6.2.3&r2=1.33.2.2.2.6.2.4&diff_format=u
Index: php-src/main/streams/xp_socket.c
diff -u php-src/main/streams/xp_socket.c:1.33.2.2.2.6.2.3
php-src/main/streams/xp_socket.c:1.33.2.2.2.6.2.4
--- php-src/main/streams/xp_socket.c:1.33.2.2.2.6.2.3 Mon Mar 10 19:54:47 2008
+++ php-src/main/streams/xp_socket.c Fri Jul 11 10:25:15 2008
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: xp_socket.c,v 1.33.2.2.2.6.2.3 2008/03/10 19:54:47 andrey Exp $ */
+/* $Id: xp_socket.c,v 1.33.2.2.2.6.2.4 2008/07/11 10:25:15 tony2001 Exp $ */
#include "php.h"
#include "ext/standard/file.h"
@@ -716,8 +716,10 @@
xparam->outputs.client =
php_stream_alloc_rel(stream->ops, clisockdata, NULL, "r+");
if (xparam->outputs.client) {
- /* TODO: addref ? */
xparam->outputs.client->context =
stream->context;
+ if (stream->context) {
+
zend_list_addref(stream->context->rsrc_id);
+ }
}
}
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php