cvs: php4 /ext/standard file.c streamsfuncs.c /main/streams plain_wrapper.c streams.c

From: Date: Wed, 21 May 2003 13:33:55 +0000
Subject: cvs: php4 /ext/standard file.c streamsfuncs.c /main/streams plain_wrapper.c streams.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-21173@lists.php.net to get a copy of this message
wez Wed May 21 09:33:55 2003 EDT Modified files: /php4/main/streams streams.c plain_wrapper.c /php4/ext/standard streamsfuncs.c file.c Log: MFB context refcounting and text-mode fopen fixes Index: php4/main/streams/streams.c diff -u php4/main/streams/streams.c:1.22 php4/main/streams/streams.c:1.23 --- php4/main/streams/streams.c:1.22 Mon May 19 18:58:34 2003 +++ php4/main/streams/streams.c Wed May 21 09:33:55 2003 @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: streams.c,v 1.22 2003/05/19 22:58:34 wez Exp $ */ +/* $Id: streams.c,v 1.23 2003/05/21 13:33:55 wez Exp $ */ #define _GNU_SOURCE #include "php.h" @@ -53,6 +53,14 @@ return &url_stream_wrappers_hash; } +static int _php_stream_release_context(list_entry *le, void *pContext TSRMLS_DC) +{ + if (le->ptr == pContext) { + return --le->refcount == 0; + } + return 0; +} + static int forget_persistent_resource_id_numbers(zend_rsrc_list_entry *rsrc TSRMLS_DC) { php_stream *stream; @@ -69,6 +77,13 @@ stream->rsrc_id = FAILURE; + if (stream->context) { + zend_hash_apply_with_argument(&EG(regular_list), + (apply_func_arg_t) _php_stream_release_context, + stream->context TSRMLS_CC); + stream->context = NULL; + } + return 0; } @@ -1643,8 +1658,12 @@ const char *wrappername, const char *optionname, zval *optionvalue) { zval **wrapperhash; - zval *category; + zval *category, *copied_val; + ALLOC_INIT_ZVAL(copied_val); + *copied_val = *optionvalue; + zval_copy_ctor(copied_val); + if (FAILURE == zend_hash_find(Z_ARRVAL_P(context->options), (char*)wrappername, strlen(wrappername)+1, (void**)&wrapperhash)) { MAKE_STD_ZVAL(category); @@ -1656,7 +1675,7 @@ ZVAL_ADDREF(optionvalue); wrapperhash = &category; } - return zend_hash_update(Z_ARRVAL_PP(wrapperhash), (char*)optionname, strlen(optionname)+1, (void**)&optionvalue, sizeof(zval *), NULL); + return zend_hash_update(Z_ARRVAL_PP(wrapperhash), (char*)optionname, strlen(optionname)+1, (void**)&copied_val, sizeof(zval *), NULL); } /* }}} */ Index: php4/main/streams/plain_wrapper.c diff -u php4/main/streams/plain_wrapper.c:1.16 php4/main/streams/plain_wrapper.c:1.17 --- php4/main/streams/plain_wrapper.c:1.16 Mon May 19 14:48:15 2003 +++ php4/main/streams/plain_wrapper.c Wed May 21 09:33:55 2003 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: plain_wrapper.c,v 1.16 2003/05/19 18:48:15 helly Exp $ */ +/* $Id: plain_wrapper.c,v 1.17 2003/05/21 13:33:55 wez Exp $ */ #include "php.h" #include "php_globals.h" @@ -74,7 +74,11 @@ flags |= O_BINARY; } #endif - +#ifdef _O_TEXT + if (strchr(mode, 't')) { + flags |= _O_TEXT; + } +#endif *open_flags = flags; return SUCCESS; } Index: php4/ext/standard/streamsfuncs.c diff -u php4/ext/standard/streamsfuncs.c:1.12 php4/ext/standard/streamsfuncs.c:1.13 --- php4/ext/standard/streamsfuncs.c:1.12 Sat Apr 19 21:18:58 2003 +++ php4/ext/standard/streamsfuncs.c Wed May 21 09:33:55 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: streamsfuncs.c,v 1.12 2003/04/20 01:18:58 pollita Exp $ */ +/* $Id: streamsfuncs.c,v 1.13 2003/05/21 13:33:55 wez Exp $ */ #include "php.h" #include "php_globals.h" @@ -123,6 +123,10 @@ } php_stream_to_zval(stream, return_value); + + if (zcontext) { + zend_list_addref(Z_RESVAL_P(zcontext)); + } } /* }}} */ @@ -185,6 +189,9 @@ php_stream_to_zval(stream, return_value); + if (zcontext) { + zend_list_addref(Z_RESVAL_P(zcontext)); + } } /* }}} */ @@ -752,7 +759,6 @@ /* handle the array syntax */ RETVAL_BOOL(parse_context_options(context, options) == SUCCESS); } else { - ZVAL_ADDREF(zvalue); php_stream_context_set_option(context, wrappername, optionname, zvalue); RETVAL_TRUE; } Index: php4/ext/standard/file.c diff -u php4/ext/standard/file.c:1.341 php4/ext/standard/file.c:1.342 --- php4/ext/standard/file.c:1.341 Wed May 21 00:04:50 2003 +++ php4/ext/standard/file.c Wed May 21 09:33:55 2003 @@ -21,7 +21,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: file.c,v 1.341 2003/05/21 04:04:50 pollita Exp $ */ +/* $Id: file.c,v 1.342 2003/05/21 13:33:55 wez Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -693,7 +693,9 @@ php_stream_to_zval(stream, return_value); - return; + if (zcontext) { + zend_list_addref(Z_RESVAL_P(zcontext)); + } } /* }}} */

« previous php.cvs (#21173) next »