aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorEric S. Raymond1993-04-27 21:59:39 +0000
committerEric S. Raymond1993-04-27 21:59:39 +0000
commitee6b9d192816805d5825326f89c0a45d14d3e182 (patch)
tree78c7c82baa7a59fec797ed5ff1cef44d3e874f95 /lib-src
parentf1cc678fdca621df8eb39f65054195388a0bca94 (diff)
downloademacs-ee6b9d192816805d5825326f89c0a45d14d3e182.tar.gz
emacs-ee6b9d192816805d5825326f89c0a45d14d3e182.zip
(notify): Bug fix. Treat the body of this function as a critical region.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/timer.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/lib-src/timer.c b/lib-src/timer.c
index 84c384c9f22..4111b2bfb82 100644
--- a/lib-src/timer.c
+++ b/lib-src/timer.c
@@ -9,7 +9,7 @@
9 9
10 This program is intended to be used with the lisp package called 10 This program is intended to be used with the lisp package called
11 timer.el. It was written anonymously in 1990. This version was 11 timer.el. It was written anonymously in 1990. This version was
12 documented and rewritten for portability by esr@snark,thyrsus.com, 12 documented and rewritten for portability by esr@snark.thyrsus.com,
13 Aug 7 1992. */ 13 Aug 7 1992. */
14 14
15#include <stdio.h> 15#include <stdio.h>
@@ -124,6 +124,13 @@ notify ()
124 time_t now, tdiff, waitfor = -1; 124 time_t now, tdiff, waitfor = -1;
125 register struct event *ep; 125 register struct event *ep;
126 126
127 /* If an alarm timer runs out while this function is executing,
128 it could get called recursively. This would be bad, because
129 it's not re-entrant. So we must try to suspend the signal. */
130#ifdef sigmask
131 sighold(SIGIO);
132#endif
133
127 now = time ((time_t *) NULL); 134 now = time ((time_t *) NULL);
128 135
129 for (ep = events; ep < events + num_events; ep++) 136 for (ep = events; ep < events + num_events; ep++)
@@ -137,8 +144,8 @@ notify ()
137 144
138 /* We now have a hole in the event array; fill it with the last 145 /* We now have a hole in the event array; fill it with the last
139 event. */ 146 event. */
140 ep->token = events[num_events].token; 147 ep->token = events[num_events - 1].token;
141 ep->reply_at = events[num_events].reply_at; 148 ep->reply_at = events[num_events - 1].reply_at;
142 num_events--; 149 num_events--;
143 150
144 /* We ought to scan this event again. */ 151 /* We ought to scan this event again. */
@@ -154,6 +161,10 @@ notify ()
154 /* If there are no more events, we needn't bother setting an alarm. */ 161 /* If there are no more events, we needn't bother setting an alarm. */
155 if (num_events > 0) 162 if (num_events > 0)
156 alarm (waitfor); 163 alarm (waitfor);
164
165#ifdef sigmask
166 sigrelse(SIGIO);
167#endif
157} 168}
158 169
159void 170void
@@ -276,7 +287,8 @@ main (argc, argv)
276 } 287 }
277#endif /* USG */ 288#endif /* USG */
278 289
279 while (1) pause (); 290 for (;;)
291 pause ();
280} 292}
281 293
282/* timer.c ends here */ 294/* timer.c ends here */