Skip to content

Commit

Permalink
Cleanup after error
Browse files Browse the repository at this point in the history
  • Loading branch information
braydonf committed Feb 13, 2017
1 parent 003bb6e commit ffb202f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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,
Expand Down

0 comments on commit ffb202f

Please sign in to comment.