diff options
author | Koen Kooi <koen@dominion.thruhere.net> | 2012-08-08 10:41:23 +0200 |
---|---|---|
committer | Denys Dmytriyenko <denis@denix.org> | 2012-10-17 15:51:17 -0400 |
commit | 56e60917b21bd76bfea7c65f9a885b60e3c128ef (patch) | |
tree | 7f20f0d359ee7be2d53ca7af8c763e9a4659d909 /recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.24/0058-fifo-Do-not-restart-open-if-it-already-found-a-partn.patch | |
parent | eff601caffe58c3e8049140bdb02723b5cb62da4 (diff) | |
download | meta-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.patch | 115 |
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 @@ | |||
1 | From 13d0304203a528b1c1c76b5c9b6f5b8dc093f996 Mon Sep 17 00:00:00 2001 | ||
2 | From: Anders Kaseorg <andersk@MIT.EDU> | ||
3 | Date: Sun, 15 Jul 2012 17:14:25 -0400 | ||
4 | Subject: [PATCH 058/109] fifo: Do not restart open() if it already found a | ||
5 | partner | ||
6 | MIME-Version: 1.0 | ||
7 | Content-Type: text/plain; charset=UTF-8 | ||
8 | Content-Transfer-Encoding: 8bit | ||
9 | |||
10 | commit 05d290d66be6ef77a0b962ebecf01911bd984a78 upstream. | ||
11 | |||
12 | If a parent and child process open the two ends of a fifo, and the | ||
13 | child immediately exits, the parent may receive a SIGCHLD before its | ||
14 | open() returns. In that case, we need to make sure that open() will | ||
15 | return successfully after the SIGCHLD handler returns, instead of | ||
16 | throwing EINTR or being restarted. Otherwise, the restarted open() | ||
17 | would incorrectly wait for a second partner on the other end. | ||
18 | |||
19 | The following test demonstrates the EINTR that was wrongly thrown from | ||
20 | the parent’s open(). Change .sa_flags = 0 to .sa_flags = SA_RESTART | ||
21 | to see a deadlock instead, in which the restarted open() waits for a | ||
22 | second reader that will never come. (On my systems, this happens | ||
23 | pretty reliably within about 5 to 500 iterations. Others report that | ||
24 | it 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 | |||
59 | This is what I suspect was causing the Git test suite to fail in | ||
60 | t9010-svn-fe.sh: | ||
61 | |||
62 | http://bugs.debian.org/678852 | ||
63 | |||
64 | Signed-off-by: Anders Kaseorg <andersk@mit.edu> | ||
65 | Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> | ||
66 | Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> | ||
67 | Signed-off-by: Ben Hutchings <ben@decadent.org.uk> | ||
68 | --- | ||
69 | fs/fifo.c | 9 ++++----- | ||
70 | 1 files changed, 4 insertions(+), 5 deletions(-) | ||
71 | |||
72 | diff --git a/fs/fifo.c b/fs/fifo.c | ||
73 | index 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 | -- | ||
114 | 1.7.7.6 | ||
115 | |||