- fix memory leak
authorMichael Schroeder <mls@suse.de>
Thu, 30 Jul 2009 12:41:23 +0000 (14:41 +0200)
committerMichael Schroeder <mls@suse.de>
Thu, 30 Jul 2009 12:41:23 +0000 (14:41 +0200)
- add changes, bump version
- fix pubkey handling

VERSION.cmake
examples/solv.c
ext/repo_rpmdb.c
package/libsatsolver.changes
package/libsatsolver.spec.in
src/repo.c

index cb22768..ea533d8 100644 (file)
@@ -46,6 +46,6 @@
 
 SET(LIBSATSOLVER_MAJOR "0")
 SET(LIBSATSOLVER_MINOR "14")
-SET(LIBSATSOLVER_PATCH "3")
+SET(LIBSATSOLVER_PATCH "4")
 
-# last released 0.14.3
+# last released 0.14.4
index 328aff5..1646da3 100644 (file)
@@ -96,13 +96,22 @@ char *
 yum_substitute(Pool *pool, char *line)
 {
   char *p, *p2;
+  static char *releaseevr;
+  static char *basearch;
 
+  if (!line)
+    {
+      sat_free(releaseevr);
+      releaseevr = 0;
+      sat_free(basearch);
+      basearch = 0;
+      return 0;
+    }
   p = line;
   while ((p2 = strchr(p, '$')) != 0)
     {
       if (!strncmp(p2, "$releasever", 11))
        {
-         static char *releaseevr;
          if (!releaseevr)
            {
              Queue q;
@@ -132,7 +141,6 @@ yum_substitute(Pool *pool, char *line)
        }
       if (!strncmp(p2, "$basearch", 9))
        {
-         static char *basearch;
          if (!basearch)
            {
              struct utsname un;
@@ -355,8 +363,10 @@ verify_checksum(int fd, const char *file, const unsigned char *chksum, Id chksum
   if (memcmp(sum, chksum, l))
     {
       printf("%s: checksum mismatch\n", file);
+      sat_chksum_free(h, 0);
       return 0;
     }
+  sat_chksum_free(h, 0);
   return 1;
 }
 
@@ -647,6 +657,14 @@ curlfopen(struct repoinfo *cinfo, const char *file, int uncompress, const unsign
          fclose(fp);
          if (!cinfo->baseurl)
            return 0;
+#ifdef FEDORA
+         if (strchr(cinfo->baseurl, '$'))
+           {
+             char *b = yum_substitute(cinfo->repo->pool, cinfo->baseurl);
+             free(cinfo->baseurl);
+             cinfo->baseurl = strdup(b);
+           }
+#endif
          if (!chksumtype && mlchksumtype && !strcmp(file, "repodata/repomd.xml"))
            {
              chksumtype = mlchksumtype;
@@ -2333,6 +2351,9 @@ main(int argc, char **argv)
       pool_free(pool);
       free_repoinfos(repoinfos, nrepoinfos);
       sat_free(commandlinepkgs);
+#ifdef FEDORA
+      yum_substitute(pool, 0);
+#endif
       exit(0);
     }
 
@@ -2776,5 +2797,8 @@ rerunsolver:
   pool_free(pool);
   free_repoinfos(repoinfos, nrepoinfos);
   sat_free(commandlinepkgs);
+#ifdef FEDORA
+  yum_substitute(pool, 0);
+#endif
   exit(0);
 }
index 117e850..8947f9a 100644 (file)
@@ -2100,10 +2100,8 @@ struct rpmdbentry {
 #define ENTRIES_BLOCK 255
 #define NAMEDATA_BLOCK 1023
 
-#define FLAGS_GET_PUBKEYS 1
-
 static struct rpmdbentry *
-getinstalledrpmdbids(struct rpm_by_state *state, const char *index, const char *match, int *nentriesp, char **namedatap, int flags)
+getinstalledrpmdbids(struct rpm_by_state *state, const char *index, const char *match, int *nentriesp, char **namedatap)
 {
   DB_ENV *dbenv = 0;
   DB *db = 0;
@@ -2156,19 +2154,8 @@ getinstalledrpmdbids(struct rpm_by_state *state, const char *index, const char *
     }
   while (dbc->c_get(dbc, &dbkey, &dbdata, match ? DB_SET : DB_NEXT) == 0)
     {
-      if (!match)
-       {
-         if ((flags & FLAGS_GET_PUBKEYS))
-           {
-             if (dbkey.size != 10 || memcmp(dbkey.data, "gpg-pubkey", 10))
-               continue;
-           }
-         else
-           {
-             if (dbkey.size == 10 && !memcmp(dbkey.data, "gpg-pubkey", 10))
-               continue;
-           }
-       }
+      if (!match && dbkey.size == 10 && !memcmp(dbkey.data, "gpg-pubkey", 10))
+       continue;
       dl = dbdata.size;
       dp = dbdata.data;
       while(dl >= 8)
@@ -2203,6 +2190,19 @@ getinstalledrpmdbids(struct rpm_by_state *state, const char *index, const char *
   return entries;
 }
 
+static void
+freestate(struct rpm_by_state *state)
+{
+  /* close down */
+  if (!state)
+    return;
+  if (state->db)
+    state->db->close(state->db, 0);
+  if (state->dbenv)
+    state->dbenv->close(state->dbenv, 0);
+  sat_free(state->rpmhead);
+}
+
 int
 rpm_installedrpmdbids(const char *rootdir, const char *index, const char *match, Queue *rpmdbidq)
 {
@@ -2218,13 +2218,13 @@ rpm_installedrpmdbids(const char *rootdir, const char *index, const char *match,
   memset(&state, 0, sizeof(state));
   if (!(state.dbenv = opendbenv(rootdir)))
     return 0;
-  entries = getinstalledrpmdbids(&state, index, match, &nentries, &namedata, 0);
+  entries = getinstalledrpmdbids(&state, index, match, &nentries, &namedata);
   if (rpmdbidq)
     for (i = 0; i < nentries; i++)
       queue_push(rpmdbidq, entries[i].rpmdbid);
   sat_free(entries);
   sat_free(namedata);
-  rpm_byrpmdbid(0, 0, (void **)&state);
+  freestate(&state);
   return nentries;
 }
 
@@ -2240,13 +2240,7 @@ rpm_byrpmdbid(Id rpmdbid, const char *rootdir, void **statep)
   if (!rpmdbid)
     {
       /* close down */
-      if (!state)
-       return 0;
-      if (state->db)
-       state->db->close(state->db, 0);
-      if (state->dbenv)
-        state->dbenv->close(state->dbenv, 0);
-      sat_free(state->rpmhead);
+      freestate(state);
       sat_free(state);
       *statep = (void *)0;
       return 0;
@@ -2964,10 +2958,11 @@ repo_add_rpmdb_pubkeys(Repo *repo, const char *rootdir, int flags)
   memset(&state, 0, sizeof(state));
   if (!(state.dbenv = opendbenv(rootdir)))
     return;
-  entries = getinstalledrpmdbids(&state, "Name", 0, &nentries, &namedata, FLAGS_GET_PUBKEYS);
+  entries = getinstalledrpmdbids(&state, "Name", "gpg-pubkey", &nentries, &namedata);
   for (i = 0 ; i < nentries; i++)
     {
-      RpmHead *rpmhead = rpm_byrpmdbid(entries[i].rpmdbid, rootdir, (void **)&state);
+      void *statep = &state;
+      RpmHead *rpmhead = rpm_byrpmdbid(entries[i].rpmdbid, rootdir, &statep);
       if (!rpmhead)
        continue;
       str = headstring(rpmhead, TAG_DESCRIPTION);
@@ -2982,7 +2977,7 @@ repo_add_rpmdb_pubkeys(Repo *repo, const char *rootdir, int flags)
        repo->rpmdbid = repo_sidedata_create(repo, sizeof(Id));
       repo->rpmdbid[s - pool->solvables - repo->start] = entries[i].rpmdbid;
     }
-  rpm_byrpmdbid(0, 0, (void **)&state);
+  freestate(&state);
   if (!(flags & REPO_NO_INTERNALIZE))
     repodata_internalize(data);
 }
index c1303a8..cd2399f 100644 (file)
@@ -1,4 +1,13 @@
 -------------------------------------------------------------------
+Thu Jul 30 12:49:38 CEST 2009 - mls@suse.de
+
+- speed up file list parsing
+- speed up addfileprovides
+- fix bugs in pubkey handling
+- fix bug in filelist handling when there are no abs paths
+- 0.14.4
+
+-------------------------------------------------------------------
 Fri Jul 17 14:07:07 CEST 2009 - mls@suse.de
 
 - add satversion.h header file
index 4713f0f..0568b85 100644 (file)
@@ -93,7 +93,13 @@ A new approach to package dependency solving.
 %package demo
 Summary:        Applications demoing the satsolver library
 Group:          System/Management
-Requires:       gpg2 curl
+Requires:       curl
+%if 0%{?fedora_version}
+Requires:       gnupg2
+%endif
+%if 0%{?suse_version}
+Requires:       gpg2
+%endif
 
 %description demo
 Applications demoing the satsolver library.
index 44d8790..af8357d 100644 (file)
@@ -103,6 +103,7 @@ repo_empty(Repo *repo, int reuseids)
   repo->rpmdbid = sat_free(repo->rpmdbid);
   for (i = 0; i < repo->nrepodata; i++)
     repodata_freedata(repo->repodata + i);
+  sat_free(repo->repodata);
   repo->repodata = 0;
   repo->nrepodata = 0;
 }