* sigproc.h (no_thread_exit_protect): New class.
* sigproc.cc (thread_exit): Use no_thread_exit_protect to determine if we need to coordinate ThreadExit/ExitProcess. * fhandler_dsp.cc (fhandler_dev_dsp::Audio_out::stop): Use no_thread_exit_protect to kludge around waiting for waveOutClose as it waits for a thread that never exits. (fhandler_dev_dsp::Audio_in::stop): Ditto for waveInClose. * fhandler.h (fhandler_dev_dsp::base): New method. (fhandler_dev_dsp::_read): Ditto. (fhandler_dev_dsp::_write): Ditto. (fhandler_dev_dsp::_ioctl): Ditto. (fhandler_dev_dsp::_fixup_after_fork): Ditto. (fhandler_dev_dsp::_fixup_after_exec): Ditto. * fhandler_dsp.cc (fhandler_dev_dsp::read): Call real function via base() pointer. (fhandler_dev_dsp::write): Ditto. (fhandler_dev_dsp::ioctl): Ditto. (fhandler_dev_dsp::fixup_after_fork): Ditto. (fhandler_dev_dsp::fixup_after_exec): Ditto. (fhandler_dev_dsp::_read): Rename by adding an leading underscore. (fhandler_dev_dsp::_write): Ditto. (fhandler_dev_dsp::_ioctl): Ditto. (fhandler_dev_dsp::_fixup_after_fork): Ditto. (fhandler_dev_dsp::_fixup_after_exec): Ditto.
This commit is contained in:
parent
600afd99ab
commit
4f0b5a097d
|
@ -1,3 +1,33 @@
|
||||||
|
2014-03-17 Christopher Faylor <me.cygwin2014@cgf.cx>
|
||||||
|
|
||||||
|
* sigproc.h (no_thread_exit_protect): New class.
|
||||||
|
* sigproc.cc (thread_exit): Use no_thread_exit_protect to determine if
|
||||||
|
we need to coordinate ThreadExit/ExitProcess.
|
||||||
|
* fhandler_dsp.cc (fhandler_dev_dsp::Audio_out::stop): Use
|
||||||
|
no_thread_exit_protect to kludge around waiting for waveOutClose as it
|
||||||
|
waits for a thread that never exits.
|
||||||
|
(fhandler_dev_dsp::Audio_in::stop): Ditto for waveInClose.
|
||||||
|
|
||||||
|
2014-03-16 Christopher Faylor <me.cygwin2014@cgf.cx>
|
||||||
|
|
||||||
|
* fhandler.h (fhandler_dev_dsp::base): New method.
|
||||||
|
(fhandler_dev_dsp::_read): Ditto.
|
||||||
|
(fhandler_dev_dsp::_write): Ditto.
|
||||||
|
(fhandler_dev_dsp::_ioctl): Ditto.
|
||||||
|
(fhandler_dev_dsp::_fixup_after_fork): Ditto.
|
||||||
|
(fhandler_dev_dsp::_fixup_after_exec): Ditto.
|
||||||
|
* fhandler_dsp.cc (fhandler_dev_dsp::read): Call real function via
|
||||||
|
base() pointer.
|
||||||
|
(fhandler_dev_dsp::write): Ditto.
|
||||||
|
(fhandler_dev_dsp::ioctl): Ditto.
|
||||||
|
(fhandler_dev_dsp::fixup_after_fork): Ditto.
|
||||||
|
(fhandler_dev_dsp::fixup_after_exec): Ditto.
|
||||||
|
(fhandler_dev_dsp::_read): Rename by adding an leading underscore.
|
||||||
|
(fhandler_dev_dsp::_write): Ditto.
|
||||||
|
(fhandler_dev_dsp::_ioctl): Ditto.
|
||||||
|
(fhandler_dev_dsp::_fixup_after_fork): Ditto.
|
||||||
|
(fhandler_dev_dsp::_fixup_after_exec): Ditto.
|
||||||
|
|
||||||
2014-03-12 Corinna Vinschen <corinna@vinschen.de>
|
2014-03-12 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* cygheap.h (enum cygheap_pwdgrp::cache_t): Remove.
|
* cygheap.h (enum cygheap_pwdgrp::cache_t): Remove.
|
||||||
|
|
|
@ -1790,16 +1790,23 @@ class fhandler_dev_dsp: public fhandler_base
|
||||||
Audio_in *audio_in_;
|
Audio_in *audio_in_;
|
||||||
public:
|
public:
|
||||||
fhandler_dev_dsp ();
|
fhandler_dev_dsp ();
|
||||||
|
fhandler_dev_dsp *base () const {return (fhandler_dev_dsp *)archetype;}
|
||||||
|
|
||||||
int open (int flags, mode_t mode = 0);
|
int open (int flags, mode_t mode = 0);
|
||||||
ssize_t __stdcall write (const void *ptr, size_t len);
|
ssize_t __stdcall write (const void *ptr, size_t len);
|
||||||
void __reg3 read (void *ptr, size_t& len);
|
void __reg3 read (void *ptr, size_t& len);
|
||||||
int ioctl (unsigned int cmd, void *);
|
int ioctl (unsigned int cmd, void *);
|
||||||
off_t lseek (off_t, int) { return 0; }
|
|
||||||
int close ();
|
int close ();
|
||||||
void fixup_after_fork (HANDLE parent);
|
void fixup_after_fork (HANDLE parent);
|
||||||
void fixup_after_exec ();
|
void fixup_after_exec ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
ssize_t __stdcall _write (const void *ptr, size_t len);
|
||||||
|
void __reg3 _read (void *ptr, size_t& len);
|
||||||
|
int _ioctl (unsigned int cmd, void *);
|
||||||
|
void _fixup_after_fork (HANDLE parent);
|
||||||
|
void _fixup_after_exec ();
|
||||||
|
|
||||||
void close_audio_in ();
|
void close_audio_in ();
|
||||||
void close_audio_out (bool immediately = false);
|
void close_audio_out (bool immediately = false);
|
||||||
bool use_archetype () const {return true;}
|
bool use_archetype () const {return true;}
|
||||||
|
|
|
@ -435,6 +435,7 @@ fhandler_dev_dsp::Audio_out::stop (bool immediately)
|
||||||
debug_printf ("%u = waveOutUnprepareHeader(%p)", rc, pHdr);
|
debug_printf ("%u = waveOutUnprepareHeader(%p)", rc, pHdr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
no_thread_exit_protect for_now (true);
|
||||||
rc = waveOutClose (dev_);
|
rc = waveOutClose (dev_);
|
||||||
debug_printf ("%u = waveOutClose()", rc);
|
debug_printf ("%u = waveOutClose()", rc);
|
||||||
|
|
||||||
|
@ -810,6 +811,7 @@ fhandler_dev_dsp::Audio_in::stop ()
|
||||||
debug_printf ("%u = waveInUnprepareHeader(%p)", rc, pHdr);
|
debug_printf ("%u = waveInUnprepareHeader(%p)", rc, pHdr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
no_thread_exit_protect for_now (true);
|
||||||
rc = waveInClose (dev_);
|
rc = waveInClose (dev_);
|
||||||
debug_printf ("%u = waveInClose()", rc);
|
debug_printf ("%u = waveInClose()", rc);
|
||||||
|
|
||||||
|
@ -1003,6 +1005,37 @@ fhandler_dev_dsp::fhandler_dev_dsp ():
|
||||||
dev ().parse (FH_OSS_DSP);
|
dev ().parse (FH_OSS_DSP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ssize_t __stdcall
|
||||||
|
fhandler_dev_dsp::write (const void *ptr, size_t len)
|
||||||
|
{
|
||||||
|
return base ()->_write (ptr, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
void __reg3
|
||||||
|
fhandler_dev_dsp::read (void *ptr, size_t& len)
|
||||||
|
{
|
||||||
|
return base ()->_read (ptr, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
fhandler_dev_dsp::ioctl (unsigned int cmd, void *)
|
||||||
|
{
|
||||||
|
return base ()->_ioctl (cmd, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
fhandler_dev_dsp::fixup_after_fork (HANDLE parent)
|
||||||
|
{
|
||||||
|
base ()->fixup_after_fork (parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
fhandler_dev_dsp::fixup_after_exec ()
|
||||||
|
{
|
||||||
|
base ()->fixup_after_exec ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
fhandler_dev_dsp::open (int flags, mode_t mode)
|
fhandler_dev_dsp::open (int flags, mode_t mode)
|
||||||
{
|
{
|
||||||
|
@ -1046,7 +1079,7 @@ fhandler_dev_dsp::open (int flags, mode_t mode)
|
||||||
#define IS_READ() ((get_flags() & O_ACCMODE) != O_WRONLY)
|
#define IS_READ() ((get_flags() & O_ACCMODE) != O_WRONLY)
|
||||||
|
|
||||||
ssize_t __stdcall
|
ssize_t __stdcall
|
||||||
fhandler_dev_dsp::write (const void *ptr, size_t len)
|
fhandler_dev_dsp::_write (const void *ptr, size_t len)
|
||||||
{
|
{
|
||||||
debug_printf ("ptr=%p len=%ld", ptr, len);
|
debug_printf ("ptr=%p len=%ld", ptr, len);
|
||||||
int len_s = len;
|
int len_s = len;
|
||||||
|
@ -1092,7 +1125,7 @@ fhandler_dev_dsp::write (const void *ptr, size_t len)
|
||||||
}
|
}
|
||||||
|
|
||||||
void __reg3
|
void __reg3
|
||||||
fhandler_dev_dsp::read (void *ptr, size_t& len)
|
fhandler_dev_dsp::_read (void *ptr, size_t& len)
|
||||||
{
|
{
|
||||||
debug_printf ("ptr=%p len=%ld", ptr, len);
|
debug_printf ("ptr=%p len=%ld", ptr, len);
|
||||||
|
|
||||||
|
@ -1159,7 +1192,7 @@ fhandler_dev_dsp::close ()
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
fhandler_dev_dsp::ioctl (unsigned int cmd, void *buf)
|
fhandler_dev_dsp::_ioctl (unsigned int cmd, void *buf)
|
||||||
{
|
{
|
||||||
debug_printf ("audio_in=%p audio_out=%p", audio_in_, audio_out_);
|
debug_printf ("audio_in=%p audio_out=%p", audio_in_, audio_out_);
|
||||||
int *intbuf = (int *) buf;
|
int *intbuf = (int *) buf;
|
||||||
|
@ -1362,7 +1395,7 @@ fhandler_dev_dsp::ioctl (unsigned int cmd, void *buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
fhandler_dev_dsp::fixup_after_fork (HANDLE parent)
|
fhandler_dev_dsp::_fixup_after_fork (HANDLE parent)
|
||||||
{ // called from new child process
|
{ // called from new child process
|
||||||
debug_printf ("audio_in=%p audio_out=%p",
|
debug_printf ("audio_in=%p audio_out=%p",
|
||||||
audio_in_, audio_out_);
|
audio_in_, audio_out_);
|
||||||
|
@ -1375,7 +1408,7 @@ fhandler_dev_dsp::fixup_after_fork (HANDLE parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
fhandler_dev_dsp::fixup_after_exec ()
|
fhandler_dev_dsp::_fixup_after_exec ()
|
||||||
{
|
{
|
||||||
debug_printf ("audio_in=%p audio_out=%p, close_on_exec %d",
|
debug_printf ("audio_in=%p audio_out=%p, close_on_exec %d",
|
||||||
audio_in_, audio_out_, close_on_exec ());
|
audio_in_, audio_out_, close_on_exec ());
|
||||||
|
|
|
@ -39,6 +39,8 @@ struct sigaction *global_sigs;
|
||||||
const char *__sp_fn ;
|
const char *__sp_fn ;
|
||||||
int __sp_ln;
|
int __sp_ln;
|
||||||
|
|
||||||
|
bool no_thread_exit_protect::flag;
|
||||||
|
|
||||||
char NO_COPY myself_nowait_dummy[1] = {'0'};// Flag to sig_send that signal goes to
|
char NO_COPY myself_nowait_dummy[1] = {'0'};// Flag to sig_send that signal goes to
|
||||||
// current process but no wait is required
|
// current process but no wait is required
|
||||||
|
|
||||||
|
@ -446,6 +448,8 @@ void
|
||||||
exit_thread (DWORD res)
|
exit_thread (DWORD res)
|
||||||
{
|
{
|
||||||
# undef ExitThread
|
# undef ExitThread
|
||||||
|
if (no_thread_exit_protect ())
|
||||||
|
ExitThread (res);
|
||||||
sigfillset (&_my_tls.sigmask); /* No signals wanted */
|
sigfillset (&_my_tls.sigmask); /* No signals wanted */
|
||||||
lock_process for_now; /* May block indefinitely when exiting. */
|
lock_process for_now; /* May block indefinitely when exiting. */
|
||||||
HANDLE h;
|
HANDLE h;
|
||||||
|
@ -465,7 +469,7 @@ exit_thread (DWORD res)
|
||||||
siginfo_t si = {__SIGTHREADEXIT, SI_KERNEL};
|
siginfo_t si = {__SIGTHREADEXIT, SI_KERNEL};
|
||||||
si.si_cyg = h;
|
si.si_cyg = h;
|
||||||
sig_send (myself_nowait, si, &_my_tls);
|
sig_send (myself_nowait, si, &_my_tls);
|
||||||
ExitThread (0);
|
ExitThread (res);
|
||||||
}
|
}
|
||||||
|
|
||||||
int __reg3
|
int __reg3
|
||||||
|
|
|
@ -83,6 +83,22 @@ int kill_pgrp (pid_t, siginfo_t&);
|
||||||
void __reg1 exit_thread (DWORD) __attribute__ ((noreturn));
|
void __reg1 exit_thread (DWORD) __attribute__ ((noreturn));
|
||||||
void __reg1 setup_signal_exit (int);
|
void __reg1 setup_signal_exit (int);
|
||||||
|
|
||||||
|
class no_thread_exit_protect
|
||||||
|
{
|
||||||
|
static bool flag;
|
||||||
|
bool modify;
|
||||||
|
public:
|
||||||
|
no_thread_exit_protect (int) {flag = true; modify = true;}
|
||||||
|
~no_thread_exit_protect ()
|
||||||
|
{
|
||||||
|
if (modify)
|
||||||
|
flag = false;
|
||||||
|
}
|
||||||
|
no_thread_exit_protect () {modify = false;}
|
||||||
|
operator int () {return flag;}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
extern "C" void sigdelayed ();
|
extern "C" void sigdelayed ();
|
||||||
|
|
||||||
extern char myself_nowait_dummy[];
|
extern char myself_nowait_dummy[];
|
||||||
|
|
Loading…
Reference in New Issue