| Commit message (Collapse) | Author | Age |
| |
|
|
|
|
|
|
|
| |
gcc-16 rightfully complains as follows:
daemon.c:66:19: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
66 | char *p = strchr(arg, ':');
In audiod.c, parse_stream_command() has the same issue, so fix both.
|
| |
|
|
|
|
|
| |
Currently we use at several places the package version, i.e. the version
that was checked out when the package was configured. The paraslash version
is recomputed every time the package is build, so this is more up-to-date.
So use paraslash_version() everywhere and remove PACKAGE_VERSION.
|
| |
|
|
|
|
|
|
| |
Generated with
sed -i 's|Copyright.*Andre Noll.*|SPDX-License-Identifier: GPL-2.0 */|g' *.c *.h
followed by manually tweaking the result a bit. No license change intended.
|
| |
|
|
|
|
|
|
| |
All but one caller immediately free the result after using it. The exception
is daemon.c, which maintains a copy in struct daemon, and leaks it on exit.
All users can trivially be converted to use the new version, which does not
require to free the result.
|
| |
|
|
| |
Every .c file includes it anyway.
|
| |
|
|
| |
This function has no return value, so don't use \return.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
The new public daemon_get_loglevel() is needed in the zero argument
case. Otherwise, the ll command handler parses the argument and calls
daemon_set_loglevel().
The lopsub stanza for the subcommand is stored in a separate file
which is currently only included by the lopsub suite for para_audiod,
but will be included as well by the server suite.
For similar reasons we implement the completer as a generic public
function, i9e_ll_completer(), although it only has one caller in
audioc.c. Another caller follows when the ll server command is added.
|
| |
|
|
|
|
|
|
|
| |
Open-code the logic in daemon_set_log_color_or_die() and get the
values from the new SEVERTIES macro rather than duplicating the
severity list in get_loglevel_by_name().
The SEVERTIES macro will turn out to be handy for the ll subcommands of
para_server and para_audiod which are introduced in subsequent commits.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Currently the severity string (debug, info, etc.) given to --loglevel
is parsed twice: Once by lopsub, which returns the loglevel as the
index into the array of severity strings. We turn this index into a
string and pass the string to daemon_set_loglevel() which parses the
string again to turn it back into a log level value (which happens
to coincide with the index value).
Clean this up by letting daemon_set_loglevel() receive a log level
value rather than a severity string. This also allows us to remove
the now unused ENUM_STRING_VAL() macro from audiod.c.
|
| |
|
|
| |
The function receives a severity string, not a log level number.
|
| |
|
|
|
|
| |
The function was introduced already one year ago in commit ced0c17d1a3e
(daemon: Introduce log mutex), but no documentation was provided
back then.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently the server processes append messages to the log file without
coordination. This usually does not cause problems, but sometimes
the log messages of the main server process and the afs process get
interleaved due to the lack of serialization.
This patch serializes access to the common log file by employing a
new lock: the log_mutex. Like the mmd_mutex, it is realized as an
one-element System V semaphore set.
Logging is performed by the daemon subsystem implemented in daemon.c.
This subsystem is also used by para_audiod which is single-threaded
and thus does not need to care about serialization of log messages.
To keep daemon.c working for both para_server and para_audiod,
struct daemon gains two optional methods, ->pre_log_hook and
->post_log_hook. If the function pointers are not NULL, the methods
are called before and after a message is logged. For para_server
the methods call back to the server code to take and release the
lock. para_audiod does not need to be modified because if the new
function pointers are left at their default value NULL, so no hooks
are called.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
If the argument to --logfile is a relative path, it is interpreted
as relative to the current working directory. In daemon mode, the
current working directory is changed to / during startup. Hence,
when para_server re-opens the log file after it received SIGHUP, the
logfile path will now be interpreted as relative to the the root of
the file system.
Fix this by remembering the original current working directory.
Opening "." as recommended in getcwd(3) is not an option here since the
whole point of changing the cwd to / is to prevent the daemon from
keeping the cwd busy.
|
| |
|
|
|
|
|
|
|
|
| |
If the log file can not be re-opened, the error message is lost
because the log file has already been closed when PARA_EMERG_LOG() is
called. We can do better by deferring the call to daemon_close_log()
until the new log file has been opened.
With the patch applied, the reason why the (new) log file could not
be opened is logged to the old file.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The GPLv2 line does not add any additional information, so drop
it. This leaves a single line of legalese text for most files, which
is about the amount of screen real estate it deserves.
This patch was created with the following script (plus some manual
fixups):
awk '{
if (NR <= 5) {
gs = gensub(/.*Copyright.* ([0-9]+).*Andre Noll.*/, "\\1", "g")
if (gs != $0)
year = gs
next
}
if (NR == 6 && year != "")
printf("/* Copyright (C) %s Andre Noll <maan@tuebingen.mpg.de>, see file COPYING. */\n", year)
print
}'
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When we switched to lopsub, the callback request functions became
unused and were removed. At the same time, all command handlers were
made static, so they are no longer part of the doxygen documentation
and we shouldn't refer to them any more.
Also struct slot_info and the server_uptime variable have been made
private to their respective files audiod and time.c. Tthe latter was
in fact replaced by a timeval struct long ago.
The http and udp receivers don't have an init function any more, and
get_chunk_table_of_row() was removed ten years ago in commit 54a480ae.
Most references of the source code documentation will be annotated
with \ref in a subsequent commit to avoid this kind of documentation
bug in the future.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If parent_waits is true, the parent process waits for a signal from
the child before it exits. However, this signal can arive before the
parent has set up its signal handler.
This patch closes the race window by switching from signals to
pipes. We now create a pipe before the new process is forked, and
let the parent block on read(2) until the child exits or indicates
success by writing a byte to one end of the pipe. The child process
receives the file descriptor of the writing end of the pipe as the
return value of daemonize().
The only user of the parent_waits feature is para_server, which is
changed accordingly.
|
| |
|
|
|
| |
The function name "daemonize" is shown anyway, so let's print the
path to the log file instead.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The function receives the values given to the --log-color option as
a char * array, which is the type that gengetopt provides for the
arguments to string options which may be given multiple times.
This patch gets get rid of this implementation detail. The function no
longer takes the arguments to --log-color at all and applications now
must call daemon_set_log_color_or_die() themselves to set user-defined
per-loglevel colors.
To make this work, we let daemon_init_colors_or_die() return a
boolean which indicates whether color mode should be enabled, and
daemon_set_log_color_or_die() is made public. The two users of this
API, para_server and para_audiod, are adjusted accordingly.
|
| |
|
|
|
| |
daemon_set_logfile() and daemon_set_loglevel() do not modify the
passed string, so the type of the argument should be const char *.
|
| |
|
|
|
| |
If the string passed to daemon_set_log_color_or_die() can not be
parsed, we don't have a syntax error but an invalid argument.
|
| |
|
|
|
|
|
|
| |
On slow hardware it is useful to set the priority of the para_audiod
process to avoid sound artefacts due to buffer underruns.
This patch adds an option for this purpose which is available for
para_server and para_audiod.
|
| |
|
|
|
|
|
|
| |
This function is used within para_server and para_audiod. Adding the
"para_" prefix in daemon_log_welcome() rather than its callers avoids
the duplication. Also rename the "whoami" parameter to "name" and add
documentation for it. Finally, the build date is not really important
in the log message, so simply remove it.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Currently para_audiod and para_server won't start in the background
if no logfile is specified, so "-dL /dev/null" must be given to force
this. This is a bit tedious to type, so this commit makes "/dev/null"
the default.
To achive this, we can simply remove the gengetopt "dependon" statement
from daemon.m4. This works because if no logfile was given, log output
is written to stderr, which is redirected to /dev/null in case -d
was also given. We need to open /dev/null in read-write mode though,
but no other changes are required.
|
| |
|
|
|
|
|
|
|
| |
The log color logic is already contained in para_server and
para_audiod. Let's use a single function in daemon.c for this
purpose.
daemon_set_default_log_colors() and daemon_set_log_color_or_die()
can be made static since they are only called from daemon.c now.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Done with
files=$(git grep -l 'Copyright (C) [0-9]\{4\}\(-2014\)* Andre Noll')
sed --in-place= -e 's/Copyright (C) \([0-9]\{4\}\)-2014 Andre Noll/Copyright (C) \1 Andre Noll/1' $files
In previous years we ran a similar script to set the second year in
the range to the current year. This is kind of silly, so let's get
rid of this useless information.
This commit replaces "Copyright (C) A-B" by "Copyright (C) A" in
all file headers, i.e. only the first year (A) is left in. Accurate
information including time stamps for each change can be obtained
from the git history.
|
| |
|
|
| |
Found by cppcheck.
|
| |
|
|
|
| |
Using setvbuf() is equivalent, and more portable. See setbuf(3)
for details.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
The mail server on systemlinux.org was down for more than a week
lately, so let's use an alternative official address. This commit
changes all maan@systemlinux.org addresses to maan@tuebingen.mpg.de.
Most .c and .h files contain the email address in the copyright header,
so they must all be patched. Three other files contain the address
for a different reason:
* README lists email and git, gitweb and home page URLs
* configure.ac needs it for configure -h
* version.c contains it for the -V option of all commands
|
| |
|
|
|
| |
Let's reserve the daemon_ prefix for public functions of daemon.c
to make it clear where these functions are defined.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
This function receives a pointer to a timeval structure which is
supposed to contain the daemon startup time. Passing NULL means to
set the daemon startup time to the current time.
There are only two callers of this function, in audiod.c and in
server.c. The first one passes NULL, the other one initialises the
timeval structure pointed to by the global now pointer to the current
time, and passes this pointer.
It's easier to let set_server_start_time() always act as if NULL had
been passed.
|
| |
|
|
|
|
|
|
|
| |
This year, we're really on time. The changes in this patch were
created by the following silly script:
files=$(git grep -l 'Copyright (C) [0-9]\{4\}\(-2013\)* Andre Noll')
sed --in-place= -e 's/Copyright (C) \([0-9]\{4\}\)-2013 Andre Noll/Copyright (C) \1-2014 Andre Noll/1' $files
sed --in-place= -e 's/Copyright (C) 2013 Andre Noll/Copyright (C) 2013-2014 Andre Noll/1' $files
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
POSIX.1-2008 marks gettimeofday() as obsolete, so let's switch to
clock_gettime().
clock_gettime() operates on timespecs rather than on timevals like
gettimeofday() does. Since timevals are extensively used in all
parts of paraslash, and select() takes a timeval pointer as the
timeout parameter, it seems to be easiest to add a new wrapper,
clock_get_realtime(). It calls clock_gettime(), performs error
checking (all errors are treated fatal and abort the program), and
converts the result to a timeval.
Another difference between gettimeofday() and clock_gettime()
is that sys/time.h needs to be included for gettimeofday(), while
clock_gettime() is declared in time.h which gets included from para.h.
Hence we can remove the include statement for sys/time.h everywhere.
Programs which call clock_gettime need to be linked against librt on
glibc versions before 2.17 while BSD and newer glibc-based systems
have no such requirement. To make matters more interesting,
MacOS lacks clock_gettime() completely although this function conforms
to SUSv2 and POSIX.1-2001.
We'd like to avoid the unnecessary dependence on librt on systems that
have clock_gettime() in -lc, and we must fall back to gettimeofday()
on MacOS. Hence this commit also introduces a check in configure.ac
which determines whether clock_gettime() is available and, if it is,
whether -lrt is needed. Executables are only linked with -lrt if
configure found that this is necessary.
|
| |
|
|
| |
Better late than never.
|
| |
|
|
|
| |
Remove the incorrect documentation of the (non existing) return
value.
|
| | |
|
| |
|
|
|
|
|
|
|
| |
This adds the #include statement for stdbool.h to para.h. This allows
to get rid of the individual includes in *.c.
More importantly, since all *.c files include para.h, booleans will
now be available everywhere so that we won't need to touch dozens of
files anymore whenever a boolean is added to a public structure.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently, para_client defines its para_log function via the
INIT_STDERR_LOGGING() macro which generates a log function that
writes to stderr. However, we will need to switch to a different,
curses-aware logging function when operating in interactive mode.
To support more than one log method the type of para_log is changed
from a function to a (public) pointer variable. This variable is
supposed to point to the log function currently in use so that the
application can simply set para_log differently in order to switch
between log functions.
The patch also changes the INIT_STDERR_LOGGING() macro to receive the
name of the log function to be defined and to let para_log point to
the newly defined function.
|
| |
|
|
|
|
| |
Commit 25ca796b (daemon: Introduce parent_waits flag for
daemonize().) broke the compilation on FreeBSD due to signal.h not
being included. This patch adds the missing include.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In daemon mode, para_server should not detach from the console
until it is listening on its command socket. The previous approach
turned out to be buggy and has been reverted in the previous commit.
This second attempt tries to get it right. It adds a boolean parameter
"parent_waits" to daemonize(). After daemonize() has forked, the
parent process does not exit immediately if parent_waits is true but
waits until the child process sends SIGTERM to its parent, or exits.
para_server makes use of the new flag in server_init(). The daemon
process (child) sends SIGTERM to its parent after the command socket
has been initialized. para_audiod, on the other hand, does not need
this feature, so it calls daemonize() with parent_waits == false to
get the old behaviour.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The public interface of daemon.c offers some helpers for maintaining
and printing the uptime of the service. This interface consists of
the "uptime" enumeration and the public functions server_uptime()
and uptime_str(). The former function takes an uptime enum which is
either 'UPTIME_GET' or 'UPTIME_SET'.
It is cleaner to avoid the enumeration and have two separate
functions for getting and setting the uptime, so this patch
replaces server_uptime() by two new functions get_server_uptime()
and set_server_start_time(), renames uptime_str() to
get_server_uptime_str() and gets rid of the uptime enum.
All three new functions take an optional struct timeval * type argument
for the common case where the caller already knows the current time, or
wishes to specify another time for whatever reason. This allows to save
one time() system call per scheduler loop in para_server since with
this patch status_refresh() can pass the global "now" pointer (which
us updated by the scheduler once per loop) to get_server_uptime().
|
| |\ |
|
| | |
| |
| |
| |
| |
| |
| | |
We exit on errors anyway, so get rid of the return value of
color_parse() and daemon_set_log_color() and abort immediately rather
than returning -1. Add the familiar "_or_die" suffix to these functions
to make it clear that no error handling is necessary in the caller.
|
| |/ |
|
| |
|
|
| |
Hey, this is earlier than last year :)
|
| |
|
|
| |
This adds another option to include milliseconds in the output of each log message.
|
| |\ |
|
| | |
| |
| |
| |
| | |
MAXLINE is kind of depricated. Just use a 100 byte buffer and make the scope of the
buffer more local. Also, kill the pointless initialization to an empty string.
|
| | |
| |
| |
| |
| | |
The call to setuid() may fail, e.g. because it brings the process over its RLIMIT_NPROC
resource limit. So print an error message and exit in this case.
|
| |\| |
|