]> git.eshelyaron.com Git - emacs.git/commitdiff
; * src/android.c (android_run_select_thread): Fix typos.
authorPo Lu <luangruo@yahoo.com>
Thu, 23 Feb 2023 10:19:32 +0000 (18:19 +0800)
committerPo Lu <luangruo@yahoo.com>
Thu, 23 Feb 2023 10:19:32 +0000 (18:19 +0800)
src/android.c

index ffeb4b659d9e976e088532bdbbffa42415394e99..9c600be6cdf0d530a7bc6772c9967afd35dab14b 100644 (file)
@@ -344,12 +344,15 @@ android_run_select_thread (void *data)
       android_pselect_rc = rc;
       pthread_mutex_unlock (&event_queue.select_mutex);
 
-      /* Signal the main thread that there is now data to read.
-         It is ok to signal this condition variable without holding
-         the event queue lock, because android_select will always
-         wait for this to complete before returning.  */
+      /* Signal the main thread that there is now data to read.  Hold
+         the event queue lock during this process to make sure this
+         does not happen before the main thread begins to wait for the
+         condition variable.  */
+
+      pthread_mutex_lock (&event_queue.mutex);
       android_pselect_completed = true;
       pthread_cond_broadcast (&event_queue.read_var);
+      pthread_mutex_unlock (&event_queue.mutex);
 
       /* Read a single byte from the select pipe.  */
       read (select_pipe[0], &byte, 1);
@@ -392,10 +395,10 @@ android_run_select_thread (void *data)
          does not happen before the main thread begins to wait for the
          condition variable.  */
 
-      pthread_mutex_lock (&event_queue.select_mutex);
+      pthread_mutex_lock (&event_queue.mutex);
       android_pselect_completed = true;
       pthread_cond_broadcast (&event_queue.read_var);
-      pthread_mutex_unlock (&event_queue.select_mutex);
+      pthread_mutex_unlock (&event_queue.mutex);
 
       if (rc != -1 || errno != EINTR)
        /* Now, wait for SIGUSR1, unless pselect was interrupted and