From e11cc390f844754fc7e410c0a2fa5283d286a097 Mon Sep 17 00:00:00 2001 From: Philipp Schafft Date: Sat, 26 Feb 2022 13:55:21 +0000 Subject: [PATCH] Feature: Create global libigloo instance --- src/global.c | 1 + src/global.h | 3 +++ src/main.c | 14 ++++++++++++++ 3 files changed, 18 insertions(+) diff --git a/src/global.c b/src/global.c index 80721ceb..87f781d4 100644 --- a/src/global.c +++ b/src/global.c @@ -27,6 +27,7 @@ #include "source.h" ice_global_t global; +igloo_ro_t igloo_instance = igloo_RO_NULL; static mutex_t _global_mutex; diff --git a/src/global.h b/src/global.h index e2f789e4..2788e73c 100644 --- a/src/global.h +++ b/src/global.h @@ -21,6 +21,8 @@ #define ICECAST_VERSION_STRING "Icecast " PACKAGE_VERSION +#include + #include "common/thread/thread.h" #include "common/avl/avl.h" #include "icecasttypes.h" @@ -46,6 +48,7 @@ typedef struct ice_global_tag } ice_global_t; extern ice_global_t global; +extern igloo_ro_t igloo_instance; void global_initialize(void); void global_shutdown(void); diff --git a/src/main.c b/src/main.c index dc66a15f..95c48294 100644 --- a/src/main.c +++ b/src/main.c @@ -45,6 +45,8 @@ #include #endif +#include + #include "common/thread/thread.h" #include "common/net/sock.h" #include "common/net/resolver.h" @@ -587,6 +589,11 @@ int main(int argc, char **argv) char pbuf[1024]; ice_config_t *config; + if (igloo_initialize(&igloo_instance) != igloo_ERROR_NONE) { + _fatal_error("FATAL: Can not initialize libigloo."); + return 1; + } + /* parse the '-c icecast.xml' option ** only, so that we can read a configfile */ @@ -597,6 +604,7 @@ int main(int argc, char **argv) if (!_start_logging_stdout()) { _fatal_error("FATAL: Could not start logging on stderr."); shutdown_subsystems(); + igloo_ro_unref(&igloo_instance); return 1; } #endif @@ -626,10 +634,12 @@ int main(int argc, char **argv) #if !defined(_WIN32) || defined(_CONSOLE) || defined(__MINGW32__) || defined(__MINGW64__) shutdown_subsystems(); #endif + igloo_ro_unref(&igloo_instance); return 1; } } else { _print_usage(); + igloo_ro_unref(&igloo_instance); return 1; } @@ -640,6 +650,7 @@ int main(int argc, char **argv) if(!_server_proc_init()) { _fatal_error("Server startup failed. Exiting"); shutdown_subsystems(); + igloo_ro_unref(&igloo_instance); return 1; } @@ -650,6 +661,7 @@ int main(int argc, char **argv) if (!_start_logging()) { _fatal_error("FATAL: Could not start logging"); shutdown_subsystems(); + igloo_ro_unref(&igloo_instance); return 1; } @@ -668,6 +680,7 @@ int main(int argc, char **argv) fprintf(stderr, "ERROR: You should not run icecast2 as root\n"); fprintf(stderr, "Use the changeowner directive in the config file\n"); shutdown_subsystems(); + igloo_ro_unref(&igloo_instance); return 1; } #endif @@ -706,6 +719,7 @@ int main(int argc, char **argv) free (pidfile); } + igloo_ro_unref(&igloo_instance); return 0; }