Lose unnecessary cfd member from fsm, refcount through payload instead
authorPanu Matilainen <pmatilai@redhat.com>
Tue, 17 Apr 2012 15:03:29 +0000 (18:03 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Tue, 17 Apr 2012 15:03:29 +0000 (18:03 +0300)
lib/cpio.c
lib/fsm.c

index b77b308..958c123 100644 (file)
@@ -41,7 +41,7 @@ rpmcpio_t rpmcpioOpen(FD_t fd, char mode)
         return NULL;
 
     rpmcpio_t cpio = xcalloc(1, sizeof(*cpio));
-    cpio->fd = fd;
+    cpio->fd = fdLink(fd);
     cpio->mode = mode;
     cpio->offset = 0;
     return cpio;
@@ -327,6 +327,7 @@ int rpmcpioClose(rpmcpio_t cpio)
     if ((cpio->mode & O_ACCMODE) == O_WRONLY) {
         rc = rpmcpioTrailerWrite(cpio);
     }
+    fdFree(cpio->fd);
     _free(cpio);
     return rc;
 }
index 57032f5..57a3882 100644 (file)
--- a/lib/fsm.c
+++ b/lib/fsm.c
@@ -96,7 +96,6 @@ struct fsmIterator_s {
  */
 struct fsm_s {
     char * path;               /*!< Current file name. */
-    FD_t cfd;                  /*!< Payload file handle. */
     rpmcpio_t archive;         /*!< cpio archive */
     char * buf;                        /*!<  read: Buffer. */
     size_t bufsize;            /*!<  read: Buffer allocated size. */
@@ -591,9 +590,6 @@ static int fsmSetup(FSM_t fsm, fileStage goal,
     memset(fsm, 0, sizeof(*fsm));
     fsm->ix = -1;
     fsm->goal = goal;
-    if (cfd != NULL) {
-       fsm->cfd = fdLink(cfd);
-    }
     fsm->iter = mapInitIterator(ts, te, fi);
     fsm->sehandle = rpmtsSELabelHandle(ts);
 
@@ -667,10 +663,6 @@ static int fsmTeardown(FSM_t fsm)
     rc = rpmcpioClose(fsm->archive) || rc;
 
     fsm->iter = mapFreeIterator(fsm->iter);
-    if (fsm->cfd != NULL) {
-       fsm->cfd = fdFree(fsm->cfd);
-       fsm->cfd = NULL;
-    }
     fsm->failedFile = NULL;
 
     fsm->path = _free(fsm->path);