pollita         Fri Jun 13 17:33:59 2003 EDT

  Modified files:              
    /php4/ext/standard  basic_functions.c file.c streamsfuncs.c 
    /php4/main/streams  php_stream_context.h streams.c 
  Log:
  Plug leak (context options not freed)
  Make contexts auto-registered, ensures userland contexts
  and C API contexts are both dealt with on request shutdown.
  Also brings contexts in keeping with streams which are already
  auto-registered.
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.614 
php4/ext/standard/basic_functions.c:1.615
--- php4/ext/standard/basic_functions.c:1.614   Tue Jun 10 16:03:37 2003
+++ php4/ext/standard/basic_functions.c Fri Jun 13 17:33:59 2003
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: basic_functions.c,v 1.614 2003/06/10 20:03:37 imajes Exp $ */
+/* $Id: basic_functions.c,v 1.615 2003/06/13 21:33:59 pollita Exp $ */
 
 #include "php.h"
 #include "php_streams.h"
@@ -1247,11 +1247,6 @@
                BG(user_filter_map) = NULL;
        }
 
-       /* cleanup any default context that was created */
-       if (FG(default_context)) {
-               php_stream_context_free(FG(default_context));
-       }
-       
        return SUCCESS;
 }
 
Index: php4/ext/standard/file.c
diff -u php4/ext/standard/file.c:1.346 php4/ext/standard/file.c:1.347
--- php4/ext/standard/file.c:1.346      Tue Jun 10 16:03:37 2003
+++ php4/ext/standard/file.c    Fri Jun 13 17:33:59 2003
@@ -21,7 +21,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: file.c,v 1.346 2003/06/10 20:03:37 imajes Exp $ */
+/* $Id: file.c,v 1.347 2003/06/13 21:33:59 pollita Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -129,7 +129,9 @@
 
 static ZEND_RSRC_DTOR_FUNC(file_context_dtor)
 {
-       php_stream_context_free((php_stream_context*)rsrc->ptr);
+       php_stream_context *context = (php_stream_context*)rsrc->ptr;
+       zval_dtor(context->options);
+       php_stream_context_free(context);
 }
 
 static void file_globals_ctor(php_file_globals *file_globals_p TSRMLS_DC)
Index: php4/ext/standard/streamsfuncs.c
diff -u php4/ext/standard/streamsfuncs.c:1.15 php4/ext/standard/streamsfuncs.c:1.16
--- php4/ext/standard/streamsfuncs.c:1.15       Tue Jun 10 16:03:38 2003
+++ php4/ext/standard/streamsfuncs.c    Fri Jun 13 17:33:59 2003
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: streamsfuncs.c,v 1.15 2003/06/10 20:03:38 imajes Exp $ */
+/* $Id: streamsfuncs.c,v 1.16 2003/06/13 21:33:59 pollita Exp $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -802,7 +802,7 @@
                parse_context_options(context, params);
        }
        
-       ZEND_REGISTER_RESOURCE(return_value, context, php_le_stream_context());
+       php_stream_context_to_zval(context, return_value);
 }
 /* }}} */
 
Index: php4/main/streams/php_stream_context.h
diff -u php4/main/streams/php_stream_context.h:1.4 
php4/main/streams/php_stream_context.h:1.5
--- php4/main/streams/php_stream_context.h:1.4  Tue Jun 10 16:03:42 2003
+++ php4/main/streams/php_stream_context.h      Fri Jun 13 17:33:59 2003
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_stream_context.h,v 1.4 2003/06/10 20:03:42 imajes Exp $ */
+/* $Id: php_stream_context.h,v 1.5 2003/06/13 21:33:59 pollita Exp $ */
 
 /* Stream context and status notification related definitions */
 
@@ -38,6 +38,8 @@
                FG(default_context) ? FG(default_context) : \
                (FG(default_context) = php_stream_context_alloc()) )
 
+#define php_stream_context_to_zval(context, zval) { ZVAL_RESOURCE(zval, 
(context)->rsrc_id); }
+
 typedef struct _php_stream_notifier {
        php_stream_notification_func func;
        void *ptr;
@@ -48,6 +50,7 @@
 struct _php_stream_context {
        php_stream_notifier *notifier;
        zval *options;  /* hash keyed by wrapper family or specific wrapper */
+       int rsrc_id;    /* used for auto-cleanup */
 };
 
 PHPAPI void php_stream_context_free(php_stream_context *context);
Index: php4/main/streams/streams.c
diff -u php4/main/streams/streams.c:1.24 php4/main/streams/streams.c:1.25
--- php4/main/streams/streams.c:1.24    Tue Jun 10 16:03:42 2003
+++ php4/main/streams/streams.c Fri Jun 13 17:33:59 2003
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: streams.c,v 1.24 2003/06/10 20:03:42 imajes Exp $ */
+/* $Id: streams.c,v 1.25 2003/06/13 21:33:59 pollita Exp $ */
 
 #define _GNU_SOURCE
 #include "php.h"
@@ -1630,6 +1630,7 @@
        MAKE_STD_ZVAL(context->options);
        array_init(context->options);
 
+       context->rsrc_id = ZEND_REGISTER_RESOURCE(NULL, context, 
php_le_stream_context());
        return context;
 }
 



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

Reply via email to