hdb: Fix warnings and leaks

This commit is contained in:
Nicolas Williams
2021-03-28 17:55:14 -05:00
parent fb553dde1d
commit 4f8399a433
9 changed files with 44 additions and 30 deletions

View File

@@ -172,6 +172,8 @@ forked_reader(struct tsync *s)
while ((bytes = read(s->reader_go_pipe[0], b, sizeof(b))) == -1 &&
errno == EINTR)
;
if (bytes == -1)
err(1, "Could not read from reader-go pipe (error)");
/* Open a new HDB handle to read */
if ((ret = hdb_create(context, &dbr, s->hdb_name))) {
@@ -195,6 +197,8 @@ forked_reader(struct tsync *s)
while ((bytes = write(s->writer_go_pipe[1], "", sizeof(""))) == -1 &&
errno == EINTR)
;
if (bytes == -1)
err(1, "Could not write to writer-go pipe (error)");
/* Wait for the writer to have written one more entry to the HDB */
@@ -231,6 +235,8 @@ forked_reader(struct tsync *s)
while ((bytes = write(s->writer_go_pipe[1], "", sizeof(""))) == -1 &&
errno == EINTR)
;
if (bytes == -1)
err(1, "Could not write to writer-go pipe (error)");
dbr->hdb_close(context, dbr);
dbr->hdb_destroy(context, dbr);