Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Icecast-Server
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
94
Issues
94
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
External Wiki
External Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xiph.Org
Icecast-Server
Commits
83e8826f
Commit
83e8826f
authored
Jun 16, 2018
by
Philipp Schafft
🦁
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'ph3-update-pidfile'
parents
6bc631c2
6f7881a8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
83 additions
and
13 deletions
+83
-13
src/Makefile.am
src/Makefile.am
+1
-0
src/cfgfile.c
src/cfgfile.c
+2
-0
src/main.c
src/main.c
+64
-13
src/main.h
src/main.h
+16
-0
No files found.
src/Makefile.am
View file @
83e8826f
...
...
@@ -6,6 +6,7 @@ bin_PROGRAMS = icecast
noinst_HEADERS
=
\
admin.h
\
main.h
\
cfgfile.h
\
logging.h
\
sighandler.h
\
...
...
src/cfgfile.c
View file @
83e8826f
...
...
@@ -42,6 +42,7 @@
#include "fserve.h"
#include "stats.h"
#include "connection.h"
#include "main.h"
#define CATMODULE "CONFIG"
#define CONFIG_DEFAULT_LOCATION "Earth"
...
...
@@ -701,6 +702,7 @@ void config_reread_config(void)
config_set_config
(
&
new_config
);
config
=
config_get_config_unlocked
();
restart_logging
(
config
);
main_config_reload
(
config
);
connection_reread_config
(
config
);
yp_recheck_config
(
config
);
fserve_recheck_mime_types
(
config
);
...
...
src/main.c
View file @
83e8826f
...
...
@@ -60,6 +60,7 @@
#include <pwd.h>
#endif
#include "main.h"
#include "cfgfile.h"
#include "util.h"
#include "sighandler.h"
...
...
@@ -86,6 +87,8 @@
static
int
background
;
static
char
*
pidfile
=
NULL
;
static
void
pidfile_update
(
ice_config_t
*
config
,
int
always_try
);
static
void
_fatal_error
(
const
char
*
perr
)
{
#ifdef WIN32_SERVICE
...
...
@@ -116,7 +119,7 @@ static void _stop_logging(void)
log_close
(
playlistlog
);
}
void
initialize_subsystems
(
void
)
static
void
initialize_subsystems
(
void
)
{
log_initialize
();
thread_initialize
();
...
...
@@ -134,7 +137,7 @@ void initialize_subsystems(void)
#endif
}
void
shutdown_subsystems
(
void
)
static
void
shutdown_subsystems
(
void
)
{
event_shutdown
();
fserve_shutdown
();
...
...
@@ -162,6 +165,12 @@ void shutdown_subsystems(void)
xslt_shutdown
();
}
void
main_config_reload
(
ice_config_t
*
config
)
{
ICECAST_LOG_DEBUG
(
"Reloading configuration."
);
pidfile_update
(
config
,
0
);
}
static
int
_parse_config_opts
(
int
argc
,
char
**
argv
,
char
*
filename
,
size_t
size
)
{
int
i
=
1
;
...
...
@@ -324,6 +333,58 @@ static int _start_listening(void)
return
1
;
}
static
void
pidfile_update
(
ice_config_t
*
config
,
int
always_try
)
{
char
*
newpidfile
=
NULL
;
if
(
config
->
pidfile
)
{
FILE
*
f
;
/* check if the file actually changed */
if
(
pidfile
&&
strcmp
(
pidfile
,
config
->
pidfile
)
==
0
)
return
;
ICECAST_LOG_DEBUG
(
"New pidfile on %H"
,
config
->
pidfile
);
if
(
!
always_try
)
{
if
(
config
->
chuid
)
{
ICECAST_LOG_ERROR
(
"Can not write new pidfile, changeowner in effect."
);
return
;
}
if
(
config
->
chroot
)
{
ICECAST_LOG_ERROR
(
"Can not write new pidfile, chroot in effect."
);
return
;
}
}
newpidfile
=
strdup
(
config
->
pidfile
);
if
(
!
newpidfile
)
{
ICECAST_LOG_ERROR
(
"Can not allocate memory for pidfile filename. BAD."
);
return
;
}
f
=
fopen
(
newpidfile
,
"w"
);
if
(
!
f
)
{
free
(
newpidfile
);
ICECAST_LOG_ERROR
(
"Can not open new pidfile for writing."
);
return
;
}
fprintf
(
f
,
"%lld
\n
"
,
(
long
long
int
)
getpid
());
fclose
(
f
);
ICECAST_LOG_INFO
(
"pidfile %H updated."
,
pidfile
);
}
if
(
newpidfile
!=
pidfile
)
{
if
(
pidfile
)
remove
(
pidfile
);
free
(
pidfile
);
pidfile
=
newpidfile
;
}
}
/* bind the socket and start listening */
static
int
_server_proc_init
(
void
)
{
...
...
@@ -337,17 +398,7 @@ static int _server_proc_init(void)
return
0
;
}
/* recreate the pid file */
if
(
config
->
pidfile
)
{
FILE
*
f
;
pidfile
=
strdup
(
config
->
pidfile
);
if
(
pidfile
&&
(
f
=
fopen
(
config
->
pidfile
,
"w"
))
!=
NULL
)
{
fprintf
(
f
,
"%d
\n
"
,
(
int
)
getpid
());
fclose
(
f
);
}
}
pidfile_update
(
config
,
1
);
return
1
;
}
...
...
src/main.h
0 → 100644
View file @
83e8826f
/* Icecast
*
* This program is distributed under the GNU General Public License, version 2.
* A copy of this license is included with this source.
*
* Copyright 2018, Philipp "ph3-der-loewe" Schafft <lion@lion.leolix.org>,
*/
#ifndef __MAIN_H__
#define __MAIN_H__
#include "cfgfile.h"
void
main_config_reload
(
ice_config_t
*
config
);
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment