Skip to content

Commit

Permalink
Dont try to close non-existent fdno's on Fclose()
Browse files Browse the repository at this point in the history
- Commit 547a004 introduced a regression
  on stacked io Fclose() return code, details at
  http://lists.rpm.org/pipermail/rpm-maint/2014-August/003731.html
- The original code seems fishy in other ways (missed errors), this
  hopefully fixes both cases by only attempting to close actually
  open fdno's and only considering actual closes for error codes.

(cherry picked from commit 0ffc0e2)
  • Loading branch information
pmatilai committed Aug 27, 2014
1 parent c3770b4 commit f2918ad
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions rpmio/rpmio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1028,16 +1028,18 @@ int Fclose(FD_t fd)
fd = fdLink(fd);
fdstat_enter(fd, FDSTAT_CLOSE);
for (FDSTACK_t fps = fd->fps; fps != NULL; fps = fdPop(fd)) {
fdio_close_function_t _close = FDIOVEC(fps, close);
rc = _close ? _close(fps) : -2;
if (fps->fdno >= 0) {
fdio_close_function_t _close = FDIOVEC(fps, close);
rc = _close ? _close(fps) : -2;

if (ec == 0 && rc)
ec = rc;
}

/* Debugging stats for compresed types */
if ((_rpmio_debug || rpmIsDebug()) && fps->fdno == -1)
fdstat_print(fd, fps->io->ioname, stderr);

if (ec == 0 && rc)
ec = rc;

/* Leave freeing the last one after stats */
if (fps->prev == NULL)
break;
Expand Down

0 comments on commit f2918ad

Please sign in to comment.