]> git.pld-linux.org Git - packages/rpm.git/commitdiff
- add workaround for https://bugs.launchpad.net/rpm/+bug/934420 auto/th/rpm-5.4.10-0.12
authorJan Rękorajski <baggins@pld-linux.org>
Mon, 10 Sep 2012 15:44:59 +0000 (17:44 +0200)
committerJan Rękorajski <baggins@pld-linux.org>
Mon, 10 Sep 2012 15:44:59 +0000 (17:44 +0200)
rpm-db_buffer_small.patch [new file with mode: 0644]
rpm.spec

diff --git a/rpm-db_buffer_small.patch b/rpm-db_buffer_small.patch
new file mode 100644 (file)
index 0000000..020aa97
--- /dev/null
@@ -0,0 +1,75 @@
+In certain cases with BerkleyDB 5.3.x we are getting the error:
+
+db3.c:1443: dbcursor->pget(-30999): BDB0063 DB_BUFFER_SMALL: User memory too small for return value
+
+See https://bugs.launchpad.net/rpm/+bug/934420 for more information.
+
+It appears to be some type of a bug in the BerkleyDB 5.3.x.  In an attempt
+to workaround the problem, when we encounter this situation we attempt
+to adjust the size of the mmap buffer until the call works, or we
+end up trying 10 times.  The new size is either the updated vp->size
+from the failed pget call, or the previous size + 1024.
+
+If DBI debugging is enabled, additional diagnostics are printed, otherwise
+a basic retry and success message is added to show that the failure was
+resolved.
+
+Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
+
+Index: rpm-5.4.9/rpmdb/rpmdb.c
+===================================================================
+--- rpm-5.4.9.orig/rpmdb/rpmdb.c
++++ rpm-5.4.9/rpmdb/rpmdb.c
+@@ -2212,8 +2212,12 @@ static int rpmmiGet(dbiIndex dbi, DBC * 
+       vp->flags |= DB_DBT_USERMEM;
+       rc = dbiGet(dbi, dbcursor, kp, vp, flags);
+       if (rc == DB_BUFFER_SMALL) {
++          int retry = 0;
++          size_t origlen = vp->size;
+           size_t uhlen = vp->size;
+-          void * uh = mmap(NULL, uhlen, _prot, _flags, _fdno, _off);
++          void * uh;
++retry_get:
++          uh = mmap(NULL, uhlen, _prot, _flags, _fdno, _off);
+           if (uh == NULL || uh == (void *)-1)
+               fprintf(stderr,
+                   "==> mmap(%p[%u], 0x%x, 0x%x, %d, 0x%x) error(%d): %s\n",
+@@ -2235,6 +2239,25 @@ static int rpmmiGet(dbiIndex dbi, DBC * 
+               if (munmap(uh, uhlen) != 0)
+                   fprintf(stderr, "==> munmap(%p[%u]) error(%d): %s\n",
+                       uh, (unsigned)uhlen, errno, strerror(errno));
++              /* We want to be sure to limit the number of retry attempts to avoid a loop! */
++              if (rc == DB_BUFFER_SMALL && retry < 10) {
++                 /* If we got a largr vp-size back, use that, otherwise increment the size by 1k */
++                 uhlen = vp->size > uhlen ? vp->size : uhlen + 1024;
++                 retry++;
++                 if ((dbi)->dbi_debug)
++                     fprintf(stderr, "==> DB_BUFFER_SMALL orig requested (%d), configured (%d), forcing larger buffer (%d), new size (%d)\n",
++                          origlen, vp->ulen, uhlen, vp->size);
++                 else
++                     fprintf(stderr, "==> retry (%d) db3cpget (%d)\n", retry, uhlen);
++                 goto retry_get;
++              }
++          }
++          if (retry) {
++              if ((dbi)->dbi_debug)
++                 fprintf(stderr, "==> success orig requested (%d), configured buffer (%d), buffer (%d), size after dbiGet (%d)\n",
++                      origlen, vp->ulen, uhlen, vp->size);
++              else
++                 fprintf(stderr, "==> success\n");
+           }
+       }
+     } else
+Index: rpm-5.4.9/rpmdb/db3.c
+===================================================================
+--- rpm-5.4.9.orig/rpmdb/db3.c
++++ rpm-5.4.9/rpmdb/db3.c
+@@ -1452,7 +1452,7 @@ assert(db != NULL);
+ #endif
+     }
+-DBIDEBUG(dbi, (stderr, "<-- %s(%p,%p,%p,%p,%p,0x%x) rc %d %s%s\n", __FUNCTION__, dbi, dbcursor, key, pkey, data, flags, rc, _DBCFLAGS(flags), _KEYDATA(key, pkey, data, NULL)));
++DBIDEBUG(dbi, (stderr, "<-- %s(%p,%p,%p,%p,%p,0x%x) rc %d %s%s\n", __FUNCTION__, dbi, dbcursor, key, pkey, data, flags, rc, _DBCFLAGS(flags), _KEYDATA(key, pkey, rc == DB_BUFFER_SMALL ? NULL : data, NULL)));
+     return rc;
+ }
+ /*@=mustmod@*/
index 9ef1becb1c421dddb42243d99347d1ed16febb46..a04bb696c3cc824e166817f24857fd4c303a8b2c 100644 (file)
--- a/rpm.spec
+++ b/rpm.spec
@@ -55,7 +55,7 @@ Summary(ru.UTF-8):    Менеджер пакетов от RPM
 Summary(uk.UTF-8):     Менеджер пакетів від RPM
 Name:          rpm
 Version:       5.4.10
-Release:       0.11
+Release:       0.12
 License:       LGPL
 Group:         Base
 # http://rpm5.org/files/rpm/rpm-5.4/rpm-5.4.10-0.20120706.src.rpm
@@ -134,6 +134,7 @@ Patch40:    %{name}-silence-RPM_CHAR_TYPE.patch
 Patch41:       %{name}-fix-missing-types-in-headers.patch
 Patch42:       %{name}-disable-ldconfig-optimization.patch
 Patch43:       %{name}-fix--p-interpreter-and-empty-script.patch
+Patch44:       %{name}-db_buffer_small.patch
 
 # Patches imported from Mandriva
 
@@ -803,6 +804,7 @@ Dokumentacja API RPM-a oraz przewodniki w formacie HTML generowane ze
 %patch41 -p1
 %patch42 -p1
 %patch43 -p1
+%patch44 -p1
 
 %patch1000 -p1
 %patch1001 -p1
This page took 0.036825 seconds and 4 git commands to generate.