Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Xiph.Org
Icecast-IceS
Commits
c5aa7b0b
Commit
c5aa7b0b
authored
Sep 23, 2001
by
Michael Smith
Browse files
Add new way of doing metadata updates - read specified file on SIGUSR1, if
so configured. svn path=/trunk/ices/; revision=2072
parent
90e02122
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/config.h
View file @
c5aa7b0b
...
...
@@ -81,6 +81,7 @@ typedef struct _config_tag
/* private */
int
log_id
;
int
shutdown
;
char
*
metadata_filename
;
cond_t
queue_cond
;
mutex_t
refcount_lock
;
mutex_t
flush_lock
;
...
...
src/im_oss.c
View file @
c5aa7b0b
...
...
@@ -178,6 +178,8 @@ input_module_t *oss_open_module(module_param_t *params)
device
=
current
->
value
;
else
if
(
!
strcmp
(
current
->
name
,
"metadata"
))
use_metadata
=
atoi
(
current
->
value
);
else
if
(
!
strcmp
(
current
->
name
,
"metadatafilename"
))
ices_config
->
metadata_filename
=
current
->
value
;
else
LOG_WARN1
(
"Unknown parameter %s for stdinpcm module"
,
current
->
name
);
...
...
@@ -239,7 +241,10 @@ input_module_t *oss_open_module(module_param_t *params)
if
(
use_metadata
)
{
thread_create
(
"im_oss-metadata"
,
metadata_thread
,
mod
,
1
);
if
(
ices_config
->
metadata_filename
)
thread_create
(
"im_oss-metadata"
,
metadata_thread_signal
,
mod
,
1
);
else
thread_create
(
"im_oss-metadata"
,
metadata_thread_stdin
,
mod
,
1
);
LOG_INFO0
(
"Started metadata update thread"
);
}
...
...
src/metadata.c
View file @
c5aa7b0b
...
...
@@ -12,6 +12,8 @@
#include
<stdio.h>
#include
<stdlib.h>
#include
<string.h>
#include
<errno.h>
#include
<unistd.h>
#include
"config.h"
#include
"inputmodule.h"
...
...
@@ -20,7 +22,9 @@
#define MODULE "metadata/"
#include
"logging.h"
void
*
metadata_thread
(
void
*
arg
)
volatile
int
metadata_update_signalled
=
0
;
void
*
metadata_thread_stdin
(
void
*
arg
)
{
char
buf
[
1024
];
input_module_t
*
mod
=
arg
;
...
...
@@ -58,3 +62,56 @@ void *metadata_thread(void *arg)
}
}
void
*
metadata_thread_signal
(
void
*
arg
)
{
char
buf
[
1024
];
input_module_t
*
mod
=
arg
;
while
(
1
)
{
char
**
md
=
NULL
;
int
comments
=
0
;
FILE
*
file
;
while
(
metadata_update_signalled
==
0
)
sleep
(
60
);
metadata_update_signalled
=
0
;
file
=
fopen
(
ices_config
->
metadata_filename
,
"r"
);
LOG_WARN2
(
"Failed to open file %s for metadata update: %s"
,
ices_config
->
metadata_filename
,
strerror
(
errno
));
if
(
!
file
)
continue
;
while
(
fgets
(
buf
,
1024
,
file
))
{
if
(
buf
[
0
]
==
'\n'
)
break
;
else
{
if
(
buf
[
strlen
(
buf
)
-
1
]
==
'\n'
)
buf
[
strlen
(
buf
)
-
1
]
=
0
;
md
=
realloc
(
md
,
(
comments
+
2
)
*
sizeof
(
char
*
));
md
[
comments
]
=
malloc
(
strlen
(
buf
)
+
1
);
memcpy
(
md
[
comments
],
buf
,
strlen
(
buf
)
+
1
);
comments
++
;
}
}
fclose
(
file
);
if
(
md
)
/* Don't update if there's nothing there */
{
md
[
comments
]
=
0
;
/* Now, let's actually use the new data */
LOG_INFO0
(
"Updating metadata"
);
mod
->
handle_event
(
mod
,
EVENT_METADATAUPDATE
,
md
);
}
}
}
src/metadata.h
View file @
c5aa7b0b
...
...
@@ -12,7 +12,8 @@
#ifndef __METADATA_H__
#define __METADATA_H__
void
*
metadata_thread
(
void
*
arg
);
void
*
metadata_thread_stdin
(
void
*
arg
);
void
*
metadata_thread_signal
(
void
*
arg
);
#endif
/* __METADATA_H__ */
src/signals.c
View file @
c5aa7b0b
...
...
@@ -24,6 +24,16 @@
#define MODULE "signals/"
#include
"logging.h"
extern
volatile
int
metadata_update_signalled
;
void
signal_usr1_handler
(
int
signum
)
{
LOG_INFO0
(
"Metadata update requested"
);
metadata_update_signalled
=
1
;
signal
(
SIGUSR1
,
signal_usr1_handler
);
}
void
signal_hup_handler
(
int
signum
)
{
LOG_INFO0
(
"Flushing logs"
);
...
...
@@ -55,6 +65,7 @@ void signals_setup(void)
{
signal
(
SIGHUP
,
signal_hup_handler
);
signal
(
SIGINT
,
signal_int_handler
);
signal
(
SIGUSR1
,
signal_usr1_handler
);
signal
(
SIGPIPE
,
SIG_IGN
);
}
...
...
Write
Preview
Supports
Markdown
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