Skip to content

Commit

Permalink
nanocoap_vfs: don't close socket in nanocoap_vfs_put()
Browse files Browse the repository at this point in the history
  • Loading branch information
benpicco authored and Benjamin Valentin committed Oct 31, 2022
1 parent 780309d commit 3877a92
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions sys/net/application_layer/nanocoap/vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ static int _vfs_put(coap_block_request_t *ctx, const char *file, void *buffer)
vfs_lseek(fd, -1, SEEK_CUR);
}

nanocoap_block_request_done(ctx);

vfs_close(fd);
return res;
}
Expand Down Expand Up @@ -151,9 +149,10 @@ int nanocoap_vfs_put_url(const char *url, const char *src,
coap_block_request_t ctx;
int res = nanocoap_block_request_init_url(&ctx, url, COAP_METHOD_PUT,
coap_size2szx(work_buf_len - 1));
if (res) {
return res;
if (res == 0) {
res = _vfs_put(&ctx, src, work_buf);
nanocoap_block_request_done(&ctx);
}

return _vfs_put(&ctx, src, work_buf);
return res;
}

0 comments on commit 3877a92

Please sign in to comment.