libupdate
This commit is contained in:
parent
d3c241b7a3
commit
454894f55d
2
event.c
2
event.c
@ -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;
|
||||||
}
|
}
|
||||||
|
2
event.h
2
event.h
@ -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_ */
|
||||||
|
@ -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());
|
||||||
|
|
||||||
|
10
signals.c
10
signals.c
@ -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;
|
||||||
|
@ -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);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user