[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 9970816: Avoid aborts when a thread signals an erro
From: |
Eli Zaretskii |
Subject: |
[Emacs-diffs] master 9970816: Avoid aborts when a thread signals an error |
Date: |
Sun, 11 Dec 2016 16:00:13 +0000 (UTC) |
branch: master
commit 997081634a3b6c2359226305db05c818c492a9b2
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>
Avoid aborts when a thread signals an error
* src/thread.h (struct thread_state): Add members
m_waiting_for_input and m_input_available_clear_time.
(waiting_for_input, input_available_clear_time): New macros.
* src/keyboard.c (waiting_for_input, input_available_clear_time):
Remove; they are now macros that reference the current thread.
(Bug#25171)
* src/w32select.c: Don't include keyboard.h.
* test/src/thread-tests.el (thread-errors): New test.
---
src/keyboard.c | 7 -------
src/keyboard.h | 7 -------
src/thread.h | 9 +++++++++
src/w32select.c | 1 -
test/src/thread-tests.el | 15 +++++++++++++++
5 files changed, 24 insertions(+), 15 deletions(-)
diff --git a/src/keyboard.c b/src/keyboard.c
index 01b9b3c..cc78548 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -148,9 +148,6 @@ static Lisp_Object regular_top_level_message;
static sys_jmp_buf getcjmp;
-/* True while doing kbd input. */
-bool waiting_for_input;
-
/* True while displaying for echoing. Delays C-g throwing. */
static bool echoing;
@@ -322,10 +319,6 @@ static ptrdiff_t echo_length (void);
/* Incremented whenever a timer is run. */
unsigned timers_run;
-/* Address (if not 0) of struct timespec to zero out if a SIGIO interrupt
- happens. */
-struct timespec *input_available_clear_time;
-
/* True means use SIGIO interrupts; false means use CBREAK mode.
Default is true if INTERRUPT_INPUT is defined. */
bool interrupt_input;
diff --git a/src/keyboard.h b/src/keyboard.h
index a5ed5e1..5084c39 100644
--- a/src/keyboard.h
+++ b/src/keyboard.h
@@ -415,13 +415,6 @@ extern void unuse_menu_items (void);
#define EVENT_HEAD_KIND(event_head) \
(Fget ((event_head), Qevent_kind))
-/* True while doing kbd input. */
-extern bool waiting_for_input;
-
-/* Address (if not 0) of struct timespec to zero out if a SIGIO interrupt
- happens. */
-extern struct timespec *input_available_clear_time;
-
extern bool ignore_mouse_drag_p;
extern Lisp_Object parse_modifiers (Lisp_Object);
diff --git a/src/thread.h b/src/thread.h
index 6174032..f10824f 100644
--- a/src/thread.h
+++ b/src/thread.h
@@ -155,6 +155,15 @@ struct thread_state
int m_waiting_for_user_input_p;
#define waiting_for_user_input_p (current_thread->m_waiting_for_user_input_p)
+ /* True while doing kbd input. */
+ bool m_waiting_for_input;
+#define waiting_for_input (current_thread->m_waiting_for_input)
+
+ /* Address (if not 0) of struct timespec to zero out if a SIGIO interrupt
+ happens. */
+ struct timespec *m_input_available_clear_time;
+#define input_available_clear_time
(current_thread->m_input_available_clear_time)
+
/* The OS identifier for this thread. */
sys_thread_t thread_id;
diff --git a/src/w32select.c b/src/w32select.c
index 1754534..36908f9 100644
--- a/src/w32select.c
+++ b/src/w32select.c
@@ -77,7 +77,6 @@ along with GNU Emacs. If not, see
<http://www.gnu.org/licenses/>. */
#include "w32common.h" /* os_subtype */
#include "w32term.h" /* for all of the w32 includes */
#include "w32select.h"
-#include "keyboard.h" /* for waiting_for_input */
#include "blockinput.h"
#include "coding.h"
diff --git a/test/src/thread-tests.el b/test/src/thread-tests.el
index 4631882..4e7b052 100644
--- a/test/src/thread-tests.el
+++ b/test/src/thread-tests.el
@@ -209,5 +209,20 @@
(string= "hi bob"
(condition-name (make-condition-variable (make-mutex)
"hi bob")))))
+(defun call-error ()
+ "Call `error'."
+ (error "Error is called"))
+
+;; This signals an error internally; the error should be caught.
+(defun thread-custom ()
+ (defcustom thread-custom-face 'highlight
+ "Face used for thread customizations."
+ :type 'face
+ :group 'widget-faces))
+
+(ert-deftest thread-errors ()
+ "Test what happens when a thread signals an error."
+ (should (threadp (make-thread #'call-error "call-error")))
+ (should (threadp (make-thread #'thread-custom "thread-custom"))))
;;; threads.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 9970816: Avoid aborts when a thread signals an error,
Eli Zaretskii <=