cvs: php-src(PHP_5_2) /main php_streams.h /main/streams plain_wrapper.c streams.c /sapi/cli php_cli.c

From: Date: Wed, 21 Feb 2007 21:57:22 +0000
Subject: cvs: php-src(PHP_5_2) /main php_streams.h /main/streams plain_wrapper.c streams.c /sapi/cli php_cli.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-43203@lists.php.net to get a copy of this message
tony2001 Wed Feb 21 21:57:22 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/main php_streams.h /php-src/main/streams plain_wrapper.c streams.c /php-src/sapi/cli php_cli.c Log: MFH: implement PHP_STREAM_FLAG_NO_CLOSE and avoid hacks http://cvs.php.net/viewvc.cgi/php-src/main/php_streams.h?r1=1.103.2.1.2.1&r2=1.103.2.1.2.2&diff_format=u Index: php-src/main/php_streams.h diff -u php-src/main/php_streams.h:1.103.2.1.2.1 php-src/main/php_streams.h:1.103.2.1.2.2 --- php-src/main/php_streams.h:1.103.2.1.2.1 Mon Jan 1 09:36:11 2007 +++ php-src/main/php_streams.h Wed Feb 21 21:57:21 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_streams.h,v 1.103.2.1.2.1 2007/01/01 09:36:11 sebastian Exp $ */ +/* $Id: php_streams.h,v 1.103.2.1.2.2 2007/02/21 21:57:21 tony2001 Exp $ */ #ifndef PHP_STREAMS_H #define PHP_STREAMS_H @@ -178,6 +178,8 @@ * might otherwise cause the read to block for much longer than * is strictly required. */ #define PHP_STREAM_FLAG_AVOID_BLOCKING 16 + +#define PHP_STREAM_FLAG_NO_CLOSE 32 struct _php_stream { php_stream_ops *ops; http://cvs.php.net/viewvc.cgi/php-src/main/streams/plain_wrapper.c?r1=1.52.2.6.2.15&r2=1.52.2.6.2.16&diff_format=u Index: php-src/main/streams/plain_wrapper.c diff -u php-src/main/streams/plain_wrapper.c:1.52.2.6.2.15 php-src/main/streams/plain_wrapper.c:1.52.2.6.2.16 --- php-src/main/streams/plain_wrapper.c:1.52.2.6.2.15 Tue Feb 13 23:39:14 2007 +++ php-src/main/streams/plain_wrapper.c Wed Feb 21 21:57:21 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: plain_wrapper.c,v 1.52.2.6.2.15 2007/02/13 23:39:14 iliaa Exp $ */ +/* $Id: plain_wrapper.c,v 1.52.2.6.2.16 2007/02/21 21:57:21 tony2001 Exp $ */ #include "php.h" #include "php_globals.h" @@ -392,16 +392,7 @@ data->file = NULL; } } else if (data->fd != -1) { -#if PHP_DEBUG - if ((data->fd == 1 || data->fd == 2) && 0 == strcmp(sapi_module.name, "cli")) { - /* don't close stdout or stderr in CLI in DEBUG mode, as we want to see any leaks */ - ret = 0; - } else { - ret = close(data->fd); - } -#else ret = close(data->fd); -#endif data->fd = -1; } else { return 0; /* everything should be closed already -> success */ http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.82.2.6.2.10&r2=1.82.2.6.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.10 php-src/main/streams/streams.c:1.82.2.6.2.11 --- php-src/main/streams/streams.c:1.82.2.6.2.10 Mon Jan 15 17:07:07 2007 +++ php-src/main/streams/streams.c Wed Feb 21 21:57:21 2007 @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: streams.c,v 1.82.2.6.2.10 2007/01/15 17:07:07 tony2001 Exp $ */ +/* $Id: streams.c,v 1.82.2.6.2.11 2007/02/21 21:57:21 tony2001 Exp $ */ #define _GNU_SOURCE #include "php.h" @@ -279,6 +279,10 @@ int preserve_handle = close_options & PHP_STREAM_FREE_PRESERVE_HANDLE ? 1 : 0; int release_cast = 1; + if (stream->flags & PHP_STREAM_FLAG_NO_CLOSE) { + preserve_handle = 1; + } + #if STREAM_DEBUG fprintf(stderr, "stream_free: %s:%p[%s] in_free=%d opts=%08x\n", stream->ops->label, stream, stream->orig_path, stream->in_free, close_options); #endif http://cvs.php.net/viewvc.cgi/php-src/sapi/cli/php_cli.c?r1=1.129.2.13.2.14&r2=1.129.2.13.2.15&diff_format=u Index: php-src/sapi/cli/php_cli.c diff -u php-src/sapi/cli/php_cli.c:1.129.2.13.2.14 php-src/sapi/cli/php_cli.c:1.129.2.13.2.15 --- php-src/sapi/cli/php_cli.c:1.129.2.13.2.14 Tue Feb 20 19:20:41 2007 +++ php-src/sapi/cli/php_cli.c Wed Feb 21 21:57:21 2007 @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_cli.c,v 1.129.2.13.2.14 2007/02/20 19:20:41 tony2001 Exp $ */ +/* $Id: php_cli.c,v 1.129.2.13.2.15 2007/02/21 21:57:21 tony2001 Exp $ */ #include "php.h" #include "php_globals.h" @@ -476,6 +476,12 @@ s_out = php_stream_open_wrapper_ex("php://stdout", "wb", 0, NULL, sc_out); s_err = php_stream_open_wrapper_ex("php://stderr", "wb", 0, NULL, sc_err); +#if PHP_DEBUG + /* do not close stdout and stderr */ + s_out->flags |= PHP_STREAM_FLAG_NO_CLOSE; + s_err->flags |= PHP_STREAM_FLAG_NO_CLOSE; +#endif + if (s_in==NULL || s_out==NULL || s_err==NULL) { FREE_ZVAL(zin); FREE_ZVAL(zout);

« previous php.cvs (#43203) next »