emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 5435323: Attempt to fix crashes with threads in GTK


From: Eli Zaretskii
Subject: [Emacs-diffs] master 5435323: Attempt to fix crashes with threads in GTK builds
Date: Fri, 30 Dec 2016 09:37:16 +0000 (UTC)

branch: master
commit 543532313a1d9570d6a74a7846b4e776a2282964
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Attempt to fix crashes with threads in GTK builds
    
    * src/xgselect.c (xg_select): Call pselect via thread_select, not
    directly, to avoid running Lisp (via unblock_input) when more than
    one thread could be running.  (Bug#25247)
    * src/process.c (wait_reading_process_output) [HAVE_GLIB]: Call
    xg_select directly instead of through thread_select.
    * src/xgselect.h (xg_select): Last 2 arguments are no longer
    'const', for consistency with thread_select.
---
 src/process.c  |   15 ++++++++++-----
 src/xgselect.c |   11 ++++++-----
 src/xgselect.h |    3 +--
 3 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/src/process.c b/src/process.c
index c5a46f9..c0c52c2 100644
--- a/src/process.c
+++ b/src/process.c
@@ -5341,18 +5341,23 @@ wait_reading_process_output (intmax_t time_limit, int 
nsecs, int read_kbd,
            }
 #endif
 
+/* HAVE_GLIB builds call thread_select in xgselect.c.  */
+#ifdef HAVE_GLIB
+         nfds = xg_select (max_desc + 1,
+                           &Available, (check_write ? &Writeok : 0),
+                           NULL, &timeout, NULL);
+#else  /* !HAVE_GLIB */
          nfds = thread_select (
-#if defined (HAVE_NS)
+# ifdef HAVE_NS
                                ns_select
-#elif defined (HAVE_GLIB)
-                               xg_select
-#else
+# else
                                pselect
-#endif
+# endif
                                , max_desc + 1,
                                &Available,
                                (check_write ? &Writeok : 0),
                                NULL, &timeout, NULL);
+#endif /* !HAVE_GLIB */
 
 #ifdef HAVE_GNUTLS
           /* GnuTLS buffers data internally.  In lowat mode it leaves
diff --git a/src/xgselect.c b/src/xgselect.c
index a9461a5..c73ef7c 100644
--- a/src/xgselect.c
+++ b/src/xgselect.c
@@ -25,6 +25,7 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 
 #include <glib.h>
 #include <errno.h>
+#include "lisp.h"
 #include "blockinput.h"
 #include "systime.h"
 
@@ -41,11 +42,11 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 
 int
 xg_select (int fds_lim, fd_set *rfds, fd_set *wfds, fd_set *efds,
-          struct timespec const *timeout, sigset_t const *sigmask)
+          struct timespec *timeout, sigset_t *sigmask)
 {
   fd_set all_rfds, all_wfds;
   struct timespec tmo;
-  struct timespec const *tmop = timeout;
+  struct timespec *tmop = timeout;
 
   GMainContext *context;
   bool have_wfds = wfds != NULL;
@@ -113,9 +114,9 @@ xg_select (int fds_lim, fd_set *rfds, fd_set *wfds, fd_set 
*efds,
     }
 
   fds_lim = max_fds + 1;
-  nfds = pselect (fds_lim, &all_rfds, have_wfds ? &all_wfds : NULL,
-                 efds, tmop, sigmask);
-
+  nfds = thread_select (pselect, fds_lim,
+                       &all_rfds, have_wfds ? &all_wfds : NULL, efds,
+                       tmop, sigmask);
   if (nfds < 0)
     retval = nfds;
   else if (nfds > 0)
diff --git a/src/xgselect.h b/src/xgselect.h
index 4c56633..a566942 100644
--- a/src/xgselect.h
+++ b/src/xgselect.h
@@ -27,7 +27,6 @@ struct timespec;
 
 extern int xg_select (int max_fds,
                      fd_set *rfds, fd_set *wfds, fd_set *efds,
-                     struct timespec const *timeout,
-                     sigset_t const *sigmask);
+                     struct timespec *timeout, sigset_t *sigmask);
 
 #endif /* XGSELECT_H */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]