]> Dogcows Code - chaz/tar/commitdiff
Do not try to drain the input pipe before closing the archive.
authorSergey Poznyakoff <gray@gnu.org.ua>
Tue, 25 Nov 2008 12:33:28 +0000 (12:33 +0000)
committerSergey Poznyakoff <gray@gnu.org.ua>
Tue, 25 Nov 2008 12:33:28 +0000 (12:33 +0000)
* src/buffer.c (close_archive): Remove call to
sys_drain_input_pipe. Pass hit_eof as the second
argument to sys_wait_for_child.
* src/common.h (sys_drain_input_pipe): Remove
(sys_wait_for_child): Declare second argument.
* src/system.c (sys_drain_input_pipe): Remove.
(sys_wait_for_child): Take two arguments. The second one helps to
decide whether to tolerate child termination on SIGPIPE.

ChangeLog
src/buffer.c
src/common.h
src/system.c

index 5036e699e7f3a37172d29e49c5a68496d129939f..62a15c8274e9a353798073c3ca6dcc516dcfe2c8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2008-11-25  Sergey Poznyakoff  <gray@gnu.org.ua>
+
+       Do not try to drain the input pipe before closing the
+       archive. 
+       
+       * src/buffer.c (close_archive): Remove call to
+       sys_drain_input_pipe. Pass hit_eof as the second
+       argument to sys_wait_for_child.
+       * src/common.h (sys_drain_input_pipe): Remove
+       (sys_wait_for_child): Declare second argument.
+       * src/system.c (sys_drain_input_pipe): Remove.
+       (sys_wait_for_child): Take two arguments. The second one helps to
+       decide whether to tolerate child termination on SIGPIPE.
+
 2008-11-03  Sergey Poznyakoff  <gray@gnu.org.ua>
 
        * src/buffer.c (_write_volume_label): Fix typo, which prevented
index 02a3e4c620aeffc0ef6714fc951c05bd59f2fb43..5f5457a95571e531a027179b511fdb0c41763d69 100644 (file)
@@ -848,8 +848,6 @@ close_archive (void)
         flush_archive ();
     }
 
-  sys_drain_input_pipe ();
-
   compute_duration ();
   if (verify_option)
     verify_volume ();
@@ -857,7 +855,7 @@ close_archive (void)
   if (rmtclose (archive) != 0)
     close_error (*archive_name_cursor);
 
-  sys_wait_for_child (child_pid);
+  sys_wait_for_child (child_pid, hit_eof);
 
   tar_stat_destroy (&current_stat_info);
   if (save_name)
index cc3483e224a35b091800f0de992563dda33a03bb..9897b46c4c104a79a978fc04361f848669680342 100644 (file)
@@ -699,8 +699,7 @@ char *xheader_format_name (struct tar_stat_info *st, const char *fmt,
 
 void sys_detect_dev_null_output (void);
 void sys_save_archive_dev_ino (void);
-void sys_drain_input_pipe (void);
-void sys_wait_for_child (pid_t);
+void sys_wait_for_child (pid_t, bool);
 void sys_spawn_shell (void);
 bool sys_compare_uid (struct stat *a, struct stat *b);
 bool sys_compare_gid (struct stat *a, struct stat *b);
index e57e6dafb6398e6b65d3a5cfb5e4b11fa5445112..c90a40d1217b0441571604ead5f9af839675793c 100644 (file)
@@ -1,6 +1,7 @@
 /* System-dependent calls for tar.
 
-   Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004, 2005, 2006, 2007,
+   2008 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by the
@@ -51,12 +52,7 @@ sys_detect_dev_null_output (void)
 }
 
 void
-sys_drain_input_pipe (void)
-{
-}
-
-void
-sys_wait_for_child (pid_t child_pid)
+sys_wait_for_child (pid_t child_pid, bool eof)
 {
 }
 
@@ -160,26 +156,8 @@ sys_detect_dev_null_output (void)
                         && archive_stat.st_ino == dev_null_stat.st_ino));
 }
 
-/* Manage to fully drain a pipe we might be reading, so to not break it on
-   the producer after the EOF block.  FIXME: one of these days, GNU tar
-   might become clever enough to just stop working, once there is no more
-   work to do, we might have to revise this area in such time.  */
-
-void
-sys_drain_input_pipe (void)
-{
-  size_t r;
-
-  if (access_mode == ACCESS_READ
-      && ! _isrmt (archive)
-      && (S_ISFIFO (archive_stat.st_mode) || S_ISSOCK (archive_stat.st_mode)))
-    while ((r = rmtread (archive, record_start->buffer, record_size)) != 0
-          && r != SAFE_READ_ERROR)
-      continue;
-}
-
 void
-sys_wait_for_child (pid_t child_pid)
+sys_wait_for_child (pid_t child_pid, bool eof)
 {
   if (child_pid)
     {
@@ -193,8 +171,11 @@ sys_wait_for_child (pid_t child_pid)
          }
 
       if (WIFSIGNALED (wait_status))
-       ERROR ((0, 0, _("Child died with signal %d"),
-               WTERMSIG (wait_status)));
+       {
+         int sig = WTERMSIG (wait_status);
+         if (!(!eof && sig == SIGPIPE))
+           ERROR ((0, 0, _("Child died with signal %d"), sig));
+       }
       else if (WEXITSTATUS (wait_status) != 0)
        ERROR ((0, 0, _("Child returned status %d"),
                WEXITSTATUS (wait_status)));
This page took 0.03159 seconds and 4 git commands to generate.