aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2016-12-30 11:36:07 +0200
committerEli Zaretskii2016-12-30 11:36:07 +0200
commit543532313a1d9570d6a74a7846b4e776a2282964 (patch)
tree72b0fc8e8fb161f04af620ef14a02836ad672791 /src
parentd9b126890dd729e18cb5522c38f33fc70daadd79 (diff)
downloademacs-543532313a1d9570d6a74a7846b4e776a2282964.tar.gz
emacs-543532313a1d9570d6a74a7846b4e776a2282964.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/process.c15
-rw-r--r--src/xgselect.c11
-rw-r--r--src/xgselect.h3
3 files changed, 17 insertions, 12 deletions
diff --git a/src/process.c b/src/process.c
index c5a46f992d7..c0c52c232b9 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,
5341 } 5341 }
5342#endif 5342#endif
5343 5343
5344/* HAVE_GLIB builds call thread_select in xgselect.c. */
5345#ifdef HAVE_GLIB
5346 nfds = xg_select (max_desc + 1,
5347 &Available, (check_write ? &Writeok : 0),
5348 NULL, &timeout, NULL);
5349#else /* !HAVE_GLIB */
5344 nfds = thread_select ( 5350 nfds = thread_select (
5345#if defined (HAVE_NS) 5351# ifdef HAVE_NS
5346 ns_select 5352 ns_select
5347#elif defined (HAVE_GLIB) 5353# else
5348 xg_select
5349#else
5350 pselect 5354 pselect
5351#endif 5355# endif
5352 , max_desc + 1, 5356 , max_desc + 1,
5353 &Available, 5357 &Available,
5354 (check_write ? &Writeok : 0), 5358 (check_write ? &Writeok : 0),
5355 NULL, &timeout, NULL); 5359 NULL, &timeout, NULL);
5360#endif /* !HAVE_GLIB */
5356 5361
5357#ifdef HAVE_GNUTLS 5362#ifdef HAVE_GNUTLS
5358 /* GnuTLS buffers data internally. In lowat mode it leaves 5363 /* GnuTLS buffers data internally. In lowat mode it leaves
diff --git a/src/xgselect.c b/src/xgselect.c
index a9461a5df5a..c73ef7ce5f2 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/>. */
25 25
26#include <glib.h> 26#include <glib.h>
27#include <errno.h> 27#include <errno.h>
28#include "lisp.h"
28#include "blockinput.h" 29#include "blockinput.h"
29#include "systime.h" 30#include "systime.h"
30 31
@@ -41,11 +42,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
41 42
42int 43int
43xg_select (int fds_lim, fd_set *rfds, fd_set *wfds, fd_set *efds, 44xg_select (int fds_lim, fd_set *rfds, fd_set *wfds, fd_set *efds,
44 struct timespec const *timeout, sigset_t const *sigmask) 45 struct timespec *timeout, sigset_t *sigmask)
45{ 46{
46 fd_set all_rfds, all_wfds; 47 fd_set all_rfds, all_wfds;
47 struct timespec tmo; 48 struct timespec tmo;
48 struct timespec const *tmop = timeout; 49 struct timespec *tmop = timeout;
49 50
50 GMainContext *context; 51 GMainContext *context;
51 bool have_wfds = wfds != NULL; 52 bool have_wfds = wfds != NULL;
@@ -113,9 +114,9 @@ xg_select (int fds_lim, fd_set *rfds, fd_set *wfds, fd_set *efds,
113 } 114 }
114 115
115 fds_lim = max_fds + 1; 116 fds_lim = max_fds + 1;
116 nfds = pselect (fds_lim, &all_rfds, have_wfds ? &all_wfds : NULL, 117 nfds = thread_select (pselect, fds_lim,
117 efds, tmop, sigmask); 118 &all_rfds, have_wfds ? &all_wfds : NULL, efds,
118 119 tmop, sigmask);
119 if (nfds < 0) 120 if (nfds < 0)
120 retval = nfds; 121 retval = nfds;
121 else if (nfds > 0) 122 else if (nfds > 0)
diff --git a/src/xgselect.h b/src/xgselect.h
index 4c56633e966..a56694229e5 100644
--- a/src/xgselect.h
+++ b/src/xgselect.h
@@ -27,7 +27,6 @@ struct timespec;
27 27
28extern int xg_select (int max_fds, 28extern int xg_select (int max_fds,
29 fd_set *rfds, fd_set *wfds, fd_set *efds, 29 fd_set *rfds, fd_set *wfds, fd_set *efds,
30 struct timespec const *timeout, 30 struct timespec *timeout, sigset_t *sigmask);
31 sigset_t const *sigmask);
32 31
33#endif /* XGSELECT_H */ 32#endif /* XGSELECT_H */