[Dosemu-cvs] [SCM] dosemu branch devel updated. dosemu-1.4.0.8-721-gfdc9e06
Brought to you by:
bartoldeman
From: Stas S. <st...@us...> - 2014-06-29 03:01:23
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "dosemu". The branch, devel has been updated via fdc9e06239b69f5f85ff2f383fb5756e86edcaa3 (commit) via 9a5dce39f7e1b82484311ab8681e299c6cac0ac2 (commit) via 61fd6b09947bfddf2ffb36ccd64606192abd98ee (commit) via 7019be85d3252d77f88aa05e44d0c3e6ebe15cdf (commit) from 60f132566ce18afdd6e10ce0ee270f76da0dbd55 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://sourceforge.net/p/dosemu/code/ci/fdc9e06239b69f5f85ff2f383fb5756e86edcaa3 commit fdc9e06239b69f5f85ff2f383fb5756e86edcaa3 Author: Stas Sergeev <st...@us...> Date: Sun Jun 29 06:56:59 2014 +0400 do waitpid() in SIGCHLD handler for timidity diff --git a/src/arch/linux/async/signal.c b/src/arch/linux/async/signal.c index 9b3cc04..176a659 100644 --- a/src/arch/linux/async/signal.c +++ b/src/arch/linux/async/signal.c @@ -396,7 +396,8 @@ static void cleanup_child(void *arg) pid2 = waitpid(pid, &status, WNOHANG); if (pid2 != pid) return; - chld_hndl[i].handler(); + if (chld_hndl[i].handler) + chld_hndl[i].handler(); } /* this cleaning up is necessary to avoid the port server becoming diff --git a/src/plugin/midimisc/mid_o_tmdty.c b/src/plugin/midimisc/mid_o_tmdty.c index 46a5797..2ca6f1b 100644 --- a/src/plugin/midimisc/mid_o_tmdty.c +++ b/src/plugin/midimisc/mid_o_tmdty.c @@ -182,6 +182,8 @@ static int midotmdty_preinit(void) close(tmdty_pipe_in[1]); ctrl_sock_in = tmdty_pipe_in[0]; ctrl_sock_out = tmdty_pipe_out[1]; + /* no handler, default handler does waitpid() */ + sigchld_register_handler(tmdty_pid, NULL); return TRUE; @@ -252,12 +254,10 @@ static int midotmdty_detect(void) } if (!ret) { + sigchld_enable_handler(tmdty_pid, 0); close(data_sock); close(ctrl_sock_out); - if (tmdty_pid != -1) { - waitpid(tmdty_pid, &status, 0); - tmdty_pid = -1; - } + waitpid(tmdty_pid, &status, 0); } return ret; @@ -338,16 +338,14 @@ static void midotmdty_done(void) shutdown(data_sock, 2); close(data_sock); } + sigchld_enable_handler(tmdty_pid, 0); write(ctrl_sock_out, cmd2, strlen(cmd2)); n = read(ctrl_sock_in, buf, sizeof(buf) - 1); buf[n] = 0; S_printf("\tQuit: %s\n", buf); close(ctrl_sock_out); - if (tmdty_pid != -1) { - waitpid(tmdty_pid, &status, 0); - tmdty_pid = -1; - } + waitpid(tmdty_pid, &status, 0); } static void midotmdty_reset(void) @@ -370,8 +368,6 @@ static void midotmdty_reset(void) static void midotmdty_write(Bit8u val) { - if (tmdty_pid == -1) - return; send(data_sock, &val, 1, MSG_DONTWAIT); } http://sourceforge.net/p/dosemu/code/ci/9a5dce39f7e1b82484311ab8681e299c6cac0ac2 commit 9a5dce39f7e1b82484311ab8681e299c6cac0ac2 Author: Stas Sergeev <st...@us...> Date: Sun Jun 29 06:30:45 2014 +0400 fix race in nested signal handling Before allowing the nested signal we need to restore segment registers. So set all signals initially to blocked, and unblock only when it is safe. diff --git a/src/arch/linux/async/signal.c b/src/arch/linux/async/signal.c index 6f7e819..9b3cc04 100644 --- a/src/arch/linux/async/signal.c +++ b/src/arch/linux/async/signal.c @@ -103,8 +103,9 @@ dosemu_sigaction_wrapper(int sig, void *fun, int flags) sigset_t mask; sa.sa_flags = flags; - sigemptyset(&mask); - addset_signals_that_queue(&mask); + /* initially block all signals. The handler will unblock some + * when it is safe (after segment registers are restored) */ + sigfillset(&mask); sa.sa_mask = mask; if (sa.sa_flags & SA_ONSTACK) { @@ -249,7 +250,7 @@ int check_fix_fs_gs_base(unsigned char prefix) expects. That means restoring fs and gs for vm86 (necessary for 2.4 kernels) and fs, gs and eflags for DPMI. */ __attribute__((no_instrument_function)) -void init_handler(struct sigcontext_struct *scp) +static void __init_handler(struct sigcontext_struct *scp) { /* * FIRST thing to do in signal handlers - to avoid being trapped into int0x11 @@ -330,6 +331,25 @@ void init_handler(struct sigcontext_struct *scp) loadregister(gs, eflags_fs_gs.gs); } +__attribute__((no_instrument_function)) +void init_handler(struct sigcontext_struct *scp) +{ + /* All signals are initially blocked. + * We need to restore registers before unblocking signals. + * Otherwise the nested signal handler will restore the registers + * and return; the current signal handler will then save the wrong + * registers. + * Note: in 64bit mode some segment registers are neither saved nor + * restored by the signal dispatching code in kernel, so we have + * to restore them by hands. + */ + sigset_t mask; + __init_handler(scp); + sigemptyset(&mask); + addset_signals_that_queue(&mask); + sigprocmask(SIG_SETMASK, &mask, NULL); +} + static int ld_sig; static void leavedos_call(void *arg) { http://sourceforge.net/p/dosemu/code/ci/61fd6b09947bfddf2ffb36ccd64606192abd98ee commit 61fd6b09947bfddf2ffb36ccd64606192abd98ee Author: Stas Sergeev <st...@us...> Date: Sun Jun 29 05:03:32 2014 +0400 add dpmi awareness for SIGCHLD and SIGTERM handlers diff --git a/src/arch/linux/async/signal.c b/src/arch/linux/async/signal.c index 0856566..6f7e819 100644 --- a/src/arch/linux/async/signal.c +++ b/src/arch/linux/async/signal.c @@ -388,6 +388,7 @@ static void sig_child(int sig, siginfo_t *si, void *uc) (struct sigcontext_struct *)&((ucontext_t *)uc)->uc_mcontext; init_handler(scp); SIGNAL_save(cleanup_child, &si->si_pid, sizeof(si->si_pid), __func__); + dpmi_iret_setup(scp); } __attribute__((no_instrument_function)) @@ -406,6 +407,8 @@ static void leavedos_signal(int sig) g_printf("Interrupting active signal handlers\n"); in_handle_signals = 0; } + /* process it now */ + handle_signals(); } /* Silly Interrupt Generator Initialization/Closedown */ http://sourceforge.net/p/dosemu/code/ci/7019be85d3252d77f88aa05e44d0c3e6ebe15cdf commit 7019be85d3252d77f88aa05e44d0c3e6ebe15cdf Author: Stas Sergeev <st...@us...> Date: Sun Jun 29 04:11:20 2014 +0400 coopth: re-introduce coopth_leave() Same as coopth_detach() but is allowed to be called from main thread. diff --git a/src/base/misc/coopth.c b/src/base/misc/coopth.c index 8f84344..281100d 100644 --- a/src/base/misc/coopth.c +++ b/src/base/misc/coopth.c @@ -823,6 +823,15 @@ void coopth_detach(void) switch_state(COOPTH_DETACH); } +/* same as coopth_detach(), but is allowed to be called from main thr + * (in which case it just returns) */ +void coopth_leave(void) +{ + if (!_coopth_is_in_thread_nowarn()) + return; + coopth_detach(); +} + static void do_awake(struct coopth_per_thread_t *pth) { assert(pth->state == COOPTHS_SLEEPING); diff --git a/src/include/coopth.h b/src/include/coopth.h index d3d13c3..233f018 100644 --- a/src/include/coopth.h +++ b/src/include/coopth.h @@ -40,7 +40,7 @@ void coopth_sleep(void); void coopth_sched(void); void coopth_detach(void); void coopth_attach(void); -#define coopth_leave() coopth_detach() +void coopth_leave(void); void coopth_exit(void); void coopth_wake_up(int tid); void coopth_asleep(int tid); ----------------------------------------------------------------------- Summary of changes: src/arch/linux/async/signal.c | 32 ++++++++++++++++++++++++++++---- src/base/misc/coopth.c | 9 +++++++++ src/include/coopth.h | 2 +- src/plugin/midimisc/mid_o_tmdty.c | 16 ++++++---------- 4 files changed, 44 insertions(+), 15 deletions(-) hooks/post-receive -- dosemu |