pollita Fri Jul 16 19:40:21 2004 EDT Modified files: /php-src/ext/standard filters.c Log: convert.* filters not consuming buckets_in on PSFS_FLUSH_* http://cvs.php.net/diff.php/php-src/ext/standard/filters.c?r1=1.38&r2=1.39&ty=u Index: php-src/ext/standard/filters.c diff -u php-src/ext/standard/filters.c:1.38 php-src/ext/standard/filters.c:1.39 --- php-src/ext/standard/filters.c:1.38 Thu Jan 8 03:17:31 2004 +++ php-src/ext/standard/filters.c Fri Jul 16 19:40:21 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: filters.c,v 1.38 2004/01/08 08:17:31 andi Exp $ */ +/* $Id: filters.c,v 1.39 2004/07/16 23:40:21 pollita Exp $ */ #include "php.h" #include "php_globals.h" @@ -1484,10 +1484,18 @@ char *pd; size_t ocnt; - if (flags != PSFS_FLAG_NORMAL) { - /* flush operation */ + /* Always wind buckets_in whether this is a flush op or not */ + while (buckets_in->head != NULL) { + const char *ps; + size_t icnt; + + bucket = buckets_in->head; + + php_stream_bucket_unlink(bucket TSRMLS_CC); + icnt = bucket->buflen; + ps = bucket->buf; - out_buf_size = 64; + out_buf_size = bucket->buflen; out_buf = pemalloc(out_buf_size, inst->persistent); ocnt = out_buf_size; pd = out_buf; @@ -1495,8 +1503,8 @@ /* trying hard to reduce the number of buckets to hand to the * next filter */ - for (;;) { - err = php_conv_convert(inst->cd, NULL, NULL, &pd, &ocnt); + while (icnt > 0) { + err = php_conv_convert(inst->cd, &ps, &icnt, &pd, &ocnt); switch (err) { case PHP_CONV_ERR_UNKNOWN: @@ -1515,9 +1523,7 @@ break; } - if (err != PHP_CONV_ERR_TOO_BIG) { - break; - } else { + if (err == PHP_CONV_ERR_TOO_BIG) { char *new_out_buf; size_t new_out_buf_size; @@ -1542,6 +1548,10 @@ } } } + + /* update consumed by the number of bytes just used */ + consumed += bucket->buflen - icnt; + /* give output bucket to next in chain */ if (out_buf_size - ocnt > 0) { new_bucket = php_stream_bucket_new(stream, out_buf, (out_buf_size - ocnt), 1, inst->persistent TSRMLS_CC); @@ -1549,85 +1559,77 @@ } else { pefree(out_buf, inst->persistent); } - } else { - while (buckets_in->head != NULL) { - const char *ps; - size_t icnt; - - bucket = buckets_in->head; - php_stream_bucket_unlink(bucket TSRMLS_CC); - icnt = bucket->buflen; - ps = bucket->buf; + php_stream_bucket_delref(bucket TSRMLS_CC); + } - out_buf_size = bucket->buflen; - out_buf = pemalloc(out_buf_size, inst->persistent); - ocnt = out_buf_size; - pd = out_buf; + if (flags != PSFS_FLAG_NORMAL) { + /* flush operation */ - /* trying hard to reduce the number of buckets to hand to the - * next filter */ + out_buf_size = 64; + out_buf = pemalloc(out_buf_size, inst->persistent); + ocnt = out_buf_size; + pd = out_buf; - while (icnt > 0) { - err = php_conv_convert(inst->cd, &ps, &icnt, &pd, &ocnt); + /* trying hard to reduce the number of buckets to hand to the + * next filter */ - switch (err) { - case PHP_CONV_ERR_UNKNOWN: - php_error_docref(NULL TSRMLS_CC, E_WARNING, "stream filter (%s): unknown error", inst->filtername); - goto out_failure; + for (;;) { + err = php_conv_convert(inst->cd, NULL, NULL, &pd, &ocnt); - case PHP_CONV_ERR_INVALID_SEQ: - php_error_docref(NULL TSRMLS_CC, E_WARNING, "stream filter (%s): invalid base64 sequence", inst->filtername); - goto out_failure; + switch (err) { + case PHP_CONV_ERR_UNKNOWN: + php_error_docref(NULL TSRMLS_CC, E_WARNING, "stream filter (%s): unknown error", inst->filtername); + goto out_failure; - case PHP_CONV_ERR_UNEXPECTED_EOS: - php_error_docref(NULL TSRMLS_CC, E_WARNING, "stream filter (%s): unexpected end of stream", inst->filtername); - goto out_failure; + case PHP_CONV_ERR_INVALID_SEQ: + php_error_docref(NULL TSRMLS_CC, E_WARNING, "stream filter (%s): invalid base64 sequence", inst->filtername); + goto out_failure; - default: - break; - } + case PHP_CONV_ERR_UNEXPECTED_EOS: + php_error_docref(NULL TSRMLS_CC, E_WARNING, "stream filter (%s): unexpected end of stream", inst->filtername); + goto out_failure; - if (err == PHP_CONV_ERR_TOO_BIG) { - char *new_out_buf; - size_t new_out_buf_size; - - new_out_buf_size = out_buf_size << 1; - - if (new_out_buf_size < out_buf_size) { - /* whoa! no bigger buckets are sold anywhere... */ - new_bucket = php_stream_bucket_new(stream, out_buf, (out_buf_size - ocnt), 1, inst->persistent TSRMLS_CC); - - php_stream_bucket_append(buckets_out, new_bucket TSRMLS_CC); - - out_buf_size = bucket->buflen; - out_buf = pemalloc(out_buf_size, inst->persistent); - ocnt = out_buf_size; - pd = out_buf; - } else { - new_out_buf = perealloc(out_buf, new_out_buf_size, inst->persistent); - pd = new_out_buf + (pd - out_buf); - ocnt += (new_out_buf_size - out_buf_size); - out_buf = new_out_buf; - out_buf_size = new_out_buf_size; - } - } + default: + break; } - /* update consumed by the number of bytes just used */ - consumed += bucket->buflen - icnt; - - /* give output bucket to next in chain */ - if (out_buf_size - ocnt > 0) { - new_bucket = php_stream_bucket_new(stream, out_buf, (out_buf_size - ocnt), 1, inst->persistent TSRMLS_CC); - php_stream_bucket_append(buckets_out, new_bucket TSRMLS_CC); + if (err != PHP_CONV_ERR_TOO_BIG) { + break; } else { - pefree(out_buf, inst->persistent); - } + char *new_out_buf; + size_t new_out_buf_size; - php_stream_bucket_delref(bucket TSRMLS_CC); + new_out_buf_size = out_buf_size << 1; + + if (new_out_buf_size < out_buf_size) { + /* whoa! no bigger buckets are sold anywhere... */ + new_bucket = php_stream_bucket_new(stream, out_buf, (out_buf_size - ocnt), 1, inst->persistent TSRMLS_CC); + + php_stream_bucket_append(buckets_out, new_bucket TSRMLS_CC); + + out_buf_size = bucket->buflen; + out_buf = pemalloc(out_buf_size, inst->persistent); + ocnt = out_buf_size; + pd = out_buf; + } else { + new_out_buf = perealloc(out_buf, new_out_buf_size, inst->persistent); + pd = new_out_buf + (pd - out_buf); + ocnt += (new_out_buf_size - out_buf_size); + out_buf = new_out_buf; + out_buf_size = new_out_buf_size; + } + } + } + /* give output bucket to next in chain */ + if (out_buf_size - ocnt > 0) { + new_bucket = php_stream_bucket_new(stream, out_buf, (out_buf_size - ocnt), 1, inst->persistent TSRMLS_CC); + php_stream_bucket_append(buckets_out, new_bucket TSRMLS_CC); + } else { + pefree(out_buf, inst->persistent); } } + if (bytes_consumed) { *bytes_consumed = consumed;
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php