supermin/0006-rpm-Flush-debugging-messages-in-C-code.patch
Richard W.M. Jones 22a6b3ebe7 Pull in all upstream patches since 5.1.13.
- Choose providers better (RHBZ#1266918).
- Use autopatch.
2015-10-13 16:28:41 +01:00

83 lines
2.7 KiB
Diff

From a843495409d2d1cf1cd966470b57d336d7ad04d4 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 13 Oct 2015 13:40:56 +0100
Subject: [PATCH 6/7] rpm: Flush debugging messages in C code.
Because C and OCaml use different implementations of stdio, and
because C stdout is not line-buffered, we can get mixed up debugging
messages.
Partially fix this by using fflush (stdout) after printing C debugging
messages (this doesn't completely fix it because we'd have to do the
same in OCaml code too).
This slows down debugging output, but it's only used when debugging so
we don't care about that.
---
src/librpm-c.c | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/src/librpm-c.c b/src/librpm-c.c
index fc847d6..3bd25a2 100644
--- a/src/librpm-c.c
+++ b/src/librpm-c.c
@@ -202,8 +202,11 @@ supermin_rpm_installed (value rpmv, value pkgv)
caml_raise_not_found ();
count = rpmdbGetIteratorCount (iter);
- if (data.debug >= 2)
- printf ("supermin: rpm: installed: %d occurrences for '%s'\n", count, String_val (pkgv));
+ if (data.debug >= 2) {
+ printf ("supermin: rpm: installed: %d occurrences for '%s'\n",
+ count, String_val (pkgv));
+ fflush (stdout);
+ }
rv = caml_alloc (count, 0);
i = 0;
@@ -287,8 +290,11 @@ supermin_rpm_pkg_requires (value rpmv, value pkgv)
caml_raise_not_found ();
count = rpmdbGetIteratorCount (iter);
- if (data.debug >= 2)
- printf ("supermin: rpm: pkg_requires: %d occurrences for '%s'\n", count, String_val (pkgv));
+ if (data.debug >= 2) {
+ printf ("supermin: rpm: pkg_requires: %d occurrences for '%s'\n",
+ count, String_val (pkgv));
+ fflush (stdout);
+ }
if (count != 1)
librpm_raise_multiple_matches (count);
@@ -351,8 +357,11 @@ supermin_rpm_pkg_whatprovides (value rpmv, value pkgv)
caml_raise_not_found ();
count = rpmdbGetIteratorCount (iter);
- if (data.debug >= 2)
- printf ("supermin: rpm: pkg_whatprovides: %d occurrences for '%s'\n", count, String_val (pkgv));
+ if (data.debug >= 2) {
+ printf ("supermin: rpm: pkg_whatprovides: %d occurrences for '%s'\n",
+ count, String_val (pkgv));
+ fflush (stdout);
+ }
rv = caml_alloc (count, 0);
i = 0;
@@ -398,8 +407,11 @@ supermin_rpm_pkg_filelist (value rpmv, value pkgv)
caml_raise_not_found ();
count = rpmdbGetIteratorCount (iter);
- if (data.debug >= 2)
- printf ("supermin: rpm: pkg_filelist: %d occurrences for '%s'\n", count, String_val (pkgv));
+ if (data.debug >= 2) {
+ printf ("supermin: rpm: pkg_filelist: %d occurrences for '%s'\n",
+ count, String_val (pkgv));
+ fflush (stdout);
+ }
if (count != 1)
librpm_raise_multiple_matches (count);
--
2.5.0