[PATCH 2/2] lib/tevent: use NSIG
Rusty Russell
rusty at rustcorp.com.au
Fri Aug 28 01:52:15 MDT 2009
This not only replaces NUM_SIGNALS+1 by NSIG, but fixes an out-by-one error where signal 64 could not be added.
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
---
lib/tevent/tevent_signal.c | 16 +++++++---------
1 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/lib/tevent/tevent_signal.c b/lib/tevent/tevent_signal.c
index 0333325..335153a 100644
--- a/lib/tevent/tevent_signal.c
+++ b/lib/tevent/tevent_signal.c
@@ -30,8 +30,6 @@
#include "tevent_internal.h"
#include "tevent_util.h"
-#define NUM_SIGNALS 64
-
/* maximum number of SA_SIGINFO signals to hold in the queue */
#define SA_INFO_QUEUE_COUNT 100
@@ -53,14 +51,14 @@ struct tevent_common_signal_list {
the poor design of signals means that this table must be static global
*/
static struct sig_state {
- struct tevent_common_signal_list *sig_handlers[NUM_SIGNALS+1];
- struct sigaction *oldact[NUM_SIGNALS+1];
- struct sigcounter signal_count[NUM_SIGNALS+1];
+ struct tevent_common_signal_list *sig_handlers[NSIG];
+ struct sigaction *oldact[NSIG];
+ struct sigcounter signal_count[NSIG];
struct sigcounter got_signal;
#ifdef SA_SIGINFO
/* with SA_SIGINFO we get quite a lot of info per signal */
- siginfo_t *sig_info[NUM_SIGNALS+1];
- struct sigcounter sig_blocked[NUM_SIGNALS+1];
+ siginfo_t *sig_info[NSIG];
+ struct sigcounter sig_blocked[NSIG];
#endif
} *sig_state;
@@ -189,7 +187,7 @@ struct tevent_signal *tevent_common_add_signal(struct tevent_context *ev,
struct tevent_common_signal_list *sl;
sigset_t set, oldset;
- if (signum >= NUM_SIGNALS) {
+ if (signum >= NSIG) {
errno = EINVAL;
return NULL;
}
@@ -307,7 +305,7 @@ int tevent_common_check_signal(struct tevent_context *ev)
return 0;
}
- for (i=0;i<NUM_SIGNALS+1;i++) {
+ for (i=0;i<NSIG;i++) {
struct tevent_common_signal_list *sl, *next;
struct sigcounter counter = sig_state->signal_count[i];
uint32_t count = sig_count(counter);
--
1.6.0.4
More information about the samba-technical
mailing list