[vlc-commits] commit: Maemo: work-around segmentation fault when poll() unwinds ( Rémi Denis-Courmont )

git at videolan.org git at videolan.org
Sun May 9 18:22:35 CEST 2010


vlc/vlc-1.1 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Dec 15 17:59:17 2009 +0200| [99160aa17dce3a6c0b3d100422cfed4685ce1b0f] | committer: Rémi Denis-Courmont 

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

(This seems like a toolchain bug)
(cherry picked from commit 7f42234cabfde2f61ced5694eb9e09ea49c40987)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.1.git/?a=commit;h=99160aa17dce3a6c0b3d100422cfed4685ce1b0f
---

 bin/vlc.c            |   14 ++++++++++++++
 include/vlc_fixups.h |    4 ++++
 src/misc/pthread.c   |    3 +++
 src/network/poll.c   |   34 +++++++++++++++++++++++++++++++++-
 4 files changed, 54 insertions(+), 1 deletions(-)

diff --git a/bin/vlc.c b/bin/vlc.c
index e141b4b..d50bc82 100644
--- a/bin/vlc.c
+++ b/bin/vlc.c
@@ -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);
diff --git a/include/vlc_fixups.h b/include/vlc_fixups.h
index c832197..25102fa 100644
--- a/include/vlc_fixups.h
+++ b/include/vlc_fixups.h
@@ -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
diff --git a/src/misc/pthread.c b/src/misc/pthread.c
index ca422cf..d7aeb4d 100644
--- a/src/misc/pthread.c
+++ b/src/misc/pthread.c
@@ -655,6 +655,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)



More information about the vlc-commits mailing list