Manage explicit event bases

This commit is contained in:
Julien BLACHE 2009-04-07 17:37:12 +02:00
parent 02f960b25b
commit 8a351e5bf8
2 changed files with 8 additions and 2 deletions

View File

@ -79,4 +79,7 @@ typedef struct tag_config {
extern CONFIG config; extern CONFIG config;
/* Event bases */
extern struct event_base *evbase_main;
#endif /* _DAAPD_H_ */ #endif /* _DAAPD_H_ */

View File

@ -111,6 +111,8 @@
*/ */
CONFIG config; /**< Main configuration structure, as read from configfile */ CONFIG config; /**< Main configuration structure, as read from configfile */
struct event_base *evbase_main;
/* /*
* Forwards * Forwards
*/ */
@ -550,7 +552,7 @@ int main(int argc, char *argv[]) {
} }
/* Initialize libevent (after forking) */ /* Initialize libevent (after forking) */
event_init(); evbase_main = event_init();
main_timer = (struct event *)malloc(sizeof(struct event)); main_timer = (struct event *)malloc(sizeof(struct event));
if (!main_timer) if (!main_timer)
{ {
@ -698,12 +700,13 @@ int main(int argc, char *argv[]) {
/* Set up main timer */ /* Set up main timer */
evtimer_set(main_timer, mainloop_cb, main_timer); evtimer_set(main_timer, mainloop_cb, main_timer);
event_base_set(evbase_main, main_timer);
evutil_timerclear(&tv); evutil_timerclear(&tv);
tv.tv_sec = MAIN_SLEEP_INTERVAL; tv.tv_sec = MAIN_SLEEP_INTERVAL;
evtimer_add(main_timer, &tv); evtimer_add(main_timer, &tv);
/* Run the loop */ /* Run the loop */
event_dispatch(); event_base_dispatch(evbase_main);
DPRINTF(E_LOG,L_MAIN,"Stopping gracefully\n"); DPRINTF(E_LOG,L_MAIN,"Stopping gracefully\n");