mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2025-06-30 22:18:19 -04:00
Feature: Added most basic ping infrastructure
This commit is contained in:
parent
53055aafd7
commit
91ea5d0f79
@ -82,6 +82,7 @@
|
||||
#include "yp.h"
|
||||
#include "auth.h"
|
||||
#include "event.h"
|
||||
#include "ping.h"
|
||||
#include "listensocket.h"
|
||||
#include "fastevent.h"
|
||||
#include "prng.h"
|
||||
@ -169,6 +170,7 @@ static void initialize_subsystems(void)
|
||||
xslt_initialize();
|
||||
#ifdef HAVE_CURL
|
||||
icecast_curl_initialize();
|
||||
ping_initialize();
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -182,6 +184,9 @@ static void shutdown_subsystems(void)
|
||||
auth_shutdown();
|
||||
yp_shutdown();
|
||||
stats_shutdown();
|
||||
#ifdef HAVE_CURL
|
||||
ping_shutdown();
|
||||
#endif
|
||||
|
||||
ICECAST_LOG_DEBUG("Shuting down connection related subsystems...");
|
||||
connection_shutdown();
|
||||
|
47
src/ping.c
47
src/ping.c
@ -11,4 +11,51 @@
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "thread/thread.h"
|
||||
|
||||
#include "ping.h"
|
||||
#include "logging.h"
|
||||
#include "curl.h"
|
||||
|
||||
#define CATMODULE "ping"
|
||||
|
||||
static bool ping_running = false;
|
||||
static thread_type *_ping_thread_id;
|
||||
static mutex_t _ping_mutex;
|
||||
|
||||
static void *_ping_thread(void *arg)
|
||||
{
|
||||
CURLM *curl_multi = curl_multi_init();
|
||||
|
||||
while (ping_running) {
|
||||
break;
|
||||
}
|
||||
|
||||
curl_multi_cleanup(curl_multi);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void ping_initialize(void)
|
||||
{
|
||||
if (ping_running)
|
||||
return;
|
||||
|
||||
thread_mutex_create(&_ping_mutex);
|
||||
|
||||
ping_running = true;
|
||||
_ping_thread_id = thread_create("Ping Thread", _ping_thread, NULL, THREAD_ATTACHED);
|
||||
}
|
||||
|
||||
void ping_shutdown(void)
|
||||
{
|
||||
if (!ping_running)
|
||||
return;
|
||||
|
||||
ping_running = false;
|
||||
ICECAST_LOG_DEBUG("waiting for ping thread");
|
||||
thread_join(_ping_thread_id);
|
||||
thread_mutex_destroy(&_ping_mutex);
|
||||
}
|
||||
|
@ -9,4 +9,7 @@
|
||||
#ifndef __PING_H__
|
||||
#define __PING_H__
|
||||
|
||||
void ping_initialize(void);
|
||||
void ping_shutdown(void);
|
||||
|
||||
#endif /* __PING_H__ */
|
||||
|
Loading…
x
Reference in New Issue
Block a user