Work on removing libevent completely as a mandatory dependency.
This commit is contained in:
@@ -557,6 +557,7 @@ struct hub_info* hub_start_service(struct hub_config* config)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef USE_LIBEVENT
|
||||
event_set(&hub->ev_accept, hub->fd_tcp, EV_READ | EV_PERSIST, net_on_accept, hub);
|
||||
if (event_add(&hub->ev_accept, NULL) == -1)
|
||||
{
|
||||
@@ -565,6 +566,7 @@ struct hub_info* hub_start_service(struct hub_config* config)
|
||||
net_close(server_tcp);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (event_queue_initialize(&hub->queue, hub_event_dispatcher, (void*) hub) == -1)
|
||||
{
|
||||
@@ -612,7 +614,9 @@ void hub_shutdown_service(struct hub_info* hub)
|
||||
LOG_DEBUG("hub_shutdown_service()");
|
||||
|
||||
event_queue_shutdown(hub->queue);
|
||||
#ifdef USE_LIBEVENT
|
||||
event_del(&hub->ev_accept);
|
||||
#endif
|
||||
net_close(hub->fd_tcp);
|
||||
uman_shutdown(hub);
|
||||
hub->status = hub_status_stopped;
|
||||
@@ -987,10 +991,10 @@ void hub_disconnect_all(struct hub_info* hub)
|
||||
|
||||
void hub_event_loop(struct hub_info* hub)
|
||||
{
|
||||
int ret;
|
||||
do
|
||||
{
|
||||
ret = event_base_loop(net_get_evbase(), EVLOOP_ONCE);
|
||||
#ifdef USE_LIBEVENT
|
||||
int ret = event_base_loop(net_get_evbase(), EVLOOP_ONCE);
|
||||
|
||||
if (ret != 0)
|
||||
{
|
||||
@@ -999,7 +1003,7 @@ void hub_event_loop(struct hub_info* hub)
|
||||
|
||||
if (ret < 0)
|
||||
break;
|
||||
|
||||
#endif
|
||||
event_queue_process(hub->queue);
|
||||
}
|
||||
while (hub->status == hub_status_running || hub->status == hub_status_disabled);
|
||||
|
||||
@@ -91,8 +91,10 @@ struct hub_logout_info
|
||||
struct hub_info
|
||||
{
|
||||
int fd_tcp;
|
||||
#ifdef USE_LIBEVENT
|
||||
struct event ev_accept;
|
||||
struct event ev_timer;
|
||||
#endif
|
||||
struct hub_stats stats;
|
||||
struct event_queue* queue;
|
||||
struct hub_config* config;
|
||||
|
||||
@@ -33,7 +33,7 @@ static const char* arg_pid = 0;
|
||||
static int arg_log_syslog = 0;
|
||||
|
||||
|
||||
#ifndef WIN32
|
||||
#if !defined(WIN32) && defined(USE_LIBEVENT)
|
||||
void hub_handle_signal(int fd, short events, void* arg)
|
||||
{
|
||||
struct hub_info* hub = (struct hub_info*) arg;
|
||||
@@ -97,7 +97,7 @@ void shutdown_signal_handlers(struct hub_info* hub)
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* WIN32 */
|
||||
#endif /* !WIN32 && USE_LIBEVENT*/
|
||||
|
||||
|
||||
int main_loop()
|
||||
@@ -133,7 +133,7 @@ int main_loop()
|
||||
hub = hub_start_service(&configuration);
|
||||
if (!hub)
|
||||
return -1;
|
||||
#ifndef WIN32
|
||||
#if !defined(WIN32) && defined(USE_LIBEVENT)
|
||||
setup_signal_handlers(hub);
|
||||
#endif
|
||||
}
|
||||
@@ -148,7 +148,7 @@ int main_loop()
|
||||
|
||||
} while (hub->status == hub_status_restart);
|
||||
|
||||
#ifndef WIN32
|
||||
#if !defined(WIN32) && defined(USE_LIBEVENT)
|
||||
shutdown_signal_handlers(hub);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@ void uman_print_stats(struct hub_info* hub)
|
||||
}
|
||||
|
||||
#ifdef USERMANAGER_TIMER
|
||||
#ifdef USE_LIBEVENT
|
||||
static void timer_statistics(int fd, short ev, void *arg)
|
||||
{
|
||||
struct hub_info* hub = (struct hub_info*) arg;
|
||||
@@ -80,13 +81,16 @@ static void timer_statistics(int fd, short ev, void *arg)
|
||||
evtimer_add(&hub->ev_timer, &timeout);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
int uman_init(struct hub_info* hub)
|
||||
{
|
||||
struct hub_user_manager* users = NULL;
|
||||
#ifdef USERMANAGER_TIMER
|
||||
#ifdef USE_LIBEVENT
|
||||
struct timeval timeout = { TIMEOUT_STATS, 0 };
|
||||
#endif
|
||||
#endif
|
||||
if (!hub)
|
||||
return -1;
|
||||
@@ -108,11 +112,13 @@ int uman_init(struct hub_info* hub)
|
||||
hub->users = users;
|
||||
|
||||
#ifdef USERMANAGER_TIMER
|
||||
#ifdef USE_LIBEVENT
|
||||
if (net_get_evbase())
|
||||
{
|
||||
evtimer_set(&hub->ev_timer, timer_statistics, hub);
|
||||
evtimer_add(&hub->ev_timer, &timeout);
|
||||
}
|
||||
#endif
|
||||
#endif // 0
|
||||
return 0;
|
||||
}
|
||||
@@ -124,8 +130,10 @@ int uman_shutdown(struct hub_info* hub)
|
||||
return -1;
|
||||
|
||||
#ifdef USERMANAGER_TIMER
|
||||
#ifdef USE_LIBEVENT
|
||||
if (evtimer_pending(&hub->ev_timer, 0))
|
||||
evtimer_del(&hub->ev_timer);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (hub->users->list)
|
||||
|
||||
Reference in New Issue
Block a user