Skip to content

Commit

Permalink
rados url: handle error from rados_read()
Browse files Browse the repository at this point in the history
Resolves: rhbz#1486112

Change-Id: If437a989ddaea108216c28af99fab6da0f089e01
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
(cherry picked from commit 247c4a6)
  • Loading branch information
mattbenjamin committed Sep 27, 2017
1 parent a47e4ca commit b17e3f7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/config_parsing/conf_url_rados.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,18 @@ static int cu_rados_url_fetch(const char *url, FILE **f, char **fbuf)
do {
int nread, wrt, nwrt;

nread = ret = rados_read(io_ctx, object_name, buf, 1024, off1);
if (ret < 0) {
LogEvent(COMPONENT_CONFIG,
"%s: Failed reading %s/%s %s", __func__,
pool_name, object_name, strerror(ret));
goto err;
}
off1 += nread;
if (!stream) {
streamsz = 1024;
stream = open_memstream(&streambuf, &streamsz);
}
nread = ret = rados_read(io_ctx, object_name, buf, 1024, off1);
off1 += nread;
do {
wrt = fwrite(buf+off2, nread, 1, stream);
if (wrt > 0) {
Expand All @@ -256,6 +262,7 @@ static int cu_rados_url_fetch(const char *url, FILE **f, char **fbuf)
*fbuf = streambuf;
}

err:
rados_ioctx_destroy(io_ctx);

out:
Expand Down

0 comments on commit b17e3f7

Please sign in to comment.