From ffb202fab1372fd6e493ac2f3d41a59235ae0563 Mon Sep 17 00:00:00 2001 From: Braydon Fuller Date: Mon, 13 Feb 2017 15:30:12 -0500 Subject: [PATCH] Cleanup after error --- src/http.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/http.c b/src/http.c index d62870f..b83faef 100644 --- a/src/http.c +++ b/src/http.c @@ -59,6 +59,7 @@ int put_shard(storj_http_options_t *http_options, uv_async_t *progress_handle, bool *canceled) { + int return_code = 0; CURL *curl = curl_easy_init(); if (!curl) { @@ -136,11 +137,13 @@ int put_shard(storj_http_options_t *http_options, free(header); if (*canceled) { + return_code = 1; goto clean_up; } if (req != CURLE_OK) { - return req; + return_code = req; + goto clean_up; } // set the status code @@ -150,7 +153,8 @@ int put_shard(storj_http_options_t *http_options, // check that total bytes have been sent if (shard_body->total_sent != shard_total_bytes) { - return 1; + return_code = 1; + goto clean_up; } clean_up: @@ -162,7 +166,7 @@ int put_shard(storj_http_options_t *http_options, free(url); curl_easy_cleanup(curl); - return 0; + return return_code; } static size_t body_shard_receive(void *buffer, size_t size, size_t nmemb,