global.c 1.36 KB
Newer Older
1 2 3 4 5
/* Icecast
 *
 * This program is distributed under the GNU General Public License, version 2.
 * A copy of this license is included with this source.
 *
6
 * Copyright 2000-2004, Jack Moffitt <jack@xiph.org,
7 8 9 10 11 12
 *                      Michael Smith <msmith@xiph.org>,
 *                      oddsock <oddsock@xiph.org>,
 *                      Karl Heyes <karl@xiph.org>
 *                      and others (see AUTHORS for details).
 */

13
/* -*- c-basic-offset: 4; indent-tabs-mode: nil; -*- */
14 15 16 17
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

18 19
#include <string.h>

Marvin Scholz's avatar
Marvin Scholz committed
20 21 22
#include "common/thread/thread.h"
#include "common/avl/avl.h"
#include "common/httpp/httpp.h"
Jack Moffitt's avatar
Jack Moffitt committed
23 24 25

#include "connection.h"
#include "refbuf.h"
26
#include "client.h"
Jack Moffitt's avatar
Jack Moffitt committed
27
#include "source.h"
28
#include "format.h"
Jack Moffitt's avatar
Jack Moffitt committed
29 30 31 32 33 34 35 36 37

#include "global.h"

ice_global_t global;

static mutex_t _global_mutex;

void global_initialize(void)
{
38
    global.server_sockets = 0;
39 40
    global.relays = NULL;
    global.master_relays = NULL;
41 42 43 44 45
    global.running = 0;
    global.clients = 0;
    global.sources = 0;
    global.source_tree = avl_tree_new(source_compare_sources, NULL);
    thread_mutex_create(&_global_mutex);
Jack Moffitt's avatar
Jack Moffitt committed
46 47 48 49
}

void global_shutdown(void)
{
50
    thread_mutex_destroy(&_global_mutex);
51
    avl_tree_free(global.source_tree, NULL);
Jack Moffitt's avatar
Jack Moffitt committed
52 53 54 55
}

void global_lock(void)
{
56
    thread_mutex_lock(&_global_mutex);
Jack Moffitt's avatar
Jack Moffitt committed
57 58 59 60
}

void global_unlock(void)
{
61
    thread_mutex_unlock(&_global_mutex);
Jack Moffitt's avatar
Jack Moffitt committed
62
}