[Sheepdog] [PATCH 3/8] sheep: fix socket descriptor leak

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Sat Aug 28 22:55:29 CEST 2010


Connections could be closed before sending a response, so we need to
call client_decref() before watching socket descriptors.

Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 sheep/sdnet.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/sheep/sdnet.c b/sheep/sdnet.c
index 0d3d4b1..ae1c3b5 100644
--- a/sheep/sdnet.c
+++ b/sheep/sdnet.c
@@ -262,7 +262,6 @@ static struct request *alloc_request(struct client_info *ci, int data_length)
 
 static void free_request(struct request *req)
 {
-	client_decref(req->ci);
 	list_del(&req->r_siblings);
 	free(req);
 }
@@ -274,6 +273,7 @@ static void req_done(struct request *req)
 		dprintf("connection seems to be dead\n");
 		free_request(req);
 	}
+	client_decref(req->ci);
 }
 
 static void init_rx_hdr(struct client_info *ci)
-- 
1.5.6.5




More information about the sheepdog mailing list