aboutsummaryrefslogtreecommitdiffstats
path: root/src/android.c
diff options
context:
space:
mode:
authorPo Lu2023-01-14 22:48:28 +0800
committerPo Lu2023-01-14 22:48:28 +0800
commitc02a7b2ff48746fab891db16f58ccdc11d161745 (patch)
tree4f1db434cea50cddc743bc369853ae504fd9aaae /src/android.c
parent422035143f319e5bbd7a769247835c70dd3de495 (diff)
downloademacs-c02a7b2ff48746fab891db16f58ccdc11d161745.tar.gz
emacs-c02a7b2ff48746fab891db16f58ccdc11d161745.zip
Fix android_select
* src/android.c (android_run_select_thread, android_select): Handle EINTR in sem_wait and fix sigsets.
Diffstat (limited to 'src/android.c')
-rw-r--r--src/android.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/android.c b/src/android.c
index e4022501f9d..5e5e28c60ca 100644
--- a/src/android.c
+++ b/src/android.c
@@ -246,13 +246,23 @@ android_run_select_thread (void *data)
246 "pthread_sigmask: %s", 246 "pthread_sigmask: %s",
247 strerror (errno)); 247 strerror (errno));
248 248
249 sigdelset (&signals, SIGUSR1);
250
249 while (true) 251 while (true)
250 { 252 {
251 /* Wait for the thread to be released. */ 253 /* Wait for the thread to be released. */
252 sem_wait (&android_pselect_start_sem); 254 while (sem_wait (&android_pselect_start_sem) < 0)
255 ;;
253 256
254 /* Get the select lock and call pselect. */ 257 /* Get the select lock and call pselect. */
255 pthread_mutex_lock (&event_queue.select_mutex); 258 pthread_mutex_lock (&event_queue.select_mutex);
259
260 /* Make sure SIGUSR1 can always wake pselect up. */
261 if (android_pselect_sigset)
262 sigdelset (android_pselect_sigset, SIGUSR1);
263 else
264 android_pselect_sigset = &signals;
265
256 rc = pselect (android_pselect_nfds, 266 rc = pselect (android_pselect_nfds,
257 android_pselect_readfds, 267 android_pselect_readfds,
258 android_pselect_writefds, 268 android_pselect_writefds,
@@ -436,6 +446,7 @@ android_select (int nfds, fd_set *readfds, fd_set *writefds,
436 /* Release the select thread. */ 446 /* Release the select thread. */
437 sem_post (&android_pselect_start_sem); 447 sem_post (&android_pselect_start_sem);
438 448
449 /* Start waiting for the event queue condition to be set. */
439 pthread_cond_wait (&event_queue.read_var, &event_queue.mutex); 450 pthread_cond_wait (&event_queue.read_var, &event_queue.mutex);
440 451
441 /* Interrupt the select thread now, in case it's still in 452 /* Interrupt the select thread now, in case it's still in
@@ -443,7 +454,8 @@ android_select (int nfds, fd_set *readfds, fd_set *writefds,
443 pthread_kill (event_queue.select_thread, SIGUSR1); 454 pthread_kill (event_queue.select_thread, SIGUSR1);
444 455
445 /* Wait for pselect to return in any case. */ 456 /* Wait for pselect to return in any case. */
446 sem_wait (&android_pselect_sem); 457 while (sem_wait (&android_pselect_sem) < 0)
458 ;;
447 459
448 /* If there are now events in the queue, return 1. */ 460 /* If there are now events in the queue, return 1. */
449 if (event_queue.num_events) 461 if (event_queue.num_events)