From 99bd9f758af3f86d12cca86d71a8f842bb61d571 Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Mon, 15 Jan 2007 22:19:33 +0000 Subject: [PATCH] - Help streams debugging --- main/php_streams.h | 5 +++++ main/streams/cast.c | 5 +++++ main/streams/streams.c | 11 ++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/main/php_streams.h b/main/php_streams.h index 8bd694561d..eab472d683 100755 --- a/main/php_streams.h +++ b/main/php_streams.h @@ -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 diff --git a/main/streams/cast.c b/main/streams/cast.c index e1f71216d0..02e2282b68 100644 --- a/main/streams/cast.c +++ b/main/streams/cast.c @@ -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; diff --git a/main/streams/streams.c b/main/streams/streams.c index cba7765734..f7ed82cf9d 100755 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -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)) { -- 2.40.0