[sheepdog] [PATCH v9 4/4] collie: check an error during issuing request correctly
Liu Yuan
namei.unix at gmail.com
Wed Jul 31 10:53:20 CEST 2013
On Wed, Jul 31, 2013 at 05:44:45PM +0900, Hitoshi Mitake wrote:
> Current collie checks error during issuing request by a return value
> of collie_exec_req(). But it doesn't work well because
> collie_exec_req() returns result code of the request. The code doesn't
> represent that the request itself succeeded or not.
>
> This patch lets collie_exec_req() return 0 or -1 for checking the
> error which is caused during request issue. And also fixes invalid
> error checking done in node_recovery().
>
> In addtion, the last return statement of collie_exec_req() is changed
> like this: return ret ? -1 : 0; This ternay operator is required
> because exec_req() returns 1 when it fails. Some part of collie check
> an error of collie_exec_req() by if (ret < ), and other part check by
> if (ret). The above ternay operator is for avoiding return 1 and let
> these error handlers work correct.
>
> Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
> ---
> collie/common.c | 2 +-
> collie/node.c | 3 +++
> 2 files changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/collie/common.c b/collie/common.c
> index 8c032ba..a480418 100644
> --- a/collie/common.c
> +++ b/collie/common.c
> @@ -193,7 +193,7 @@ int collie_exec_req(const char *host, int port, struct sd_req *hdr, void *buf)
>
> sockfd_cache_put(&nid, sfd);
>
> - return rsp->result;
> + return ret ? -1 : 0;
> }
>
> /* Light request only contains header, without body content. */
> diff --git a/collie/node.c b/collie/node.c
> index 0cd7e7a..0339a45 100644
> --- a/collie/node.c
> +++ b/collie/node.c
> @@ -138,6 +138,9 @@ static int node_recovery(int argc, char **argv)
> sd_init_req(&req, SD_OP_STAT_RECOVERY);
>
> ret = collie_exec_req(host, sd_nodes[i].nid.port, &req, NULL);
> + if (ret < 0)
> + return EXIT_SYSFAIL;
> +
> if (ret == SD_RES_NODE_IN_RECOVERY) {
rsp->result == SD_RES_NODE_IN_RECOVERY?
Thanks
Yuan
> addr_to_str(host, sizeof(host),
> sd_nodes[i].nid.addr, sd_nodes[i].nid.port);
More information about the sheepdog
mailing list