aboutsummaryrefslogtreecommitdiffstats
path: root/fbench/src/fbench/client.cpp
diff options
context:
space:
mode:
authorArne H Juul <arnej@yahoo-inc.com>2017-05-09 15:34:34 +0200
committerArne H Juul <arnej@yahoo-inc.com>2017-05-09 15:34:34 +0200
commit4da5bd312d1d2062a25795473f3e77a88f8f3fd8 (patch)
tree41e7ef6f2759b6c634bbe19226736c46af498b38 /fbench/src/fbench/client.cpp
parentca6b491fd3832111d4cd0b910d43b90ece7044e1 (diff)
fix double-counting in getContent()
Diffstat (limited to 'fbench/src/fbench/client.cpp')
-rw-r--r--fbench/src/fbench/client.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/fbench/src/fbench/client.cpp b/fbench/src/fbench/client.cpp
index 6f585e33637..330c62703af 100644
--- a/fbench/src/fbench/client.cpp
+++ b/fbench/src/fbench/client.cpp
@@ -58,22 +58,22 @@ public:
int findUrl(char *buf, int buflen);
int nextUrl(char *buf, int buflen);
int getContent();
- char *content() const { return _contentbuf; }
+ const char *content() const { return _contentbuf; }
~UrlReader() { delete [] _contentbuf; }
};
bool UrlReader::reset()
{
- _reader.Reset();
- // Start reading from offset
- if (_args._singleQueryFile) {
- _reader.SetFilePos(_args._queryfileOffset);
- }
if (_restarts == _args._restartLimit) {
return false;
} else if (_args._restartLimit > 0) {
_restarts++;
}
+ _reader.Reset();
+ // Start reading from offset
+ if (_args._singleQueryFile) {
+ _reader.SetFilePos(_args._queryfileOffset);
+ }
return true;
}
@@ -121,10 +121,10 @@ int UrlReader::nextUrl(char *buf, int buflen)
int UrlReader::getContent()
{
char *buf = _contentbuf;
- int bufLen = _contentbufsize;
int totLen = 0;
- while (totLen < bufLen) {
- int len = _reader.ReadLine(buf, bufLen);
+ while (totLen < _contentbufsize) {
+ int left = _contentbufsize - totLen;
+ int len = _reader.ReadLine(buf, left);
if (len < 0) {
// reached EOF
return totLen;
@@ -136,7 +136,6 @@ int UrlReader::getContent()
return totLen;
}
buf += len;
- bufLen -= len;
totLen += len;
}
return totLen;