summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Hristov <andrey@php.net>2010-12-15 14:14:58 +0000
committerAndrey Hristov <andrey@php.net>2010-12-15 14:14:58 +0000
commitf35b89c7c459013ac3c07e149ce9011a21dbd6a4 (patch)
treea91726de979fb2f3fc18f984f2eb41d9f97a2d3d
parentc4f631b275b4576d5d32f9c291868c13bef99317 (diff)
downloadphp-git-f35b89c7c459013ac3c07e149ce9011a21dbd6a4.tar.gz
count preciser in case of error
-rw-r--r--ext/mysqlnd/mysqlnd_net.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/ext/mysqlnd/mysqlnd_net.c b/ext/mysqlnd/mysqlnd_net.c
index b6ee73dbb6..45e1471ebc 100644
--- a/ext/mysqlnd/mysqlnd_net.c
+++ b/ext/mysqlnd/mysqlnd_net.c
@@ -64,6 +64,7 @@ mysqlnd_set_sock_no_delay(php_stream * stream TSRMLS_DC)
static enum_func_status
MYSQLND_METHOD(mysqlnd_net, network_read)(MYSQLND * conn, zend_uchar * buffer, size_t count TSRMLS_DC)
{
+ enum_func_status return_value = PASS;
size_t to_read = count, ret;
size_t old_chunk_size = conn->net->stream->chunk_size;
DBG_ENTER("mysqlnd_net::network_read");
@@ -72,14 +73,15 @@ MYSQLND_METHOD(mysqlnd_net, network_read)(MYSQLND * conn, zend_uchar * buffer, s
while (to_read) {
if (!(ret = php_stream_read(conn->net->stream, (char *) buffer, to_read))) {
DBG_ERR_FMT("Error while reading header from socket");
- DBG_RETURN(FAIL);
+ return_value = FAIL;
+ break;
}
buffer += ret;
to_read -= ret;
}
- MYSQLND_INC_CONN_STATISTIC_W_VALUE(conn->stats, STAT_BYTES_RECEIVED, count);
+ MYSQLND_INC_CONN_STATISTIC_W_VALUE(conn->stats, STAT_BYTES_RECEIVED, count - to_read);
conn->net->stream->chunk_size = old_chunk_size;
- DBG_RETURN(PASS);
+ DBG_RETURN(return_value);
}
/* }}} */