[sheepdog] [PATCH 6/8] sheep: use main_refcnt_t for client_info
Hitoshi Mitake
mitake.hitoshi at lab.ntt.co.jp
Tue Jul 9 04:36:40 CEST 2013
Get and put of client_info are only allowed for the main thread. So
this patch changes the type of current refnct of client_info from int
to main_refcnt_t.
Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
sheep/request.c | 12 ++++++------
sheep/sheep_priv.h | 2 +-
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/sheep/request.c b/sheep/request.c
index c0ed943..14d03a8 100644
--- a/sheep/request.c
+++ b/sheep/request.c
@@ -487,7 +487,7 @@ static struct request *alloc_request(struct client_info *ci, int data_length)
return NULL;
req->ci = ci;
- ci->refcnt++;
+ main_refcnt_inc(&ci->refcnt);
if (data_length) {
req->data_length = data_length;
req->data = valloc(data_length);
@@ -509,7 +509,7 @@ static void free_request(struct request *req)
{
uatomic_dec(&sys->nr_outstanding_reqs);
- req->ci->refcnt--;
+ main_refcnt_dec(&req->ci->refcnt);
put_vnode_info(req->vinfo);
free(req->data);
free(req);
@@ -748,10 +748,10 @@ static void clear_client_info(struct client_info *ci)
unregister_event(ci->conn.fd);
- sd_dprintf("refcnt:%d, fd:%d, %s:%d", ci->refcnt, ci->conn.fd,
- ci->conn.ipstr, ci->conn.port);
+ sd_dprintf("refcnt:%d, fd:%d, %s:%d", main_refcnt_read(&ci->refcnt),
+ ci->conn.fd, ci->conn.ipstr, ci->conn.port);
- if (ci->refcnt)
+ if (main_refcnt_read(&ci->refcnt))
return;
destroy_client(ci);
@@ -785,7 +785,7 @@ static struct client_info *create_client(int fd, struct cluster_info *cluster)
ci->conn.fd = fd;
ci->conn.events = EPOLLIN;
- ci->refcnt = 0;
+ main_refcnt_set(&ci->refcnt, 0);
INIT_LIST_HEAD(&ci->done_reqs);
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 382d246..21fe8b9 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -52,7 +52,7 @@ struct client_info {
struct list_head done_reqs;
- int refcnt;
+ main_refcnt_t refcnt;
};
struct request {
--
1.7.10.4
More information about the sheepdog
mailing list