1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-09-22 04:15:54 -04:00

Update: Make use of listensocket_container_set_sockcount_cb() and listensocket_container_sockcount()

This fixes the starts-up-with-no-listen-sockets bug.
This commit is contained in:
Philipp Schafft 2018-05-09 13:48:32 +00:00
parent c401bbcc12
commit 4279a6caea
2 changed files with 19 additions and 0 deletions

View File

@ -1634,6 +1634,18 @@ static void _handle_connection(void)
}
static void __on_sock_count(size_t count, void *userdata)
{
(void)userdata;
ICECAST_LOG_DEBUG("Listen socket count is now %zu.", count);
if (count == 0 && global.running == ICECAST_RUNNING) {
ICECAST_LOG_INFO("No more listen sockets. Exiting.");
global.running = ICECAST_HALTING;
}
}
/* called when listening thread is not checking for incoming connections */
void connection_setup_sockets (ice_config_t *config)
{
@ -1663,6 +1675,7 @@ void connection_setup_sockets (ice_config_t *config)
global_unlock();
listensocket_container_set_sockcount_cb(global.listensockets, __on_sock_count, NULL);
listensocket_container_setup(global.listensockets);;
}

View File

@ -77,6 +77,7 @@
#include "yp.h"
#include "auth.h"
#include "event.h"
#include "listensocket.h"
#include <libxml/xmlmemory.h>
@ -377,6 +378,11 @@ static int _server_proc_init(void)
connection_setup_sockets(config);
if (listensocket_container_sockcount(global.listensockets) < 1) {
ICECAST_LOG_ERROR("Can not listen on any sockets.");
return 0;
}
pidfile_update(config, 1);
return 1;