tony2001                Wed Feb 21 21:56:45 2007 UTC

  Modified files:              
    /php-src/main       php_streams.h 
    /php-src/main/streams       plain_wrapper.c streams.c 
    /php-src/sapi/cli   php_cli.c 
  Log:
  implement PHP_STREAM_FLAG_NO_CLOSE and avoid hacks in plain wrapper
  
  
http://cvs.php.net/viewvc.cgi/php-src/main/php_streams.h?r1=1.124&r2=1.125&diff_format=u
Index: php-src/main/php_streams.h
diff -u php-src/main/php_streams.h:1.124 php-src/main/php_streams.h:1.125
--- php-src/main/php_streams.h:1.124    Wed Jan 24 21:43:47 2007
+++ php-src/main/php_streams.h  Wed Feb 21 21:56:45 2007
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_streams.h,v 1.124 2007/01/24 21:43:47 pollita Exp $ */
+/* $Id: php_streams.h,v 1.125 2007/02/21 21:56:45 tony2001 Exp $ */
 
 #ifndef PHP_STREAMS_H
 #define PHP_STREAMS_H
@@ -186,6 +186,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.80&r2=1.81&diff_format=u
Index: php-src/main/streams/plain_wrapper.c
diff -u php-src/main/streams/plain_wrapper.c:1.80 
php-src/main/streams/plain_wrapper.c:1.81
--- php-src/main/streams/plain_wrapper.c:1.80   Mon Jan  1 09:29:35 2007
+++ php-src/main/streams/plain_wrapper.c        Wed Feb 21 21:56:45 2007
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: plain_wrapper.c,v 1.80 2007/01/01 09:29:35 sebastian Exp $ */
+/* $Id: plain_wrapper.c,v 1.81 2007/02/21 21:56:45 tony2001 Exp $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -396,16 +396,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.147&r2=1.148&diff_format=u
Index: php-src/main/streams/streams.c
diff -u php-src/main/streams/streams.c:1.147 
php-src/main/streams/streams.c:1.148
--- php-src/main/streams/streams.c:1.147        Wed Jan 24 21:43:47 2007
+++ php-src/main/streams/streams.c      Wed Feb 21 21:56:45 2007
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: streams.c,v 1.147 2007/01/24 21:43:47 pollita Exp $ */
+/* $Id: streams.c,v 1.148 2007/02/21 21:56:45 tony2001 Exp $ */
 
 #define _GNU_SOURCE
 #include "php.h"
@@ -285,6 +285,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.168&r2=1.169&diff_format=u
Index: php-src/sapi/cli/php_cli.c
diff -u php-src/sapi/cli/php_cli.c:1.168 php-src/sapi/cli/php_cli.c:1.169
--- php-src/sapi/cli/php_cli.c:1.168    Tue Feb 20 19:19:14 2007
+++ php-src/sapi/cli/php_cli.c  Wed Feb 21 21:56:45 2007
@@ -20,7 +20,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_cli.c,v 1.168 2007/02/20 19:19:14 tony2001 Exp $ */
+/* $Id: php_cli.c,v 1.169 2007/02/21 21:56:45 tony2001 Exp $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -487,6 +487,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);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to