[sheepdog] [PATCH] sheep: call stat_request_end() only when stat_request_begin() was called
MORITA Kazutaka
morita.kazutaka at gmail.com
Thu Aug 29 02:54:05 CEST 2013
From: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
When sheepdog is not formated yet, sheep can call stat_request_end()
without calling stat_request_begin() and it leads to a segfault.
Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
sheep/request.c | 5 +++++
sheep/sheep_priv.h | 1 +
2 files changed, 6 insertions(+)
diff --git a/sheep/request.c b/sheep/request.c
index 53d38c7..215143e 100644
--- a/sheep/request.c
+++ b/sheep/request.c
@@ -325,6 +325,8 @@ static main_fn inline void stat_request_begin(struct request *req)
{
struct sd_req *hdr = &req->rq;
+ req->stat = true;
+
if (is_peer_op(req->op)) {
sys->stat.r.peer_total_nr++;
sys->stat.r.peer_active_nr++;
@@ -344,6 +346,9 @@ static main_fn inline void stat_request_begin(struct request *req)
static main_fn inline void stat_request_end(struct request *req)
{
+ if (!req->stat)
+ return;
+
if (is_peer_op(req->op))
sys->stat.r.peer_active_nr--;
else if (is_gateway_op(req->op))
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 1cd22a4..a3206be 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -106,6 +106,7 @@ struct request {
struct work work;
enum REQUST_STATUS status;
+ bool stat; /* true if this request is during stat */
};
struct system_info {
--
1.7.9.5
More information about the sheepdog
mailing list