[vlc-devel] [PATCH 3/4] Maemo: work-around segmentation fault when poll() unwinds
Rémi Denis-Courmont
remi at remlab.net
Sun Feb 7 12:52:26 CET 2010
---
bin/vlc.c | 11 +++++++++++
include/vlc_fixups.h | 4 ++++
src/misc/pthread.c | 3 +++
src/network/poll.c | 34 +++++++++++++++++++++++++++++++++-
4 files changed, 51 insertions(+), 1 deletions(-)
diff --git a/bin/vlc.c b/bin/vlc.c
index f944aae..51230c4 100644
--- a/bin/vlc.c
+++ b/bin/vlc.c
@@ -48,6 +48,13 @@ extern char *FromLocale (const char *);
#include <pthread.h>
#include <unistd.h>
+#ifdef HAVE_MAEMO
+static void dummy_handler (int signum)
+{
+ signal (signum, dummy_handler);
+}
+#endif
+
/*****************************************************************************
* main: parse command line, start interface and spawn threads.
*****************************************************************************/
@@ -118,6 +125,10 @@ 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);
+ signal (SIGRTMIN, dummy_handler);
+#endif
/* Block all these signals */
pthread_sigmask (SIG_BLOCK, &set, NULL);
diff --git a/include/vlc_fixups.h b/include/vlc_fixups.h
index ef6fae2..273c331 100644
--- a/include/vlc_fixups.h
+++ b/include/vlc_fixups.h
@@ -233,6 +233,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
diff --git a/src/misc/pthread.c b/src/misc/pthread.c
index 4522db0..10a91cb 100644
--- a/src/misc/pthread.c
+++ b/src/misc/pthread.c
@@ -640,6 +640,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
}
/**
diff --git a/src/network/poll.c b/src/network/poll.c
index cf9554a..eb97c83 100644
--- a/src/network/poll.c
+++ b/src/network/poll.c
@@ -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)
--
1.6.6.1
More information about the vlc-devel
mailing list