aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/os-Linux/sigio.c
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2007-07-16 02:38:56 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-16 12:05:38 -0400
commitc43990162fc7f9d2f15a12797fdc6f9c0905f704 (patch)
tree64f8b776c4807da48971f3c24ca157c5e6ab921f /arch/um/os-Linux/sigio.c
parent42a359e31a0e438b5b978a8f0fecdbd3c86bb033 (diff)
uml: simplify helper stack handling
run_helper and run_helper_thread had arguments which were the same in all callers. run_helper's stack_out was always NULL and run_helper_thread's stack_order was always 0. These are now gone, and the constants folded into the code. Also fixed leaks of the helper stack in the AIO and SIGIO code. Signed-off-by: Jeff Dike <jdike@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/um/os-Linux/sigio.c')
-rw-r--r--arch/um/os-Linux/sigio.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/arch/um/os-Linux/sigio.c b/arch/um/os-Linux/sigio.c
index 8d4e0c6b8c92..2c23cb261188 100644
--- a/arch/um/os-Linux/sigio.c
+++ b/arch/um/os-Linux/sigio.c
@@ -26,6 +26,7 @@
26 * exitcall. 26 * exitcall.
27 */ 27 */
28static int write_sigio_pid = -1; 28static int write_sigio_pid = -1;
29static unsigned long write_sigio_stack;
29 30
30/* These arrays are initialized before the sigio thread is started, and 31/* These arrays are initialized before the sigio thread is started, and
31 * the descriptors closed after it is killed. So, it can't see them change. 32 * the descriptors closed after it is killed. So, it can't see them change.
@@ -144,8 +145,10 @@ static void update_thread(void)
144 return; 145 return;
145 fail: 146 fail:
146 /* Critical section start */ 147 /* Critical section start */
147 if(write_sigio_pid != -1) 148 if (write_sigio_pid != -1) {
148 os_kill_process(write_sigio_pid, 1); 149 os_kill_process(write_sigio_pid, 1);
150 free_stack(write_sigio_stack, 0);
151 }
149 write_sigio_pid = -1; 152 write_sigio_pid = -1;
150 close(sigio_private[0]); 153 close(sigio_private[0]);
151 close(sigio_private[1]); 154 close(sigio_private[1]);
@@ -243,7 +246,6 @@ static struct pollfd *setup_initial_poll(int fd)
243 246
244static void write_sigio_workaround(void) 247static void write_sigio_workaround(void)
245{ 248{
246 unsigned long stack;
247 struct pollfd *p; 249 struct pollfd *p;
248 int err; 250 int err;
249 int l_write_sigio_fds[2]; 251 int l_write_sigio_fds[2];
@@ -293,7 +295,8 @@ static void write_sigio_workaround(void)
293 memcpy(sigio_private, l_sigio_private, sizeof(l_sigio_private)); 295 memcpy(sigio_private, l_sigio_private, sizeof(l_sigio_private));
294 296
295 write_sigio_pid = run_helper_thread(write_sigio_thread, NULL, 297 write_sigio_pid = run_helper_thread(write_sigio_thread, NULL,
296 CLONE_FILES | CLONE_VM, &stack, 0); 298 CLONE_FILES | CLONE_VM,
299 &write_sigio_stack);
297 300
298 if (write_sigio_pid < 0) 301 if (write_sigio_pid < 0)
299 goto out_clear; 302 goto out_clear;
@@ -356,10 +359,12 @@ out:
356 359
357static void sigio_cleanup(void) 360static void sigio_cleanup(void)
358{ 361{
359 if(write_sigio_pid != -1){ 362 if (write_sigio_pid == -1)
360 os_kill_process(write_sigio_pid, 1); 363 return;
361 write_sigio_pid = -1; 364
362 } 365 os_kill_process(write_sigio_pid, 1);
366 free_stack(write_sigio_stack, 0);
367 write_sigio_pid = -1;
363} 368}
364 369
365__uml_exitcall(sigio_cleanup); 370__uml_exitcall(sigio_cleanup);