libupdate

This commit is contained in:
Olaf Rempel 2009-05-03 14:07:22 +02:00
parent d3c241b7a3
commit 454894f55d
5 changed files with 7 additions and 11 deletions

View File

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

View File

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

View File

@ -113,7 +113,7 @@ int main(int argc, char *argv[])
} }
signal_init(); 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()); log_print(LOG_EVERYTIME, "sammler started (pid:%d)", getpid());

View File

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

View File

@ -5,7 +5,7 @@
#define SIG_IGNORE 0x01 #define SIG_IGNORE 0x01
int signal_remove_callback(int signum, int type); 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); int signal_init(void);