[PHP-CVS] cvs: php-src(PHP_5_3) /main/streams streams.c
lbarnaudThu Mar 19 17:55:10 2009 UTC Modified files: (Branch: PHP_5_3) /php-src/main/streams streams.c Log: MFH: Better fix for #44607. Fixes #47487 (php_stream_fill_read_buffer() performance degraded after fix of bug 44607). http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.82.2.6.2.18.2.23r2=1.82.2.6.2.18.2.24diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.82.2.6.2.18.2.23 php-src/main/streams/streams.c:1.82.2.6.2.18.2.24 --- php-src/main/streams/streams.c:1.82.2.6.2.18.2.23 Thu Jan 8 18:46:00 2009 +++ php-src/main/streams/streams.c Thu Mar 19 17:55:10 2009 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.82.2.6.2.18.2.23 2009/01/08 18:46:00 felipe Exp $ */ +/* $Id: streams.c,v 1.82.2.6.2.18.2.24 2009/03/19 17:55:10 lbarnaud Exp $ */ #define _GNU_SOURCE #include php.h @@ -540,16 +540,16 @@ efree(chunk_buf); } else { - /* reduce buffer memory consumption if possible, to avoid a realloc */ - if (stream-readbuf stream-readbuflen - stream-writepos stream-chunk_size) { - memmove(stream-readbuf, stream-readbuf + stream-readpos, stream-readbuflen - stream-readpos); - stream-writepos -= stream-readpos; - stream-readpos = 0; - } /* is there enough data in the buffer ? */ - while (stream-writepos - stream-readpos (off_t)size) { + if (stream-writepos - stream-readpos (off_t)size) { size_t justread = 0; - size_t toread; + + /* reduce buffer memory consumption if possible, to avoid a realloc */ + if (stream-readbuf stream-readbuflen - stream-writepos stream-chunk_size) { + memmove(stream-readbuf, stream-readbuf + stream-readpos, stream-readbuflen - stream-readpos); + stream-writepos -= stream-readpos; + stream-readpos = 0; + } /* grow the buffer if required * TODO: this can fail for persistent streams */ @@ -559,17 +559,13 @@ stream-is_persistent); } - toread = stream-readbuflen - stream-writepos; justread = stream-ops-read(stream, stream-readbuf + stream-writepos, - toread + stream-readbuflen - stream-writepos TSRMLS_CC); if (justread != (size_t)-1) { stream-writepos += justread; } - if (stream-eof || justread != toread) { - break; - } } } } @@ -868,10 +864,25 @@ PHPAPI char *php_stream_get_record(php_stream *stream, size_t maxlen, size_t *returned_len, char *delim, size_t delim_len TSRMLS_DC) { char *e, *buf; - size_t toread; + size_t toread, len; int skip = 0; - php_stream_fill_read_buffer(stream, maxlen TSRMLS_CC); + len = stream-writepos - stream-readpos; + + while (len maxlen) { + + size_t just_read; + toread = MIN(maxlen - len, stream-chunk_size); + + php_stream_fill_read_buffer(stream, len + toread TSRMLS_CC); + + just_read = (stream-writepos - stream-readpos) - len; + len += just_read; + + if (just_read toread) { + break; + } + } if (delim_len == 0 || !delim) { toread = maxlen; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /main/streams streams.c
felipe Thu Jan 8 18:46:00 2009 UTC Modified files: (Branch: PHP_5_3) /php-src/main/streams streams.c Log: MFH: - Fixed bug #47037 (No error when using fopen with emty string) Patch by Cristian Rodriguez R. http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.82.2.6.2.18.2.22r2=1.82.2.6.2.18.2.23diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.82.2.6.2.18.2.22 php-src/main/streams/streams.c:1.82.2.6.2.18.2.23 --- php-src/main/streams/streams.c:1.82.2.6.2.18.2.22 Wed Dec 31 11:15:48 2008 +++ php-src/main/streams/streams.c Thu Jan 8 18:46:00 2009 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.82.2.6.2.18.2.22 2008/12/31 11:15:48 sebastian Exp $ */ +/* $Id: streams.c,v 1.82.2.6.2.18.2.23 2009/01/08 18:46:00 felipe Exp $ */ #define _GNU_SOURCE #include php.h @@ -1783,6 +1783,7 @@ } if (!path || !*path) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, Filename cannot be empty); return NULL; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src(PHP_5_3) /main/streams streams.c
On 08.01.2009 21:46, Felipe Pena wrote: felipeThu Jan 8 18:46:00 2009 UTC Modified files: (Branch: PHP_5_3) /php-src/main/streams streams.c Log: MFH: - Fixed bug #47037 (No error when using fopen with emty string) Patch by Cristian Rodriguez R. Would you mind fixing these tests, too? Thanks. 5_2/ext/tidy/tests/019.phpt 5_2/ext/tidy/tests/022.phpt 5_2/ext/standard/tests/strings/md5_file.phpt 5_2/ext/standard/tests/file/readfile_variation10.phpt 5_2/ext/standard/tests/file/file_put_contents_variation8.phpt 5_2/ext/exif/tests/exif_imagetype_variation1.phpt -- Wbr, Antony Dovgal -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src(PHP_5_3) /main/streams streams.c
Em Sex, 2009-01-09 às 00:27 +0300, Antony Dovgal escreveu: On 08.01.2009 21:46, Felipe Pena wrote: felipe Thu Jan 8 18:46:00 2009 UTC Modified files: (Branch: PHP_5_3) /php-src/main/streams streams.c Log: MFH: - Fixed bug #47037 (No error when using fopen with emty string) Patch by Cristian Rodriguez R. Would you mind fixing these tests, too? Thanks. 5_2/ext/tidy/tests/019.phpt 5_2/ext/tidy/tests/022.phpt 5_2/ext/standard/tests/strings/md5_file.phpt 5_2/ext/standard/tests/file/readfile_variation10.phpt 5_2/ext/standard/tests/file/file_put_contents_variation8.phpt 5_2/ext/exif/tests/exif_imagetype_variation1.phpt Ops, np! I'll fix them. Thanks Tony ;) -- Regards, Felipe Pena -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /main/streams streams.c xp_socket.c
dsp Mon Nov 24 15:36:47 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/main/streams streams.c xp_socket.c Log: MFH: Revert fix for 43782, as it caused problems. http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.82.2.6.2.18.2.19r2=1.82.2.6.2.18.2.20diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.82.2.6.2.18.2.19 php-src/main/streams/streams.c:1.82.2.6.2.18.2.20 --- php-src/main/streams/streams.c:1.82.2.6.2.18.2.19 Tue Nov 11 01:55:51 2008 +++ php-src/main/streams/streams.c Mon Nov 24 15:36:47 2008 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.82.2.6.2.18.2.19 2008/11/11 01:55:51 lbarnaud Exp $ */ +/* $Id: streams.c,v 1.82.2.6.2.18.2.20 2008/11/24 15:36:47 dsp Exp $ */ #define _GNU_SOURCE #include php.h @@ -650,7 +650,7 @@ /* use the configured timeout when checking eof */ if (!stream-eof PHP_STREAM_OPTION_RETURN_ERR == php_stream_set_option(stream, PHP_STREAM_OPTION_CHECK_LIVENESS, - -1, NULL)) { + 0, NULL)) { stream-eof = 1; } http://cvs.php.net/viewvc.cgi/php-src/main/streams/xp_socket.c?r1=1.33.2.2.2.6.2.6r2=1.33.2.2.2.6.2.7diff_format=u Index: php-src/main/streams/xp_socket.c diff -u php-src/main/streams/xp_socket.c:1.33.2.2.2.6.2.6 php-src/main/streams/xp_socket.c:1.33.2.2.2.6.2.7 --- php-src/main/streams/xp_socket.c:1.33.2.2.2.6.2.6 Tue Aug 26 16:06:36 2008 +++ php-src/main/streams/xp_socket.cMon Nov 24 15:36:47 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: xp_socket.c,v 1.33.2.2.2.6.2.6 2008/08/26 16:06:36 dsp Exp $ */ +/* $Id: xp_socket.c,v 1.33.2.2.2.6.2.7 2008/11/24 15:36:47 dsp Exp $ */ #include php.h #include ext/standard/file.h @@ -280,12 +280,8 @@ if (sock-socket == -1) { alive = 0; - } else { - if (php_pollfd_for(sock-socket, PHP_POLLREADABLE|POLLPRI, tv) 0) { - if (0 == recv(sock-socket, buf, sizeof(buf), MSG_PEEK) php_socket_errno() != EAGAIN) { - alive = 0; - } - } else { + } else if (php_pollfd_for(sock-socket, PHP_POLLREADABLE|POLLPRI, tv) 0) { + if (0 == recv(sock-socket, buf, sizeof(buf), MSG_PEEK) php_socket_errno() != EAGAIN) { alive = 0; } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /main/streams streams.c
tony2001Wed Aug 6 09:03:48 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/main/streams streams.c Log: MFH: increase context refcount before open() to avoid crash when open() fails and destroys the context http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.82.2.6.2.18.2.12r2=1.82.2.6.2.18.2.13diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.82.2.6.2.18.2.12 php-src/main/streams/streams.c:1.82.2.6.2.18.2.13 --- php-src/main/streams/streams.c:1.82.2.6.2.18.2.12 Fri Jul 11 12:40:28 2008 +++ php-src/main/streams/streams.c Wed Aug 6 09:03:48 2008 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.82.2.6.2.18.2.12 2008/07/11 12:40:28 tony2001 Exp $ */ +/* $Id: streams.c,v 1.82.2.6.2.18.2.13 2008/08/06 09:03:48 tony2001 Exp $ */ #define _GNU_SOURCE #include php.h @@ -1801,14 +1801,22 @@ php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC, wrapper does not support stream open); } else { + /* refcount++ to make sure the context doesn't get destroyed +* if open() fails and stream is closed */ + if (context) { + zend_list_addref(context-rsrc_id); + } + stream = wrapper-wops-stream_opener(wrapper, path_to_open, mode, options ^ REPORT_ERRORS, opened_path, context STREAMS_REL_CC TSRMLS_CC); - } - /* increase context refcount only if the context is really used */ - if (stream stream-context) { - zend_list_addref(stream-context-rsrc_id); + /* if open() succeeded and context was not used, do refcount-- +* XXX if a wrapper didn't actually use context (no way to know that) +* and open() failed, refcount will stay increased */ + if (context stream !stream-context) { + zend_list_delete(context-rsrc_id); + } } /* if the caller asked for a persistent stream but the wrapper did not -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src(PHP_5_3) /main/streams streams.c
Antony Dovgal kirjoitti: tony2001Wed Aug 6 09:03:48 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/main/streams streams.c Log: MFH: increase context refcount before open() to avoid crash when open() fails and destroys the context [snip] Isn't this a bug fix which should be MFH'd to PHP_5_2 as well? --Jani -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src(PHP_5_3) /main/streams streams.c
On 06.08.2008 19:19, Jani Taskinen wrote: Antony Dovgal kirjoitti: tony2001Wed Aug 6 09:03:48 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/main/streams streams.c Log: MFH: increase context refcount before open() to avoid crash when open() fails and destroys the context [snip] Isn't this a bug fix which should be MFH'd to PHP_5_2 as well? No, this is a fix for my previous patch, which I didn't commit to 5_2 (as it's a bugfix and an improvement in the same time). -- Wbr, Antony Dovgal -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /main/streams streams.c
tony2001Fri Jul 11 12:40:28 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/main/streams streams.c Log: MFH http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.82.2.6.2.18.2.11r2=1.82.2.6.2.18.2.12diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.82.2.6.2.18.2.11 php-src/main/streams/streams.c:1.82.2.6.2.18.2.12 --- php-src/main/streams/streams.c:1.82.2.6.2.18.2.11 Fri Jul 11 10:25:15 2008 +++ php-src/main/streams/streams.c Fri Jul 11 12:40:28 2008 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.82.2.6.2.18.2.11 2008/07/11 10:25:15 tony2001 Exp $ */ +/* $Id: streams.c,v 1.82.2.6.2.18.2.12 2008/07/11 12:40:28 tony2001 Exp $ */ #define _GNU_SOURCE #include php.h @@ -1806,8 +1806,9 @@ opened_path, context STREAMS_REL_CC TSRMLS_CC); } - if (context) { - zend_list_addref(context-rsrc_id); + /* increase context refcount only if the context is really used */ + if (stream stream-context) { + zend_list_addref(stream-context-rsrc_id); } /* if the caller asked for a persistent stream but the wrapper did not -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /main/streams streams.c
cellog Mon Apr 28 22:39:54 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/main/streams streams.c Log: fix erroneous use of php_resolve_path in _php_stream_wrapper_open_ex - this breaks require/include for all extensions that intercept zend_resolve_path http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.82.2.6.2.18.2.8r2=1.82.2.6.2.18.2.9diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.82.2.6.2.18.2.8 php-src/main/streams/streams.c:1.82.2.6.2.18.2.9 --- php-src/main/streams/streams.c:1.82.2.6.2.18.2.8Mon Apr 28 22:37:31 2008 +++ php-src/main/streams/streams.c Mon Apr 28 22:39:54 2008 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.82.2.6.2.18.2.8 2008/04/28 22:37:31 cellog Exp $ */ +/* $Id: streams.c,v 1.82.2.6.2.18.2.9 2008/04/28 22:39:54 cellog Exp $ */ #define _GNU_SOURCE #include php.h @@ -1771,7 +1771,7 @@ } if (options USE_PATH) { - resolved_path = php_resolve_path(path, strlen(path), PG(include_path) TSRMLS_CC); + resolved_path = zend_resolve_path(path, strlen(path) TSRMLS_CC); if (resolved_path) { path = resolved_path; /* we've found this file, don't re-check include_path or run realpath */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /main/streams streams.c
tony2001Mon Mar 24 16:28:35 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/main/streams streams.c Log: MFH: disabled mmap() when copying files to memory http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.82.2.6.2.18.2.5r2=1.82.2.6.2.18.2.6diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.82.2.6.2.18.2.5 php-src/main/streams/streams.c:1.82.2.6.2.18.2.6 --- php-src/main/streams/streams.c:1.82.2.6.2.18.2.5Sat Jan 12 15:50:57 2008 +++ php-src/main/streams/streams.c Mon Mar 24 16:28:35 2008 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.82.2.6.2.18.2.5 2008/01/12 15:50:57 cellog Exp $ */ +/* $Id: streams.c,v 1.82.2.6.2.18.2.6 2008/03/24 16:28:35 tony2001 Exp $ */ #define _GNU_SOURCE #include php.h @@ -1221,26 +1221,6 @@ maxlen = 0; } - if (php_stream_mmap_possible(src)) { - char *p; - size_t mapped; - - p = php_stream_mmap_range(src, php_stream_tell(src), maxlen, PHP_STREAM_MAP_MODE_SHARED_READONLY, mapped); - - if (p mapped) { - *buf = pemalloc_rel_orig(mapped + 1, persistent); - - if (*buf) { - memcpy(*buf, p, mapped); - (*buf)[mapped] = '\0'; - } - - php_stream_mmap_unmap(src); - - return mapped; - } - } - if (maxlen 0) { ptr = *buf = pemalloc_rel_orig(maxlen + 1, persistent); while ((len maxlen) !php_stream_eof(src)) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /main/streams streams.c
tony2001Sat Dec 29 10:52:24 2007 UTC Modified files: (Branch: PHP_5_3) /php-src/main/streams streams.c Log: correct fix for bug #43522 http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.82.2.6.2.18.2.2r2=1.82.2.6.2.18.2.3diff_format=u Index: php-src/main/streams/streams.c diff -u php-src/main/streams/streams.c:1.82.2.6.2.18.2.2 php-src/main/streams/streams.c:1.82.2.6.2.18.2.3 --- php-src/main/streams/streams.c:1.82.2.6.2.18.2.2Mon Dec 10 14:16:57 2007 +++ php-src/main/streams/streams.c Sat Dec 29 10:52:24 2007 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: streams.c,v 1.82.2.6.2.18.2.2 2007/12/10 14:16:57 iliaa Exp $ */ +/* $Id: streams.c,v 1.82.2.6.2.18.2.3 2007/12/29 10:52:24 tony2001 Exp $ */ #define _GNU_SOURCE #include php.h @@ -859,10 +859,17 @@ if (delim_len == 0 || !delim) { toread = maxlen; } else { + size_t seek_len; + + seek_len = stream-writepos - stream-readpos; + if (seek_len maxlen) { + seek_len = maxlen; + } + if (delim_len == 1) { - e = memchr(stream-readbuf + stream-readpos, *delim, maxlen); + e = memchr(stream-readbuf + stream-readpos, *delim, seek_len); } else { - e = php_memnstr(stream-readbuf + stream-readpos, delim, delim_len, (stream-readbuf + stream-readpos + maxlen)); + e = php_memnstr(stream-readbuf + stream-readpos, delim, delim_len, (stream-readbuf + stream-readpos + seek_len)); } if (!e) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php