Commit 7f42234c authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Maemo: work-around segmentation fault when poll() unwinds

(This seems like a toolchain bug)
parent 91550604
......@@ -50,6 +50,13 @@ extern void vlc_enable_override (void);
#include <unistd.h>
#include <dlfcn.h>
#ifdef HAVE_MAEMO
static void dummy_handler (int signum)
{
(void) signum;
}
#endif
/*****************************************************************************
* main: parse command line, start interface and spawn threads.
*****************************************************************************/
......@@ -132,6 +139,13 @@ int main( int i_argc, const char *ppsz_argv[] )
sigemptyset (&set);
for (unsigned i = 0; i < sizeof (sigs) / sizeof (sigs[0]); i++)
sigaddset (&set, sigs[i]);
#ifdef HAVE_MAEMO
sigaddset (&set, SIGRTMIN);
{
struct sigaction act = { .sa_handler = dummy_handler, };
sigaction (SIGRTMIN, &act, NULL);
}
#endif
/* Block all these signals */
pthread_sigmask (SIG_BLOCK, &set, NULL);
......
......@@ -241,6 +241,10 @@ struct pollfd
};
# define poll(a, b, c) vlc_poll(a, b, c)
#elif defined (HAVE_MAEMO)
# include <poll.h>
# define poll(a, b, c) vlc_poll(a, b, c)
int vlc_poll (struct pollfd *, unsigned, int);
#endif
#ifndef HAVE_TDESTROY
......
......@@ -688,6 +688,9 @@ int vlc_clone (vlc_thread_t *p_handle, void * (*entry) (void *), void *data,
void vlc_cancel (vlc_thread_t thread_id)
{
pthread_cancel (thread_id);
#ifdef HAVE_MAEMO
pthread_kill (thread_id, SIGRTMIN);
#endif
}
/**
......
......@@ -30,7 +30,39 @@
#include <vlc_network.h>
#ifdef HAVE_POLL
#if HAVE_MAEMO
# include <signal.h>
# include <errno.h>
# include <poll.h>
int vlc_poll (struct pollfd *fds, unsigned nfds, int timeout)
{
struct timespec tsbuf, *ts;
sigset_t set;
int canc, ret;
if (timeout != -1)
{
div_t d = div (timeout, 1000);
tsbuf.tv_sec = d.quot;
tsbuf.tv_nsec = d.rem * 1000000;
ts = &tsbuf;
}
else
ts = NULL;
pthread_sigmask (SIG_BLOCK, NULL, &set);
sigdelset (&set, SIGRTMIN);
canc = vlc_savecancel ();
ret = ppoll (fds, nfds, ts, &set);
vlc_restorecancel (canc);
vlc_testcancel ();
return ret;
}
#elif defined (HAVE_POLL)
struct pollfd;
int vlc_poll (struct pollfd *fds, unsigned nfds, int timeout)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment