]> granicus.if.org Git - php/commitdiff
- Help streams debugging
authorMarcus Boerger <helly@php.net>
Mon, 15 Jan 2007 22:19:33 +0000 (22:19 +0000)
committerMarcus Boerger <helly@php.net>
Mon, 15 Jan 2007 22:19:33 +0000 (22:19 +0000)
main/php_streams.h
main/streams/cast.c
main/streams/streams.c

index 8bd694561d0146e8ea84ddb5c47f768824d984ec..eab472d683438e651d97cc3fda0b0f540a5393be 100755 (executable)
@@ -225,7 +225,12 @@ struct _php_stream  {
 
        int eof;
 
+#if ZEND_DEBUG
+       char *open_filename;
+       uint open_lineno;
+#endif
 }; /* php_stream */
+
 /* state definitions when closing down; these are private to streams.c */
 #define PHP_STREAM_FCLOSE_NONE 0
 #define PHP_STREAM_FCLOSE_FDOPEN       1
index e1f71216d040484ff7957d1b61308a9934768c0b..02e2282b68291d8b2ad4b8ef69cbeeb1a9770796 100644 (file)
@@ -327,6 +327,11 @@ PHPAPI int _php_stream_make_seekable(php_stream *origstream, php_stream **newstr
        if (*newstream == NULL)
                return PHP_STREAM_FAILED;
 
+#if ZEND_DEBUG
+       (*newstream)->open_filename = origstream->open_filename;
+       (*newstream)->open_lineno = origstream->open_lineno;
+#endif
+
        if (php_stream_copy_to_stream(origstream, *newstream, PHP_STREAM_COPY_ALL) == 0) {
                php_stream_close(*newstream);
                *newstream = NULL;
index cba77657343389f155fe8e73c14c1fa3f3900d13..f7ed82cf9dc42d01eb72663c564f1c222c6b5f89 100755 (executable)
@@ -241,6 +241,11 @@ fprintf(stderr, "stream_alloc: %s:%p persistent=%s\n", ops->label, ret, persiste
        ret->chunk_size = FG(def_chunk_size);
        ret->readbuf_type = IS_STRING;
 
+#if ZEND_DEBUG
+       ret->open_filename = __zend_orig_filename ? __zend_orig_filename : __zend_filename;
+       ret->open_lineno = __zend_orig_lineno ? __zend_orig_lineno : __zend_lineno;
+#endif
+
        if (FG(auto_detect_line_endings)) {
                ret->flags |= PHP_STREAM_FLAG_DETECT_EOL;
        }
@@ -384,7 +389,7 @@ fprintf(stderr, "stream_free: %s:%p[%s] preserve_handle=%d release_cast=%d remov
                         * as leaked; it will log a warning, but lets help it out and display what kind
                         * of stream it was. */
                        char *leakinfo;
-                       spprintf(&leakinfo, 0, __FILE__ "(%d) : Stream of type '%s' %p (path:%s) was not closed\n", __LINE__, stream->ops->label, stream, stream->orig_path);
+                       spprintf(&leakinfo, 0, __FILE__ "(%d) : Stream of type '%s' %p (path:%s) was not closed (opened in %s on line %d)\n", __LINE__, stream->ops->label, stream, stream->orig_path, stream->open_filename, stream->open_lineno);
 
                        if (stream->orig_path) {
                                pefree(stream->orig_path, stream->is_persistent);
@@ -2376,6 +2381,10 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(char *path, char *mode, int optio
                }
                copy_of_path = pestrdup(path, persistent);
                stream->orig_path = copy_of_path;
+#if ZEND_DEBUG
+               stream->open_filename = __zend_orig_filename ? __zend_orig_filename : __zend_filename;
+               stream->open_lineno = __zend_orig_lineno ? __zend_orig_lineno : __zend_lineno;
+#endif
        }
 
        if (stream != NULL && (options & STREAM_MUST_SEEK)) {