global.c 740 Bytes
Newer Older
Jack Moffitt's avatar
Jack Moffitt committed
1 2 3 4 5 6
#include "thread.h"
#include "avl.h"

#include "httpp.h"
#include "connection.h"
#include "refbuf.h"
7
#include "client.h"
8
#include "geturl.h"
Jack Moffitt's avatar
Jack Moffitt committed
9
#include "source.h"
10
#include "format.h"
Jack Moffitt's avatar
Jack Moffitt committed
11 12 13 14 15 16 17 18 19

#include "global.h"

ice_global_t global;

static mutex_t _global_mutex;

void global_initialize(void)
{
20
	global.serversock = -1;
Jack Moffitt's avatar
Jack Moffitt committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
	global.running = 0;
	global.clients = 0;
	global.sources = 0;
	global.source_tree = avl_tree_new(source_compare_sources, NULL);
	thread_mutex_create(&_global_mutex);
}

void global_shutdown(void)
{
	thread_mutex_destroy(&_global_mutex);
	avl_tree_free(global.source_tree, source_free_source);
}

void global_lock(void)
{
	thread_mutex_lock(&_global_mutex);
}

void global_unlock(void)
{
	thread_mutex_unlock(&_global_mutex);
}