[sheepdog] [PATCH v1 2/4] sheep/http: add check for return value of http_request_read()

Liu Yuan namei.unix at gmail.com
Wed Jan 29 10:59:06 CET 2014


On Wed, Jan 29, 2014 at 05:15:05PM +0800, Robin Dong wrote:
> When users kill the curl which is uploading large files, the http_request_read()
> will return 0 and lead to dead loop, so we should check it.
> We also add code to free space of alloc after error happens.
> 
> Signed-off-by: Robin Dong <sanbai at taobao.com>
> ---
>  sheep/http/kv.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/sheep/http/kv.c b/sheep/http/kv.c
> index f896ab1..e7eb5f2 100644
> --- a/sheep/http/kv.c
> +++ b/sheep/http/kv.c
> @@ -700,10 +700,21 @@ static int onode_populate_extents(struct kv_onode *onode,
>  	total = req->data_length;
>  	while (done < total) {
>  		size = http_request_read(req, data_buf, write_buffer_size);
> +		if (size <= 0) {
> +			sd_err("Failed to read http request: %ld", size);
> +			sys->cdrv->lock(data_vid);
> +			oalloc_free(data_vid, start, count);
> +			sys->cdrv->unlock(data_vid);
> +			ret = SD_RES_EIO;
> +			goto out;
> +		}
>  		ret = vdi_read_write(data_vid, data_buf, size, offset, false);
>  		if (ret != SD_RES_SUCCESS) {
>  			sd_err("Failed to write data object for %s, %s",
>  			       onode->name, sd_strerror(ret));
> +			sys->cdrv->lock(data_vid);
> +			oalloc_free(data_vid, start, count);
> +			sys->cdrv->unlock(data_vid);
>  			goto out;
>  		}

swift_get_object should handle SD_RES_EIO and translate it to http errcode.

Thanks
Yuan



More information about the sheepdog mailing list