[sheepdog] [PATCH] sheep: return directly when sending data fails.
王帆
wangfan1985 at gmail.com
Thu May 30 04:57:49 CEST 2013
>From 52e90e362e5413de4d424bc12102077402f6144f Mon Sep 17 00:00:00 2001
From: wangfan <wangfan1985 at gmail.com>
Date: Thu, 30 May 2013 10:22:46 +0800
Subject: [PATCH] sheep: return directly when sending data fails.
when send data fails,do_client_rx will free struct client_info.
call do_client_tx will access freed memory.
Signed-off-by: wangfan <wangfan1985 at gmail.com>
---
sheep/request.c | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/sheep/request.c b/sheep/request.c
index e99f6f2..91e1f06 100644
--- a/sheep/request.c
+++ b/sheep/request.c
@@ -613,12 +613,13 @@ static inline void finish_rx(struct client_info *ci)
queue_request(req);
}
-static void do_client_rx(struct client_info *ci)
+static int do_client_rx(struct client_info *ci)
{
if (begin_rx(ci) < 0)
- return;
+ return -1;
finish_rx(ci);
+ return SD_RES_SUCCESS;
}
static void init_tx_hdr(struct client_info *ci)
@@ -810,8 +811,10 @@ static void client_handler(int fd, int events, void
*data)
if (events & (EPOLLERR | EPOLLHUP) || is_conn_dead(&ci->conn))
return clear_client_info(ci);
- if (events & EPOLLIN)
- do_client_rx(ci);
+ if (events & EPOLLIN) {
+ if (do_client_rx(ci) < 0)
+ return;
+ }
if (events & EPOLLOUT)
do_client_tx(ci);
--
1.7.1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wpkg.org/pipermail/sheepdog/attachments/20130530/71b33c53/attachment-0003.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-sheep-return-directly-when-sending-data-fails.patch
Type: application/octet-stream
Size: 1289 bytes
Desc: not available
URL: <http://lists.wpkg.org/pipermail/sheepdog/attachments/20130530/71b33c53/attachment-0003.obj>
More information about the sheepdog
mailing list