We tend to forget to set rsp->data_length to 0 when we don't need to send any data, so it looks better not to initialize the value with req->data_length. Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp> --- sheep/group.c | 1 - sheep/ops.c | 11 +++-------- sheep/request.c | 5 ----- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/sheep/group.c b/sheep/group.c index 8c3b499..4661110 100644 --- a/sheep/group.c +++ b/sheep/group.c @@ -229,7 +229,6 @@ int local_get_node_list(const struct sd_req *req, struct sd_rsp *rsp, node_rsp->local_idx = get_node_idx(current_vnode_info, &sys->this_node); } else { - node_rsp->data_length = 0; node_rsp->nr_nodes = 0; node_rsp->local_idx = 0; } diff --git a/sheep/ops.c b/sheep/ops.c index 4c0426f..4c3e9ac 100644 --- a/sheep/ops.c +++ b/sheep/ops.c @@ -444,9 +444,8 @@ static int local_stat_cluster(struct request *req) int i, max_logs; uint32_t epoch; - max_logs = rsp->data_length / sizeof(*log); + max_logs = req->rq.data_length / sizeof(*log); epoch = get_latest_epoch(); - rsp->data_length = 0; for (i = 0; i < max_logs; i++) { if (epoch <= 0) break; @@ -499,10 +498,8 @@ static int local_get_epoch(struct request *req) dprintf("%d\n", epoch); nr_nodes = epoch_log_read(epoch, req->data, req->rq.data_length); - if (nr_nodes == -1) { - req->rp.data_length = 0; + if (nr_nodes == -1) return SD_RES_NO_TAG; - } req->rp.data_length = nr_nodes * sizeof(struct sd_node) + sizeof(time_t); return SD_RES_SUCCESS; @@ -861,10 +858,8 @@ int peer_read_obj(struct request *req) iocb.length = hdr->data_length; iocb.offset = hdr->obj.offset; ret = sd_store->read(hdr->obj.oid, &iocb); - if (ret != SD_RES_SUCCESS) { - rsp->data_length = 0; + if (ret != SD_RES_SUCCESS) goto out; - } rsp->data_length = hdr->data_length; if (hdr->obj.copies) diff --git a/sheep/request.c b/sheep/request.c index ae12bd3..ab9a9ef 100644 --- a/sheep/request.c +++ b/sheep/request.c @@ -582,14 +582,9 @@ static inline int begin_rx(struct client_info *ci) static inline void finish_rx(struct client_info *ci) { struct request *req; - struct sd_req *hdr = &ci->conn.rx_hdr; req = ci->rx_req; init_rx_hdr(ci); - if (hdr->flags & SD_FLAG_CMD_WRITE) - req->rp.data_length = 0; - else - req->rp.data_length = hdr->data_length; dprintf("%d, %s:%d\n", ci->conn.fd, ci->conn.ipstr, ci->conn.port); queue_request(req); -- 1.7.2.5 |