source: patches/tar-1.21-revert_pipe_drain-1.patch@ b2297f5

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since b2297f5 was bf56c25, checked in by Jim Gifford <clfs@…>, 16 years ago

Added Revert Pipe Drain Patch to Tar

  • Property mode set to 100644
File size: 3.2 KB
RevLine 
[bf56c25]1Submitted By: Jim Gifford (jim at cross-lfs dot org)
2Date: 2009-01-04
3Initial Package Version: 1.21
4Origin: Tar Bug List
5Upstream Status: Applied
6Description: http://lists.gnu.org/archive/html/bug-tar/2008-12/msg00028.html
7
8diff -Naur tar-1.21.orig/src/buffer.c tar-1.21/src/buffer.c
9--- tar-1.21.orig/src/buffer.c 2008-11-30 04:30:29.000000000 -0800
10+++ tar-1.21/src/buffer.c 2009-01-04 20:04:57.000000000 -0800
11@@ -848,6 +848,8 @@
12 flush_archive ();
13 }
14
15+ sys_drain_input_pipe ();
16+
17 compute_duration ();
18 if (verify_option)
19 verify_volume ();
20@@ -855,7 +857,7 @@
21 if (rmtclose (archive) != 0)
22 close_error (*archive_name_cursor);
23
24- sys_wait_for_child (child_pid, hit_eof);
25+ sys_wait_for_child (child_pid);
26
27 tar_stat_destroy (&current_stat_info);
28 if (save_name)
29diff -Naur tar-1.21.orig/src/common.h tar-1.21/src/common.h
30--- tar-1.21.orig/src/common.h 2008-11-30 04:30:29.000000000 -0800
31+++ tar-1.21/src/common.h 2009-01-04 20:04:57.000000000 -0800
32@@ -699,7 +699,8 @@
33
34 void sys_detect_dev_null_output (void);
35 void sys_save_archive_dev_ino (void);
36-void sys_wait_for_child (pid_t, bool);
37+void sys_drain_input_pipe (void);
38+void sys_wait_for_child (pid_t);
39 void sys_spawn_shell (void);
40 bool sys_compare_uid (struct stat *a, struct stat *b);
41 bool sys_compare_gid (struct stat *a, struct stat *b);
42diff -Naur tar-1.21.orig/src/system.c tar-1.21/src/system.c
43--- tar-1.21.orig/src/system.c 2008-11-30 04:30:30.000000000 -0800
44+++ tar-1.21/src/system.c 2009-01-04 20:04:57.000000000 -0800
45@@ -1,7 +1,6 @@
46 /* System-dependent calls for tar.
47
48- Copyright (C) 2003, 2004, 2005, 2006, 2007,
49- 2008 Free Software Foundation, Inc.
50+ Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
51
52 This program is free software; you can redistribute it and/or modify it
53 under the terms of the GNU General Public License as published by the
54@@ -52,7 +51,12 @@
55 }
56
57 void
58-sys_wait_for_child (pid_t child_pid, bool eof)
59+sys_drain_input_pipe (void)
60+{
61+}
62+
63+void
64+sys_wait_for_child (pid_t child_pid)
65 {
66 }
67
68@@ -156,8 +160,26 @@
69 && archive_stat.st_ino == dev_null_stat.st_ino));
70 }
71
72+/* Manage to fully drain a pipe we might be reading, so to not break it on
73+ the producer after the EOF block. FIXME: one of these days, GNU tar
74+ might become clever enough to just stop working, once there is no more
75+ work to do, we might have to revise this area in such time. */
76+
77+void
78+sys_drain_input_pipe (void)
79+{
80+ size_t r;
81+
82+ if (access_mode == ACCESS_READ
83+ && ! _isrmt (archive)
84+ && (S_ISFIFO (archive_stat.st_mode) || S_ISSOCK (archive_stat.st_mode)))
85+ while ((r = rmtread (archive, record_start->buffer, record_size)) != 0
86+ && r != SAFE_READ_ERROR)
87+ continue;
88+}
89+
90 void
91-sys_wait_for_child (pid_t child_pid, bool eof)
92+sys_wait_for_child (pid_t child_pid)
93 {
94 if (child_pid)
95 {
96@@ -171,11 +193,8 @@
97 }
98
99 if (WIFSIGNALED (wait_status))
100- {
101- int sig = WTERMSIG (wait_status);
102- if (!(!eof && sig == SIGPIPE))
103- ERROR ((0, 0, _("Child died with signal %d"), sig));
104- }
105+ ERROR ((0, 0, _("Child died with signal %d"),
106+ WTERMSIG (wait_status)));
107 else if (WEXITSTATUS (wait_status) != 0)
108 ERROR ((0, 0, _("Child returned status %d"),
109 WEXITSTATUS (wait_status)));
Note: See TracBrowser for help on using the repository browser.