If SD_FLAG_CMD_WRITE is set, req->data means sent data, so we don't need to set response data in sd_notify_handler(). Otherwise, it means receive data buffer, so we don't need to set multicast data in prepare_cluster_msg().
This also fixes some local requests which don't set SD_FLAG_CMD_WRITE. Signed-off-by: MORITA Kazutaka <morita.kazut...@lab.ntt.co.jp> --- sheep/group.c | 7 ++++--- sheep/recovery.c | 1 + sheep/vdi.c | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/sheep/group.c b/sheep/group.c index ea5b9e6..3571b96 100644 --- a/sheep/group.c +++ b/sheep/group.c @@ -249,7 +249,7 @@ static struct vdi_op_message *prepare_cluster_msg(struct request *req, struct vdi_op_message *msg; size_t size; - if (has_process_main(req->op)) + if (has_process_main(req->op) && req->rq.flags & SD_FLAG_CMD_WRITE) size = sizeof(*msg) + req->rq.data_length; else size = sizeof(*msg); @@ -265,7 +265,7 @@ static struct vdi_op_message *prepare_cluster_msg(struct request *req, memcpy(&msg->req, &req->rq, sizeof(struct sd_req)); memcpy(&msg->rsp, &req->rp, sizeof(struct sd_rsp)); - if (has_process_main(req->op)) + if (has_process_main(req->op) && req->rq.flags & SD_FLAG_CMD_WRITE) memcpy(msg->data, req->data, req->rq.data_length); *sizep = size; @@ -931,7 +931,8 @@ void sd_notify_handler(struct sd_node *sender, void *data, size_t data_len) if (req) { msg->rsp.result = ret; - if (has_process_main(req->op)) + if (has_process_main(req->op) && + !(req->rq.flags & SD_FLAG_CMD_WRITE)) memcpy(req->data, msg->data, msg->rsp.data_length); memcpy(&req->rp, &msg->rsp, sizeof(req->rp)); diff --git a/sheep/recovery.c b/sheep/recovery.c index 64cd452..521d58f 100644 --- a/sheep/recovery.c +++ b/sheep/recovery.c @@ -350,6 +350,7 @@ static void notify_recovery_completion_work(struct work *work) sd_init_req(&hdr, SD_OP_COMPLETE_RECOVERY); hdr.epoch = rw->epoch; + hdr.flags = SD_FLAG_CMD_WRITE; hdr.data_length = sizeof(sys->this_node); ret = exec_local_req(&hdr, &sys->this_node); diff --git a/sheep/vdi.c b/sheep/vdi.c index 97d9f4e..f7e762f 100644 --- a/sheep/vdi.c +++ b/sheep/vdi.c @@ -578,6 +578,7 @@ static int notify_vdi_deletion(uint32_t vdi_id) int ret = SD_RES_SUCCESS; sd_init_req(&hdr, SD_OP_NOTIFY_VDI_DEL); + hdr.flags = SD_FLAG_CMD_WRITE; hdr.data_length = sizeof(vdi_id); ret = exec_local_req(&hdr, &vdi_id); -- 1.7.2.5 -- sheepdog mailing list sheepdog@lists.wpkg.org http://lists.wpkg.org/mailman/listinfo/sheepdog