1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-12-04 14:46:30 -05:00

Feature: Create global libigloo instance

This commit is contained in:
Philipp Schafft 2022-02-26 13:55:21 +00:00
parent 6a4118883e
commit e11cc390f8
3 changed files with 18 additions and 0 deletions

View File

@ -27,6 +27,7 @@
#include "source.h" #include "source.h"
ice_global_t global; ice_global_t global;
igloo_ro_t igloo_instance = igloo_RO_NULL;
static mutex_t _global_mutex; static mutex_t _global_mutex;

View File

@ -21,6 +21,8 @@
#define ICECAST_VERSION_STRING "Icecast " PACKAGE_VERSION #define ICECAST_VERSION_STRING "Icecast " PACKAGE_VERSION
#include <igloo/igloo.h>
#include "common/thread/thread.h" #include "common/thread/thread.h"
#include "common/avl/avl.h" #include "common/avl/avl.h"
#include "icecasttypes.h" #include "icecasttypes.h"
@ -46,6 +48,7 @@ typedef struct ice_global_tag
} ice_global_t; } ice_global_t;
extern ice_global_t global; extern ice_global_t global;
extern igloo_ro_t igloo_instance;
void global_initialize(void); void global_initialize(void);
void global_shutdown(void); void global_shutdown(void);

View File

@ -45,6 +45,8 @@
#include <sys/utsname.h> #include <sys/utsname.h>
#endif #endif
#include <igloo/error.h>
#include "common/thread/thread.h" #include "common/thread/thread.h"
#include "common/net/sock.h" #include "common/net/sock.h"
#include "common/net/resolver.h" #include "common/net/resolver.h"
@ -587,6 +589,11 @@ int main(int argc, char **argv)
char pbuf[1024]; char pbuf[1024];
ice_config_t *config; 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 /* parse the '-c icecast.xml' option
** only, so that we can read a configfile ** only, so that we can read a configfile
*/ */
@ -597,6 +604,7 @@ int main(int argc, char **argv)
if (!_start_logging_stdout()) { if (!_start_logging_stdout()) {
_fatal_error("FATAL: Could not start logging on stderr."); _fatal_error("FATAL: Could not start logging on stderr.");
shutdown_subsystems(); shutdown_subsystems();
igloo_ro_unref(&igloo_instance);
return 1; return 1;
} }
#endif #endif
@ -626,10 +634,12 @@ int main(int argc, char **argv)
#if !defined(_WIN32) || defined(_CONSOLE) || defined(__MINGW32__) || defined(__MINGW64__) #if !defined(_WIN32) || defined(_CONSOLE) || defined(__MINGW32__) || defined(__MINGW64__)
shutdown_subsystems(); shutdown_subsystems();
#endif #endif
igloo_ro_unref(&igloo_instance);
return 1; return 1;
} }
} else { } else {
_print_usage(); _print_usage();
igloo_ro_unref(&igloo_instance);
return 1; return 1;
} }
@ -640,6 +650,7 @@ int main(int argc, char **argv)
if(!_server_proc_init()) { if(!_server_proc_init()) {
_fatal_error("Server startup failed. Exiting"); _fatal_error("Server startup failed. Exiting");
shutdown_subsystems(); shutdown_subsystems();
igloo_ro_unref(&igloo_instance);
return 1; return 1;
} }
@ -650,6 +661,7 @@ int main(int argc, char **argv)
if (!_start_logging()) { if (!_start_logging()) {
_fatal_error("FATAL: Could not start logging"); _fatal_error("FATAL: Could not start logging");
shutdown_subsystems(); shutdown_subsystems();
igloo_ro_unref(&igloo_instance);
return 1; 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, "ERROR: You should not run icecast2 as root\n");
fprintf(stderr, "Use the changeowner directive in the config file\n"); fprintf(stderr, "Use the changeowner directive in the config file\n");
shutdown_subsystems(); shutdown_subsystems();
igloo_ro_unref(&igloo_instance);
return 1; return 1;
} }
#endif #endif
@ -706,6 +719,7 @@ int main(int argc, char **argv)
free (pidfile); free (pidfile);
} }
igloo_ro_unref(&igloo_instance);
return 0; return 0;
} }