Skip to content

Commit

Permalink
Update src/redis-benchmark.c
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
NanXiao committed Oct 10, 2012
1 parent 278304c commit 9eb3a7b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/redis-benchmark.c
Expand Up @@ -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;
}
Expand Down

0 comments on commit 9eb3a7b

Please sign in to comment.