[sheepdog] [PATCH] gateway: clean up wait_forward_request()
Liu Yuan
namei.unix at gmail.com
Tue Sep 11 05:45:05 CEST 2012
From: Liu Yuan <tailai.ly at taobao.com>
We only process POLLIN events, then we can simplify processing with goto
and remove the never-reach code.
Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
sheep/gateway.c | 28 +++++++++++++---------------
1 file changed, 13 insertions(+), 15 deletions(-)
diff --git a/sheep/gateway.c b/sheep/gateway.c
index 3e8e673..2231804 100644
--- a/sheep/gateway.c
+++ b/sheep/gateway.c
@@ -188,23 +188,21 @@ again:
if (re & (POLLERR | POLLHUP | POLLNVAL)) {
err_ret = SD_RES_NETWORK_ERROR;
finish_one_write_err(wi, i);
- } else if (re & POLLIN) {
- if (do_read(pi.pfds[i].fd, rsp, sizeof(*rsp))) {
- eprintf("remote node might have gone away\n");
- err_ret = SD_RES_NETWORK_ERROR;
- finish_one_write_err(wi, i);
- goto finish_write;
- }
+ goto finish_write;
+ }
+ if (do_read(pi.pfds[i].fd, rsp, sizeof(*rsp))) {
+ eprintf("remote node might have gone away\n");
+ err_ret = SD_RES_NETWORK_ERROR;
+ finish_one_write_err(wi, i);
+ goto finish_write;
+ }
- ret = rsp->result;
- if (ret != SD_RES_SUCCESS) {
- eprintf("fail %"PRIx32"\n", ret);
- err_ret = ret;
- }
- finish_one_write(wi, i);
- } else {
- eprintf("unhandled poll event\n");
+ ret = rsp->result;
+ if (ret != SD_RES_SUCCESS) {
+ eprintf("fail %"PRIx32"\n", ret);
+ err_ret = ret;
}
+ finish_one_write(wi, i);
}
finish_write:
if (wi->nr_sent > 0)
--
1.7.10.2
More information about the sheepdog
mailing list