Browse Source

libupdate

master
Olaf Rempel 13 years ago
parent
commit
454894f55d
  1. 2
      event.c
  2. 2
      event.h
  3. 2
      sammler.c
  4. 10
      signals.c
  5. 2
      signals.h

2
event.c

@ -199,7 +199,7 @@ void event_remove_timeout(struct event_timeout *entry)
entry->flags |= EVENT_DELETE;
}
void event_loop_break(void *dummy)
void event_loop_break(void)
{
leave_loop = 1;
}

2
event.h

@ -37,7 +37,7 @@ struct event_timeout * event_add_timeout(
void event_remove_timeout(struct event_timeout *entry);
void event_loop_break(void *dummy);
void event_loop_break(void);
int event_loop(void);
#endif /* _EVENT_H_ */

2
sammler.c

@ -113,7 +113,7 @@ int main(int argc, char *argv[])
}
signal_init();
signal_set_callback(SIGUSR1, event_loop_break, NULL);
signal_set_callback(SIGHUP, event_loop_break);
log_print(LOG_EVERYTIME, "sammler started (pid:%d)", getpid());

10
signals.c

@ -32,8 +32,7 @@ struct signal_entry {
int signum;
int deleted;
void (*callback)(void *privdata);
void *privdata;
void (*callback)(void);
};
static LIST_HEAD(callback_list);
@ -77,10 +76,8 @@ int signal_remove_callback(int signum, int type)
return 0;
}
int signal_set_callback(int signum, void (*callback)(void *privdata), void *privdata)
int signal_set_callback(int signum, void (*callback)(void))
{
signal_remove_callback(signum, SIG_DEFAULT);
struct signal_entry *entry = malloc(sizeof(struct signal_entry));
if (entry == NULL) {
log_print(LOG_WARN, "signal_add_callback(): out of memory");
@ -90,7 +87,6 @@ int signal_set_callback(int signum, void (*callback)(void *privdata), void *priv
entry->signum = signum;
entry->deleted = 0;
entry->callback = callback;
entry->privdata = privdata;
list_add_tail(&entry->list, &callback_list);
struct sigaction sig_action = {
@ -125,7 +121,7 @@ static int sig_event(int fd, void *privdata)
}
if (search->signum == signum)
search->callback(search->privdata);
search->callback();
}
return 0;

2
signals.h

@ -5,7 +5,7 @@
#define SIG_IGNORE 0x01
int signal_remove_callback(int signum, int type);
int signal_set_callback(int signum, void (*callback)(void *privdata), void *privdata);
int signal_set_callback(int signum, void (*callback)(void));
int signal_init(void);

Loading…
Cancel
Save