Merge branch 'master' of github.com:janvidar/uhub
This commit is contained in:
commit
418db22931
|
@ -732,7 +732,8 @@ int main(int argc, char** argv)
|
|||
exotic_add_test(&handle, &exotic_test_rbtree_size_4, "rbtree_size_4");
|
||||
exotic_add_test(&handle, &exotic_test_rbtree_check_10000, "rbtree_check_10000");
|
||||
exotic_add_test(&handle, &exotic_test_rbtree_iterate_10000, "rbtree_iterate_10000");
|
||||
exotic_add_test(&handle, &exotic_test_rbtree_remove_5000, "rbtree_remove_5000");
|
||||
exotic_add_test(&handle, &exotic_test_rbtree_remove_10000, "rbtree_remove_10000");
|
||||
exotic_add_test(&handle, &exotic_test_rbtree_destroy_1, "rbtree_destroy_1");
|
||||
exotic_add_test(&handle, &exotic_test_sid_create_pool, "sid_create_pool");
|
||||
exotic_add_test(&handle, &exotic_test_sid_check_0a, "sid_check_0a");
|
||||
exotic_add_test(&handle, &exotic_test_sid_check_0b, "sid_check_0b");
|
||||
|
@ -770,6 +771,7 @@ int main(int argc, char** argv)
|
|||
exotic_add_test(&handle, &exotic_test_timer_add_5_events_1, "timer_add_5_events_1");
|
||||
exotic_add_test(&handle, &exotic_test_timer_check_5_events_1, "timer_check_5_events_1");
|
||||
exotic_add_test(&handle, &exotic_test_timer_process_5_events_1, "timer_process_5_events_1");
|
||||
exotic_add_test(&handle, &exotic_test_timer_shutdown, "timer_shutdown");
|
||||
exotic_add_test(&handle, &exotic_test_tokenizer_basic_0, "tokenizer_basic_0");
|
||||
exotic_add_test(&handle, &exotic_test_tokenizer_basic_1, "tokenizer_basic_1");
|
||||
exotic_add_test(&handle, &exotic_test_tokenizer_basic_1a, "tokenizer_basic_1a");
|
||||
|
|
|
@ -86,7 +86,7 @@ EXO_TEST(rbtree_size_3, { return rb_tree_size(tree) == 0; });
|
|||
|
||||
EXO_TEST(rbtree_insert_10000, {
|
||||
int i;
|
||||
for (i = 0; i < MAX_NODES ; i++)
|
||||
for (i = 0; i < MAX_NODES; i++)
|
||||
{
|
||||
const char* key = strdup(uhub_itoa(i));
|
||||
const char* val = strdup(uhub_itoa(i + 16384));
|
||||
|
@ -96,11 +96,11 @@ EXO_TEST(rbtree_insert_10000, {
|
|||
return 1;
|
||||
});
|
||||
|
||||
EXO_TEST(rbtree_size_4, { return rb_tree_size(tree) == MAX_NODES ; });
|
||||
EXO_TEST(rbtree_size_4, { return rb_tree_size(tree) == MAX_NODES; });
|
||||
|
||||
EXO_TEST(rbtree_check_10000, {
|
||||
int i;
|
||||
for (i = 0; i < MAX_NODES ; i++)
|
||||
for (i = 0; i < MAX_NODES; i++)
|
||||
{
|
||||
char* key = strdup(uhub_itoa(i));
|
||||
const char* expect = uhub_itoa(i + 16384);
|
||||
|
@ -116,29 +116,35 @@ EXO_TEST(rbtree_iterate_10000, {
|
|||
struct rb_node* n = (struct rb_node*) rb_tree_first(tree);
|
||||
while (n)
|
||||
{
|
||||
struct rb_node* p = n;
|
||||
n = (struct rb_node*) rb_tree_next(tree);
|
||||
i++;
|
||||
}
|
||||
return i == MAX_NODES ;
|
||||
return i == MAX_NODES;
|
||||
});
|
||||
|
||||
|
||||
static int freed_nodes = 0;
|
||||
static void free_node(struct rb_node* n)
|
||||
{
|
||||
hub_free((void*) n->key);
|
||||
hub_free((void*) n->value);
|
||||
freed_nodes += 1;
|
||||
}
|
||||
|
||||
EXO_TEST(rbtree_remove_5000, {
|
||||
int i = 0;
|
||||
struct rb_node* n = (struct rb_node*) rb_tree_first(tree);
|
||||
for (i = 0; i < MAX_NODES ; i += 2)
|
||||
EXO_TEST(rbtree_remove_10000, {
|
||||
int i;
|
||||
int j;
|
||||
for (j = 0; j < 2; j++)
|
||||
{
|
||||
for (i = j; i < MAX_NODES; i += 2)
|
||||
{
|
||||
const char* key = uhub_itoa(i);
|
||||
rb_tree_remove_node(tree, key, &free_node);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return freed_nodes == MAX_NODES;
|
||||
});
|
||||
|
||||
|
||||
EXO_TEST(rbtree_destroy_1, {
|
||||
rb_tree_destroy(tree);
|
||||
return 1;
|
||||
});
|
||||
|
|
|
@ -117,3 +117,9 @@ EXO_TEST(timer_process_5_events_1,{
|
|||
g_now = 4;
|
||||
return timeout_queue_process(g_queue, g_now) == g_triggered;
|
||||
});
|
||||
|
||||
EXO_TEST(timer_shutdown,{
|
||||
timeout_queue_shutdown(g_queue);
|
||||
hub_free(g_queue);
|
||||
return 1;
|
||||
});
|
||||
|
|
|
@ -283,7 +283,6 @@ static int net_connect_job_process(struct net_connect_job* job)
|
|||
*/
|
||||
static void net_connect_job_internal_cb(struct net_connection* con, int event, void* ptr)
|
||||
{
|
||||
int ret;
|
||||
struct net_connect_job* job = net_con_get_ptr(con);
|
||||
struct net_connect_job* next_job = job->next;
|
||||
struct net_connect_handle* handle = job->handle;
|
||||
|
@ -441,7 +440,6 @@ static int net_con_connect_dns_callback(struct net_dns_job* job, const struct ne
|
|||
struct net_connect_handle* handle = (struct net_connect_handle*) net_dns_job_get_ptr(job);
|
||||
handle->dns = NULL;
|
||||
size_t usable = 0;
|
||||
int ret;
|
||||
|
||||
LOG_TRACE("net_con_connect(): async - Got DNS results");
|
||||
if (!result)
|
||||
|
|
|
@ -99,9 +99,6 @@ void net_dns_initialize()
|
|||
|
||||
void net_dns_destroy()
|
||||
{
|
||||
struct net_dns_job* job;
|
||||
struct net_dns_result* result;
|
||||
|
||||
uhub_mutex_lock(&g_dns->mutex);
|
||||
LOG_TRACE("net_dns_destroy(): jobs=%d", (int) list_size(g_dns->jobs));
|
||||
list_clear(g_dns->jobs, &shutdown_free_jobs);
|
||||
|
|
|
@ -62,8 +62,8 @@ struct rb_tree
|
|||
extern struct rb_tree* rb_tree_create(rb_tree_compare compare, rb_tree_alloc alloc, rb_tree_free dealloc);
|
||||
|
||||
/**
|
||||
* Deletes the tree and all the nodes.
|
||||
* But not the content inside the nodes.
|
||||
* Delete the tree.
|
||||
* Assumes that the tree is empty.
|
||||
*/
|
||||
extern void rb_tree_destroy(struct rb_tree*);
|
||||
|
||||
|
|
Loading…
Reference in New Issue