Parcourir la source

libdpkg: Change non-tty output to be line buffered by default

Switch it to be fully buffered only for programs that have precious and
abundant output, not just progress reporting output (i.e. dpkg-query).

This was causing out-of-order error and debug messages in relation to
normal progress reporting, which could be very confusing.

Regression introduced in commit 50c1cb4d6e8b4c3ee739646f9df05992b806ea5e.
Guillem Jover il y a 12 ans
Parent
commit
903d7cce6e
5 fichiers modifiés avec 19 ajouts et 1 suppressions
  1. 7 0
      debian/changelog
  2. 1 0
      lib/dpkg/libdpkg.map
  3. 9 1
      lib/dpkg/report.c
  4. 1 0
      lib/dpkg/report.h
  5. 1 0
      src/querycmd.c

+ 7 - 0
debian/changelog

@@ -1,5 +1,12 @@
 dpkg (1.17.5) UNRELEASED; urgency=low
 
+  [ Guillem Jover ]
+  * Switch non-tty output to be line buffered by default, and set it to fully
+    buffered only for programs with precious and abundant output, not just
+    progress reporting output (i.e. dpkg-query). This was causing out-of-order
+    error and debug messages in relation to normal progress reporting, which
+    could be very confusing. Regression introduced in dpkg 1.17.2.
+
   [ Updated dpkg translations ]
   * German (Sven Joachim).
 

+ 1 - 0
lib/dpkg/libdpkg.map

@@ -31,6 +31,7 @@ LIBDPKG_PRIVATE {
 	ohshite;
 	ohshit;
 	do_internerr;
+	dpkg_set_report_piped_mode;
 	dpkg_set_report_buffer;
 	warning_get_count;
 	warningv;

+ 9 - 1
lib/dpkg/report.c

@@ -31,13 +31,21 @@
 #include <dpkg/progname.h>
 #include <dpkg/report.h>
 
+static int piped_mode = _IOLBF;
+
+void
+dpkg_set_report_piped_mode(int mode)
+{
+	piped_mode = mode;
+}
+
 void
 dpkg_set_report_buffer(FILE *fp)
 {
 	if (isatty(fileno(fp)))
 		setvbuf(fp, NULL, _IONBF, 0);
 	else
-		setvbuf(fp, NULL, _IOFBF, 0);
+		setvbuf(fp, NULL, piped_mode, 0);
 }
 
 static int warn_count = 0;

+ 1 - 0
lib/dpkg/report.h

@@ -35,6 +35,7 @@ DPKG_BEGIN_DECLS
  * @{
  */
 
+void dpkg_set_report_piped_mode(int mode);
 void dpkg_set_report_buffer(FILE *fp);
 
 int warning_get_count(void);

+ 1 - 0
src/querycmd.c

@@ -861,6 +861,7 @@ static const struct cmdinfo cmdinfos[]= {
 int main(int argc, const char *const *argv) {
   int ret;
 
+  dpkg_set_report_piped_mode(_IOFBF);
   dpkg_locales_init(PACKAGE);
   dpkg_program_init("dpkg-query");
   dpkg_options_parse(&argv, cmdinfos, printforhelp);