emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] test-concurrency e4deba0 2/8: Fix merged code in process.c


From: Eli Zaretskii
Subject: [Emacs-diffs] test-concurrency e4deba0 2/8: Fix merged code in process.c and eval.c.
Date: Thu, 8 Dec 2016 17:13:48 +0000 (UTC)

branch: test-concurrency
commit e4deba098e0281538a0e7b04d849989f17e5bcc7
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Fix merged code in process.c and eval.c.
---
 src/eval.c    |   31 +++++++++++++++++++++++++------
 src/process.c |   13 ++++++++-----
 2 files changed, 33 insertions(+), 11 deletions(-)

diff --git a/src/eval.c b/src/eval.c
index c08f93a..4405b8b 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -3323,15 +3323,24 @@ rebind_for_thread_switch (void)
       if (bind->kind >= SPECPDL_LET)
        {
          Lisp_Object value = specpdl_saved_value (bind);
-
+         Lisp_Object sym = specpdl_symbol (bind);
+         bool was_trapped =
+           SYMBOLP (sym)
+           && XSYMBOL (sym)->trapped_write == SYMBOL_TRAPPED_WRITE;
+         /* FIXME: This is not clean, and if do_specbind signals an
+            error, the symbol will be left untrapped.  */
+         if (was_trapped)
+           XSYMBOL (sym)->trapped_write = SYMBOL_UNTRAPPED_WRITE;
          bind->let.saved_value = Qnil;
-         do_specbind (XSYMBOL (specpdl_symbol (bind)), bind, value);
+         do_specbind (XSYMBOL (sym, bind, value, true);
+         if (was_trapped)
+           XSYMBOL (sym)->trapped_write = SYMBOL_TRAPPED_WRITE;
        }
     }
 }
 
 static void
-do_one_unbind (union specbinding *this_binding, int unwinding)
+do_one_unbind (union specbinding *this_binding, bool unwinding)
 {
   eassert (unwinding || this_binding->kind >= SPECPDL_LET);
   switch (this_binding->kind)
@@ -3458,7 +3467,7 @@ unbind_to (ptrdiff_t count, Lisp_Object value)
       union specbinding this_binding;
       this_binding = *--specpdl_ptr;
 
-      do_one_unbind (&this_binding, 1);
+      do_one_unbind (&this_binding, true);
     }
 
   if (NILP (Vquit_flag) && !NILP (quitf))
@@ -3476,8 +3485,18 @@ unbind_for_thread_switch (struct thread_state *thr)
     {
       if ((--bind)->kind >= SPECPDL_LET)
        {
-         bind->let.saved_value = find_symbol_value (specpdl_symbol (bind));
-         do_one_unbind (bind, 0);
+         Lisp_Object sym = specpdl_symbol (bind);
+         bool was_trapped =
+           SYMBOLP (sym)
+           && XSYMBOL (sym)->trapped_write == SYMBOL_TRAPPED_WRITE;
+         bind->let.saved_value = find_symbol_value (sym);
+         /* FIXME: This is not clean, and if do_one_unbind signals an
+            error, the symbol will be left untrapped.  */
+         if (was_trapped)
+           XSYMBOL (sym)->trapped_write = SYMBOL_UNTRAPPED_WRITE;
+         do_one_unbind (bind, false);
+         if (was_trapped)
+           XSYMBOL (sym)->trapped_write = SYMBOL_TRAPPED_WRITE;
        }
     }
 }
diff --git a/src/process.c b/src/process.c
index e538c86..7f2a071 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1321,7 +1321,8 @@ See `set-process-sentinel' for more info on sentinels.  
*/)
 
 DEFUN ("set-process-thread", Fset_process_thread, Sset_process_thread,
        2, 2, 0,
-       doc: /* FIXME */)
+       doc: /* Set the locking thread of PROCESS to be THREAD.
+If THREAD is nil, the process is unlocked.  */)
   (Lisp_Object process, Lisp_Object thread)
 {
   struct Lisp_Process *proc;
@@ -1348,7 +1349,8 @@ DEFUN ("set-process-thread", Fset_process_thread, 
Sset_process_thread,
 
 DEFUN ("process-thread", Fprocess_thread, Sprocess_thread,
        1, 1, 0,
-       doc: /* FIXME */)
+       doc: /* Ret the locking thread of PROCESS.
+If PROCESS is unlocked, this function returns nil.  */)
   (Lisp_Object process)
 {
   CHECK_PROCESS (process);
@@ -4573,7 +4575,8 @@ is nil, from any process) before the timeout expired.  */)
       /* Can't wait for a process that is dedicated to a different
         thread.  */
       if (!EQ (procp->thread, Qnil) && !EQ (procp->thread, Fcurrent_thread ()))
-       error ("FIXME");
+       error ("Attempt to accept output from process %s locked to thread %s",
+              SDATA (procp->name), SDATA (XTHREAD (procp->thread)->name));
     }
   else
     just_this_one = Qnil;
@@ -5727,7 +5730,7 @@ wait_reading_process_output (intmax_t time_limit, int 
nsecs, int read_kbd,
 
                  if (0 <= p->infd && !EQ (p->filter, Qt)
                      && !EQ (p->command, Qt))
-                   delete_read_fd (p->infd);
+                   add_read_fd (p->infd);
                }
            }
        }                       /* End for each file descriptor.  */
@@ -7660,7 +7663,7 @@ add_keyboard_wait_descriptor (int desc)
 {
 #ifdef subprocesses /* Actually means "not MSDOS".  */
   eassert (desc >= 0 && desc < FD_SETSIZE);
-  fd_callback_info[desc].flags |= FOR_READ | KEYBOARD_FD;
+  fd_callback_info[desc].flags |= (FOR_READ | KEYBOARD_FD);
   if (desc > max_desc)
     max_desc = desc;
 #endif



reply via email to

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