diff options
author | NanXiao <xn212516@163.com> | 2012-10-10 17:08:43 +0800 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2012-10-18 11:05:47 +0200 |
commit | a03c32702b87b99079db1c2083f023dd1f0fc863 (patch) | |
tree | a25be27a27f5323e214b3ed8512defb1ba166a40 | |
parent | 21645232444ddfffcdd27563bb751f266f7e1be8 (diff) | |
download | redis-a03c32702b87b99079db1c2083f023dd1f0fc863.tar.gz |
Update src/redis-benchmark.c
The code of current implementation:
if (c->pending == 0) clientDone(c);
In clientDone function, the c's memory has been freed, then the loop will continue: while(c->pending). The memory of c has been freed now, so c->pending is invalid (c is an invalid pointer now), and this will cause memory dump in some platforams(eg: Solaris).
So I think the code should be modified as:
if (c->pending == 0)
{
clientDone(c);
break;
}
and this will not lead to while(c->pending).
-rw-r--r-- | src/redis-benchmark.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/redis-benchmark.c b/src/redis-benchmark.c index 1be4c07d9..d95bfd8ea 100644 --- a/src/redis-benchmark.c +++ b/src/redis-benchmark.c @@ -201,7 +201,10 @@ static void readHandler(aeEventLoop *el, int fd, void *privdata, int mask) { if (config.requests_finished < config.requests) config.latency[config.requests_finished++] = c->latency; c->pending--; - if (c->pending == 0) clientDone(c); + if (c->pending == 0) { + clientDone(c); + break; + } } else { break; } |