From: NanXiao Date: Wed, 10 Oct 2012 09:08:43 +0000 (+0800) Subject: Update src/redis-benchmark.c X-Git-Url: https://git.saurik.com/redis.git/commitdiff_plain/9eb3a7bc6ba041ee8f14427a68087459fc8e66f9?hp=278304cc4d2a52cd22aa82b89991854a6b9b148e 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). --- diff --git a/src/redis-benchmark.c b/src/redis-benchmark.c index 1be4c07d..d95bfd8e 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; }