[sheepdog] [PATCH] collie: cleanup callbacks of collie command when they send header only requests

Liu Yuan namei.unix at gmail.com
Fri Jul 27 05:11:41 CEST 2012


With a second review, I think this patch need more reviews.

On 07/26/2012 09:46 PM, Yunkai Zhang wrote:
> +int send_light_req(struct sd_req *hdr, const char *host, int port)
> +{
> +	int fd, ret;
> +	struct sd_rsp *rsp = (struct sd_rsp *)hdr;
> +	unsigned rlen, wlen;
> +
> +	fd = connect_to(host, port);
> +	if (fd < 0)
> +		return -1;
> +
> +	rlen = 0;
> +	wlen = 0;
> +	ret = exec_req(fd, hdr, NULL, &wlen, &rlen);
> +	close(fd);
> +
> +	if (ret) {
> +		return -1;
> +	}

Simply eprintf inside this function for connection failed

> +
> +	if (rsp->result != SD_RES_SUCCESS) {
> +		eprintf("Response's result: %s\n", sd_strerror(rsp->result));
> +		return 1;
> +	}
> +
> +	return 0;
> +}

Then use -1 for error case and 0 for success. No need to use both -1 and
1 to represent failure case.

Thanks,
Yuan




More information about the sheepdog mailing list