1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-06-23 06:25:24 +00:00

Feature: Use settings from the listen socket for YP if there is only one

Closes: #2354
This commit is contained in:
Philipp Schafft 2022-03-21 23:13:30 +00:00
parent 10e9d93523
commit b06942e1bc
3 changed files with 22 additions and 0 deletions

View File

@ -520,6 +520,22 @@ listensocket_t * listensocket_container_get_by_id(listensocket_container_t *self
return NULL;
}
/* may return NULL if there is no default */
listensocket_t * listensocket_container_get_default(listensocket_container_t *self)
{
listensocket_t *ret = NULL;
thread_rwlock_rlock(&self->rwlock);
if (self->sock_len == 1) {
if (refobject_ref(self->sock[0]) == 0) {
ret = self->sock[0];
}
}
thread_rwlock_unlock(&self->rwlock);
return ret;
}
listensocket_t ** listensocket_container_list_sockets(listensocket_container_t *self)
{
listensocket_t **res;

View File

@ -27,6 +27,7 @@ connection_t * listensocket_container_accept(listensocket_container
int listensocket_container_set_sockcount_cb(listensocket_container_t *self, void (*cb)(size_t count, void *userdata), void *userdata);
ssize_t listensocket_container_sockcount(listensocket_container_t *self);
listensocket_t * listensocket_container_get_by_id(listensocket_container_t *self, const char *id);
listensocket_t * listensocket_container_get_default(listensocket_container_t *self); /* may return NULL if there is no default */
listensocket_t ** listensocket_container_list_sockets(listensocket_container_t *self);
bool listensocket_container_is_family_included(listensocket_container_t *self, sock_family_t family);

View File

@ -611,6 +611,11 @@ static ypdata_t *create_yp_entry (struct yp_server *server, const char *mount)
if (!listen_socket)
ICECAST_LOG_ERROR("Failure to find listen socket with ID %#H, using default.",
server->listen_socket_id);
} else {
listen_socket = listensocket_container_get_default(global.listensockets);
if (!listen_socket) {
ICECAST_LOG_WARN("There is no listen socket defined for this YP nor is there a default. Listen URLs might be wrong.");
}
}
ret = client_get_baseurl(NULL, listen_socket, url, len, NULL, NULL, NULL, mount, NULL);
if (ret >= len) {