Gentoo Archives: gentoo-commits

From: "Mike Frysinger (vapier)" <vapier@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in app-arch/tar/files: tar-1.21-revert-pipe.patch
Date: Mon, 29 Dec 2008 10:03:47
Message-Id: E1LHEyO-0001nf-Dl@stork.gentoo.org
1 vapier 08/12/29 10:03:44
2
3 Added: tar-1.21-revert-pipe.patch
4 Log:
5 Revert an upstream change that breaks when piping data into tar as pointed out by Zac Medico #252680 by Etienne Hilson.
6 (Portage version: 2.2_rc18/cvs/Linux 2.6.28 x86_64)
7
8 Revision Changes Path
9 1.1 app-arch/tar/files/tar-1.21-revert-pipe.patch
10
11 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-arch/tar/files/tar-1.21-revert-pipe.patch?rev=1.1&view=markup
12 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-arch/tar/files/tar-1.21-revert-pipe.patch?rev=1.1&content-type=text/plain
13
14 Index: tar-1.21-revert-pipe.patch
15 ===================================================================
16 http://bugs.gentoo.org/252680
17
18 revert this change:
19
20 2008-11-25 Sergey Poznyakoff <gray@×××××××.ua>
21
22 Do not try to drain the input pipe before closing the
23 archive.
24
25 * src/buffer.c (close_archive): Remove call to
26 sys_drain_input_pipe. Pass hit_eof as the second
27 argument to sys_wait_for_child.
28 * src/common.h (sys_drain_input_pipe): Remove
29 (sys_wait_for_child): Declare second argument.
30 * src/system.c (sys_drain_input_pipe): Remove.
31 (sys_wait_for_child): Take two arguments. The second one helps to
32 decide whether to tolerate child termination on SIGPIPE.
33
34 diff --git a/src/buffer.c b/src/buffer.c
35 index 5f5457a..02a3e4c 100644
36 --- a/src/buffer.c
37 +++ b/src/buffer.c
38 @@ -848,6 +848,8 @@ close_archive (void)
39 flush_archive ();
40 }
41
42 + sys_drain_input_pipe ();
43 +
44 compute_duration ();
45 if (verify_option)
46 verify_volume ();
47 @@ -855,7 +857,7 @@ close_archive (void)
48 if (rmtclose (archive) != 0)
49 close_error (*archive_name_cursor);
50
51 - sys_wait_for_child (child_pid, hit_eof);
52 + sys_wait_for_child (child_pid);
53
54 tar_stat_destroy (&current_stat_info);
55 if (save_name)
56 diff --git a/src/common.h b/src/common.h
57 index 9897b46..cc3483e 100644
58 --- a/src/common.h
59 +++ b/src/common.h
60 @@ -699,7 +699,8 @@ char *xheader_format_name (struct tar_stat_info *st, const char *fmt,
61
62 void sys_detect_dev_null_output (void);
63 void sys_save_archive_dev_ino (void);
64 -void sys_wait_for_child (pid_t, bool);
65 +void sys_drain_input_pipe (void);
66 +void sys_wait_for_child (pid_t);
67 void sys_spawn_shell (void);
68 bool sys_compare_uid (struct stat *a, struct stat *b);
69 bool sys_compare_gid (struct stat *a, struct stat *b);
70 diff --git a/src/system.c b/src/system.c
71 index c90a40d..e57e6da 100644
72 --- a/src/system.c
73 +++ b/src/system.c
74 @@ -1,7 +1,6 @@
75 /* System-dependent calls for tar.
76
77 - Copyright (C) 2003, 2004, 2005, 2006, 2007,
78 - 2008 Free Software Foundation, Inc.
79 + Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
80
81 This program is free software; you can redistribute it and/or modify it
82 under the terms of the GNU General Public License as published by the
83 @@ -52,7 +51,12 @@ sys_detect_dev_null_output (void)
84 }
85
86 void
87 -sys_wait_for_child (pid_t child_pid, bool eof)
88 +sys_drain_input_pipe (void)
89 +{
90 +}
91 +
92 +void
93 +sys_wait_for_child (pid_t child_pid)
94 {
95 }
96
97 @@ -156,8 +160,26 @@ sys_detect_dev_null_output (void)
98 && archive_stat.st_ino == dev_null_stat.st_ino));
99 }
100
101 +/* Manage to fully drain a pipe we might be reading, so to not break it on
102 + the producer after the EOF block. FIXME: one of these days, GNU tar
103 + might become clever enough to just stop working, once there is no more
104 + work to do, we might have to revise this area in such time. */
105 +
106 +void
107 +sys_drain_input_pipe (void)
108 +{
109 + size_t r;
110 +
111 + if (access_mode == ACCESS_READ
112 + && ! _isrmt (archive)
113 + && (S_ISFIFO (archive_stat.st_mode) || S_ISSOCK (archive_stat.st_mode)))
114 + while ((r = rmtread (archive, record_start->buffer, record_size)) != 0
115 + && r != SAFE_READ_ERROR)
116 + continue;
117 +}
118 +
119 void
120 -sys_wait_for_child (pid_t child_pid, bool eof)
121 +sys_wait_for_child (pid_t child_pid)
122 {
123 if (child_pid)
124 {
125 @@ -171,11 +193,8 @@ sys_wait_for_child (pid_t child_pid, bool eof)
126 }
127
128 if (WIFSIGNALED (wait_status))
129 - {
130 - int sig = WTERMSIG (wait_status);
131 - if (!(!eof && sig == SIGPIPE))
132 - ERROR ((0, 0, _("Child died with signal %d"), sig));
133 - }
134 + ERROR ((0, 0, _("Child died with signal %d"),
135 + WTERMSIG (wait_status)));
136 else if (WEXITSTATUS (wait_status) != 0)
137 ERROR ((0, 0, _("Child returned status %d"),
138 WEXITSTATUS (wait_status)));