aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2023-06-12 14:19:01 +0800
committerPo Lu2023-06-12 14:19:01 +0800
commit3b08bb1318cd0bf6bc1811b520f9c6934b1aa3bd (patch)
treeb7effb4669608cb3329923a7c7a8a1387dbea412 /src
parente3196835ed08a1d1a675b933a53d1a397defd561 (diff)
downloademacs-3b08bb1318cd0bf6bc1811b520f9c6934b1aa3bd.tar.gz
emacs-3b08bb1318cd0bf6bc1811b520f9c6934b1aa3bd.zip
Fix deadlocks
* java/org/gnu/emacs/EmacsView.java (EmacsView) (showOnScreenKeyboard, hideOnScreenKeyboard): Don't synchronize. * java/org/gnu/emacs/EmacsWindow.java (EmacsWindow) (toggleOnScreenKeyboard): Revert to calling IMM functions from the main thread. * src/android.c (struct android_event_container) (android_pselect_nfds, android_pselect_readfds) (android_pselect_writefds, android_pselect_exceptfds) (android_pselect_timeout): Don't make volatile. (android_wait_event): Run queries if necessary.
Diffstat (limited to 'src')
-rw-r--r--src/android.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/android.c b/src/android.c
index 4414d465107..873d821361c 100644
--- a/src/android.c
+++ b/src/android.c
@@ -272,7 +272,7 @@ void *unused_pointer;
272struct android_event_container 272struct android_event_container
273{ 273{
274 /* The next and last events in this queue. */ 274 /* The next and last events in this queue. */
275 struct android_event_container *volatile next, *last; 275 struct android_event_container *next, *last;
276 276
277 /* The event itself. */ 277 /* The event itself. */
278 union android_event event; 278 union android_event event;
@@ -301,11 +301,11 @@ struct android_event_queue
301}; 301};
302 302
303/* Arguments to pselect used by the select thread. */ 303/* Arguments to pselect used by the select thread. */
304static volatile int android_pselect_nfds; 304static int android_pselect_nfds;
305static fd_set *volatile android_pselect_readfds; 305static fd_set *android_pselect_readfds;
306static fd_set *volatile android_pselect_writefds; 306static fd_set *android_pselect_writefds;
307static fd_set *volatile android_pselect_exceptfds; 307static fd_set *android_pselect_exceptfds;
308static struct timespec *volatile android_pselect_timeout; 308static struct timespec *android_pselect_timeout;
309 309
310/* Value of pselect. */ 310/* Value of pselect. */
311static int android_pselect_rc; 311static int android_pselect_rc;
@@ -569,12 +569,20 @@ android_pending (void)
569 return i; 569 return i;
570} 570}
571 571
572/* Forward declaration. */
573
574static void android_check_query (void);
575
572/* Wait for events to become available synchronously. Return once an 576/* Wait for events to become available synchronously. Return once an
573 event arrives. */ 577 event arrives. Also, reply to the UI thread whenever it requires a
578 response. */
574 579
575void 580void
576android_wait_event (void) 581android_wait_event (void)
577{ 582{
583 /* Run queries from the UI thread to the Emacs thread. */
584 android_check_query ();
585
578 pthread_mutex_lock (&event_queue.mutex); 586 pthread_mutex_lock (&event_queue.mutex);
579 587
580 /* Wait for events to appear if there are none available to 588 /* Wait for events to appear if there are none available to
@@ -584,6 +592,10 @@ android_wait_event (void)
584 &event_queue.mutex); 592 &event_queue.mutex);
585 593
586 pthread_mutex_unlock (&event_queue.mutex); 594 pthread_mutex_unlock (&event_queue.mutex);
595
596 /* Check for queries again. If a query is sent after the call to
597 `android_check_query' above, `read_var' will be signaled. */
598 android_check_query ();
587} 599}
588 600
589void 601void
@@ -701,10 +713,6 @@ android_write_event (union android_event *event)
701 should answer the query ASAP. */ 713 should answer the query ASAP. */
702static bool android_urgent_query; 714static bool android_urgent_query;
703 715
704/* Forward declaration. */
705
706static void android_check_query (void);
707
708int 716int
709android_select (int nfds, fd_set *readfds, fd_set *writefds, 717android_select (int nfds, fd_set *readfds, fd_set *writefds,
710 fd_set *exceptfds, struct timespec *timeout) 718 fd_set *exceptfds, struct timespec *timeout)