summaryrefslogtreecommitdiffstats
path: root/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.24/0058-fifo-Do-not-restart-open-if-it-already-found-a-partn.patch
diff options
context:
space:
mode:
authorKoen Kooi <koen@dominion.thruhere.net>2012-08-08 10:41:23 +0200
committerDenys Dmytriyenko <denis@denix.org>2012-10-17 15:51:17 -0400
commit56e60917b21bd76bfea7c65f9a885b60e3c128ef (patch)
tree7f20f0d359ee7be2d53ca7af8c763e9a4659d909 /recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.24/0058-fifo-Do-not-restart-open-if-it-already-found-a-partn.patch
parenteff601caffe58c3e8049140bdb02723b5cb62da4 (diff)
downloadmeta-ti-56e60917b21bd76bfea7c65f9a885b60e3c128ef.tar.gz
linux-ti33x-psp 3.2: update to 3.2.25
Signed-off-by: Koen Kooi <koen@dominion.thruhere.net> Signed-off-by: Denys Dmytriyenko <denys@ti.com> Signed-off-by: Denys Dmytriyenko <denis@denix.org>
Diffstat (limited to 'recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.24/0058-fifo-Do-not-restart-open-if-it-already-found-a-partn.patch')
-rw-r--r--recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.24/0058-fifo-Do-not-restart-open-if-it-already-found-a-partn.patch115
1 files changed, 115 insertions, 0 deletions
diff --git a/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.24/0058-fifo-Do-not-restart-open-if-it-already-found-a-partn.patch b/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.24/0058-fifo-Do-not-restart-open-if-it-already-found-a-partn.patch
new file mode 100644
index 00000000..99a8db5a
--- /dev/null
+++ b/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.24/0058-fifo-Do-not-restart-open-if-it-already-found-a-partn.patch
@@ -0,0 +1,115 @@
1From 13d0304203a528b1c1c76b5c9b6f5b8dc093f996 Mon Sep 17 00:00:00 2001
2From: Anders Kaseorg <andersk@MIT.EDU>
3Date: Sun, 15 Jul 2012 17:14:25 -0400
4Subject: [PATCH 058/109] fifo: Do not restart open() if it already found a
5 partner
6MIME-Version: 1.0
7Content-Type: text/plain; charset=UTF-8
8Content-Transfer-Encoding: 8bit
9
10commit 05d290d66be6ef77a0b962ebecf01911bd984a78 upstream.
11
12If a parent and child process open the two ends of a fifo, and the
13child immediately exits, the parent may receive a SIGCHLD before its
14open() returns. In that case, we need to make sure that open() will
15return successfully after the SIGCHLD handler returns, instead of
16throwing EINTR or being restarted. Otherwise, the restarted open()
17would incorrectly wait for a second partner on the other end.
18
19The following test demonstrates the EINTR that was wrongly thrown from
20the parent’s open(). Change .sa_flags = 0 to .sa_flags = SA_RESTART
21to see a deadlock instead, in which the restarted open() waits for a
22second reader that will never come. (On my systems, this happens
23pretty reliably within about 5 to 500 iterations. Others report that
24it manages to loop ~forever sometimes; YMMV.)
25
26 #include <sys/stat.h>
27 #include <sys/types.h>
28 #include <sys/wait.h>
29 #include <fcntl.h>
30 #include <signal.h>
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <unistd.h>
34
35 #define CHECK(x) do if ((x) == -1) {perror(#x); abort();} while(0)
36
37 void handler(int signum) {}
38
39 int main()
40 {
41 struct sigaction act = {.sa_handler = handler, .sa_flags = 0};
42 CHECK(sigaction(SIGCHLD, &act, NULL));
43 CHECK(mknod("fifo", S_IFIFO | S_IRWXU, 0));
44 for (;;) {
45 int fd;
46 pid_t pid;
47 putc('.', stderr);
48 CHECK(pid = fork());
49 if (pid == 0) {
50 CHECK(fd = open("fifo", O_RDONLY));
51 _exit(0);
52 }
53 CHECK(fd = open("fifo", O_WRONLY));
54 CHECK(close(fd));
55 CHECK(waitpid(pid, NULL, 0));
56 }
57 }
58
59This is what I suspect was causing the Git test suite to fail in
60t9010-svn-fe.sh:
61
62 http://bugs.debian.org/678852
63
64Signed-off-by: Anders Kaseorg <andersk@mit.edu>
65Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
66Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
67Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
68---
69 fs/fifo.c | 9 ++++-----
70 1 files changed, 4 insertions(+), 5 deletions(-)
71
72diff --git a/fs/fifo.c b/fs/fifo.c
73index b1a524d..cf6f434 100644
74--- a/fs/fifo.c
75+++ b/fs/fifo.c
76@@ -14,7 +14,7 @@
77 #include <linux/sched.h>
78 #include <linux/pipe_fs_i.h>
79
80-static void wait_for_partner(struct inode* inode, unsigned int *cnt)
81+static int wait_for_partner(struct inode* inode, unsigned int *cnt)
82 {
83 int cur = *cnt;
84
85@@ -23,6 +23,7 @@ static void wait_for_partner(struct inode* inode, unsigned int *cnt)
86 if (signal_pending(current))
87 break;
88 }
89+ return cur == *cnt ? -ERESTARTSYS : 0;
90 }
91
92 static void wake_up_partner(struct inode* inode)
93@@ -67,8 +68,7 @@ static int fifo_open(struct inode *inode, struct file *filp)
94 * seen a writer */
95 filp->f_version = pipe->w_counter;
96 } else {
97- wait_for_partner(inode, &pipe->w_counter);
98- if(signal_pending(current))
99+ if (wait_for_partner(inode, &pipe->w_counter))
100 goto err_rd;
101 }
102 }
103@@ -90,8 +90,7 @@ static int fifo_open(struct inode *inode, struct file *filp)
104 wake_up_partner(inode);
105
106 if (!pipe->readers) {
107- wait_for_partner(inode, &pipe->r_counter);
108- if (signal_pending(current))
109+ if (wait_for_partner(inode, &pipe->r_counter))
110 goto err_wr;
111 }
112 break;
113--
1141.7.7.6
115