summary refs log tree commit diff
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2016-10-03 09:37:10 -0700
committerBarton E. Schaefer <schaefer@zsh.org>2016-10-03 09:37:10 -0700
commit4abbb4b4739598c50973593d2787696116e49fcf (patch)
treedbe9dbcc2e6b9938c832e933a6a3ef80a21cdbc6
parentb71abea40f491726f96ea26143306ec27aa611ee (diff)
downloadzsh-4abbb4b4739598c50973593d2787696116e49fcf.tar.gz
zsh-4abbb4b4739598c50973593d2787696116e49fcf.tar.xz
zsh-4abbb4b4739598c50973593d2787696116e49fcf.zip
39548: DEBUG for queueing_enabled
-rw-r--r--ChangeLog2
-rw-r--r--Src/signals.c4
-rw-r--r--Src/signals.h31
3 files changed, 34 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 81d31c969..a7dfa2e3c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2016-10-03  Barton E. Schaefer  <schaefer@zsh.org>
 
+	* 39548: Src/signals.c, Src/signals.h: DEBUG for queueing_enabled
+
 	* 39547: Src/Zle/zle_main.c: handle zero delta in calc_timeout()
 
 2016-10-03  Peter Stephenson  <p.stephenson@samsung.com>
diff --git a/Src/signals.c b/Src/signals.c
index e2587dc72..9e05add09 100644
--- a/Src/signals.c
+++ b/Src/signals.c
@@ -72,6 +72,10 @@ mod_export int queueing_enabled, queue_front, queue_rear;
 mod_export int signal_queue[MAX_QUEUE_SIZE];
 /**/
 mod_export sigset_t signal_mask_queue[MAX_QUEUE_SIZE];
+#ifdef DEBUG
+/**/
+mod_export int queue_in;
+#endif
 
 /* Variables used by trap queueing */
 
diff --git a/Src/signals.h b/Src/signals.h
index d68096891..1904f4326 100644
--- a/Src/signals.h
+++ b/Src/signals.h
@@ -82,8 +82,6 @@
 
 #define MAX_QUEUE_SIZE 128
 
-#define queue_signals()    (queueing_enabled++)
-
 #define run_queued_signals() do { \
     while (queue_front != queue_rear) {      /* while signals in queue */ \
 	sigset_t oset; \
@@ -94,12 +92,35 @@
     } \
 } while (0)
 
+#ifdef DEBUG
+
+#define queue_signals()    (queue_in++, queueing_enabled++)
+
 #define unqueue_signals()  do { \
     DPUTS(!queueing_enabled, "BUG: unqueue_signals called but not queueing"); \
+    --queue_in; \
     if (!--queueing_enabled) run_queued_signals(); \
 } while (0)
 
-#define queue_signal_level() queueing_enabled
+#define dont_queue_signals() do { \
+    queue_in = queueing_enabled; \
+    queueing_enabled = 0; \
+    run_queued_signals(); \
+} while (0)
+
+#define restore_queue_signals(q) do { \
+    DPUTS2(queueing_enabled && queue_in != q, \
+         "BUG: q = %d != queue_in = %d", q, queue_in); \
+    queue_in = (queueing_enabled = (q)); \
+} while (0)
+
+#else /* !DEBUG */
+
+#define queue_signals()    (queueing_enabled++)
+
+#define unqueue_signals()  do { \
+    if (!--queueing_enabled) run_queued_signals(); \
+} while (0)
 
 #define dont_queue_signals() do { \
     queueing_enabled = 0; \
@@ -108,6 +129,10 @@
 
 #define restore_queue_signals(q) (queueing_enabled = (q))
 
+#endif /* DEBUG */
+
+#define queue_signal_level() queueing_enabled
+
 #ifdef BSD_SIGNALS
 #define signal_block(S) sigblock(S)
 #else