Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp> --- sheep/sdnet.c | 17 +++++++++++------ sheep/store.c | 5 ++++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/sheep/sdnet.c b/sheep/sdnet.c index e043b78..3b1a554 100644 --- a/sheep/sdnet.c +++ b/sheep/sdnet.c @@ -645,7 +645,7 @@ int read_object(struct sheepdog_node_list_entry *e, struct sd_obj_req hdr; struct sd_obj_rsp *rsp = (struct sd_obj_rsp *)&hdr; char name[128]; - int i = 0, n, fd, ret; + int i = 0, n, fd, ret, last_error = SD_RES_SUCCESS; if (nr > nodes) nr = nodes; @@ -680,7 +680,7 @@ int read_object(struct sheepdog_node_list_entry *e, if (fd < 0) { printf("%s(%d): %s, %m\n", __func__, __LINE__, name); - return -1; + return -SD_RES_EIO; } memset(&hdr, 0, sizeof(hdr)); @@ -695,13 +695,18 @@ int read_object(struct sheepdog_node_list_entry *e, ret = exec_req(fd, (struct sd_req *)&hdr, data, &wlen, &rlen); close(fd); - if (!ret) { - if (rsp->result == SD_RES_SUCCESS) - return rsp->data_length; + if (ret) { + last_error = SD_RES_EIO; + continue; } + + if (rsp->result == SD_RES_SUCCESS) + return rsp->data_length; + + last_error = rsp->result; } - return -1; + return -last_error; } int remove_object(struct sheepdog_node_list_entry *e, diff --git a/sheep/store.c b/sheep/store.c index d454a4f..7ff134d 100644 --- a/sheep/store.c +++ b/sheep/store.c @@ -605,7 +605,10 @@ int read_object_local(uint64_t oid, char *data, unsigned int datalen, ret = store_queue_request_local(&req, epoch); - if (ret != 0 || rsp->data_length != datalen) + if (ret != 0) + return -SD_RES_EIO; + + if (rsp->data_length != datalen) return -rsp->result; return rsp->data_length; -- 1.5.6.5 |