From 1599f63134d015abce758c8d0b290bcd08453b0d Mon Sep 17 00:00:00 2001 From: Jan Vidar Krey Date: Thu, 28 Jan 2010 00:07:42 +0100 Subject: [PATCH] Make sure the autotests work. --- autotest/test_inf.tcc | 1 + src/core/usermanager.c | 16 +++++++++++----- src/network/epoll.c | 4 ++++ src/network/kqueue.c | 4 ++++ src/network/select.c | 4 ++++ 5 files changed, 24 insertions(+), 5 deletions(-) diff --git a/autotest/test_inf.tcc b/autotest/test_inf.tcc index c5f7028..08c318c 100644 --- a/autotest/test_inf.tcc +++ b/autotest/test_inf.tcc @@ -50,6 +50,7 @@ static void inf_create_user() static void inf_destroy_user() { if (!inf_user) return; + hub_free(inf_user->connection); hub_free(inf_user); inf_user = 0; } diff --git a/src/core/usermanager.c b/src/core/usermanager.c index 4daf4ab..a1ee636 100644 --- a/src/core/usermanager.c +++ b/src/core/usermanager.c @@ -93,9 +93,12 @@ int uman_init(struct hub_info* hub) return -1; } - users->timeout = hub_malloc_zero(sizeof(struct timeout_evt)); - timeout_evt_initialize(users->timeout, timer_statistics, hub); - timeout_queue_insert(net_backend_get_timeout_queue(), users->timeout, TIMEOUT_STATS); + if (net_backend_get_timeout_queue()) + { + users->timeout = hub_malloc_zero(sizeof(struct timeout_evt)); + timeout_evt_initialize(users->timeout, timer_statistics, hub); + timeout_queue_insert(net_backend_get_timeout_queue(), users->timeout, TIMEOUT_STATS); + } hub->users = users; return 0; @@ -107,8 +110,11 @@ int uman_shutdown(struct hub_info* hub) if (!hub || !hub->users) return -1; - timeout_queue_remove(net_backend_get_timeout_queue(), hub->users->timeout); - hub_free(hub->users->timeout); + if (net_backend_get_timeout_queue()) + { + timeout_queue_remove(net_backend_get_timeout_queue(), hub->users->timeout); + hub_free(hub->users->timeout); + } if (hub->users->list) { diff --git a/src/network/epoll.c b/src/network/epoll.c index cfaf5e1..e5bc1f2 100644 --- a/src/network/epoll.c +++ b/src/network/epoll.c @@ -99,6 +99,7 @@ void net_backend_shutdown() net_cleanup_shutdown(g_backend->cleaner); hub_free(g_backend->conns); hub_free(g_backend); + g_backend = 0; } /** @@ -135,6 +136,9 @@ int net_backend_process() struct timeout_queue* net_backend_get_timeout_queue() { + if (!g_backend) + return 0; + return &g_backend->timeout_queue; } diff --git a/src/network/kqueue.c b/src/network/kqueue.c index 86042e7..460858f 100644 --- a/src/network/kqueue.c +++ b/src/network/kqueue.c @@ -86,6 +86,7 @@ void net_backend_shutdown() hub_free(g_backend->conns); hub_free(g_backend->changes); hub_free(g_backend); + g_backend = 0; } /** @@ -124,6 +125,9 @@ int net_backend_process() struct timeout_queue* net_backend_get_timeout_queue() { + if (!g_backend) + return 0; + return &g_backend->timeout_queue; } diff --git a/src/network/select.c b/src/network/select.c index 0e32653..001eafc 100644 --- a/src/network/select.c +++ b/src/network/select.c @@ -88,6 +88,7 @@ void net_backend_shutdown() net_cleanup_shutdown(g_backend->cleaner); hub_free(g_backend->conns); hub_free(g_backend); + g_backend = 0; } /** @@ -149,6 +150,9 @@ int net_backend_process() struct timeout_queue* net_backend_get_timeout_queue() { + if (!g_backend) + return 0; + return &g_backend->timeout_queue; }