On 04/12/2012 05:02 PM, [email protected] wrote:

> From: Yibin Shen <[email protected]>
> 
> 
> Signed-off-by: Yibin Shen <[email protected]>
> ---
>  sheep/store.c |   19 ++++++++++++-------
>  1 files changed, 12 insertions(+), 7 deletions(-)
> 
> diff --git a/sheep/store.c b/sheep/store.c
> index 739862c..027443f 100644
> --- a/sheep/store.c
> +++ b/sheep/store.c
> @@ -588,18 +588,23 @@ int store_remove_obj(const struct sd_req *req, struct 
> sd_rsp *rsp, void *data)
>       struct sd_obj_req *hdr = (struct sd_obj_req *)req;
>       uint32_t epoch = hdr->epoch;
>       char path[1024];
> +     struct strbuf store_dir = STRBUF_INIT;
> +     int ret = SD_RES_SUCCESS;
> +     get_store_dir(&store_dir, epoch);
>  
> -     snprintf(path, sizeof(path), "%s%08u/%016" PRIx64, obj_path,
> -              epoch, hdr->oid);
> +     snprintf(path, sizeof(path), "%s%016" PRIx64, store_dir.buf, hdr->oid);
>  


Would better use strbuf_add() to add oid to the buffer, then unlink(buf.buf)

Thanks,
Yuan

>       if (unlink(path) < 0) {
> -             if (errno == ENOENT)
> -                     return SD_RES_NO_OBJ;
> +             if (errno == ENOENT) {
> +                     ret = SD_RES_NO_OBJ;
> +                     goto out;
> +             }
>               eprintf("%m\n");
> -             return SD_RES_EIO;
> +             ret =  SD_RES_EIO;
>       }
> -
> -     return SD_RES_SUCCESS;
> + out:
> +     strbuf_release(&store_dir);
> +     return ret;
>  }
>  
>  int store_read_obj(const struct sd_req *req, struct sd_rsp *rsp, void *data)


-- 
sheepdog mailing list
[email protected]
http://lists.wpkg.org/mailman/listinfo/sheepdog

Reply via email to