Andre Noll [Sat, 19 Apr 2014 23:38:04 +0000 (23:38 +0000)]
build: Separate CPPFLAGS and CFLAGS.
The CPPFLAGS variable should consist of preprocessor options only and
should not contain any compiler options. Clearly this is not the case
at the moment.
This commit cleans up the mess and separates the per target CFLAGS
settings from the CPPFLAGS settings.
Andre Noll [Sat, 19 Apr 2014 23:22:53 +0000 (23:22 +0000)]
build: Rename DEBUG_CPPFLAGS to STRICT_CFLAGS.
This variable is a misnomer for two reasons: First, its purpose is
unrelated to debugging. We just prefer to compile our own source
files with more strict flags than the flags used for the generated
*.cmdline.c files. Compiling those with the strict flags would
result in warnings we can not fix anyway. Second, these flags are
no preprocessor flags but compiler flags. So STRICT_CFLAGS is more
appropriate than DEBUG_CPPFLAGS.
Andre Noll [Sat, 19 Apr 2014 23:22:18 +0000 (23:22 +0000)]
build: Only compile with osl_cppflags where necessary.
Currently we include $(osl_cppflags) in the CC command used to compile
all objects, regardless of whether the command needs these flags. This
commit changes Makefile.real to add the flags only for those objects
which actually include osl.h.
Andre Noll [Sat, 19 Apr 2014 22:53:00 +0000 (22:53 +0000)]
build: Run tr only once in configure.ac.
The configure script creates the subsystem error enums for config.h
from the list of object file names by turning the base name into
upper case and prepending "SS_". For the conversion to upper case we
currently execute the tr command once for each object.
This patch changes the corresponding shell code of configure.ac to
first build the full enum and then turn all words into upper case
in one go. This way tr is only executed once which should save us a
few cycles.
Andre Noll [Thu, 24 Jul 2014 20:05:56 +0000 (22:05 +0200)]
build: Remove duplicate -Wno-unused-function.
We compile the .c files generated by gengetopt with this option to
silence a compiler warning. The option is first added to CPPFLAGS
and then specified again in the rule for the *.cmdline.o target. This
gets rid of the second instance.
Andre Noll [Thu, 9 Oct 2014 21:37:09 +0000 (21:37 +0000)]
Merge branch 'refs/heads/t/server_cmds'
Was cooking for three weeks.
* Add sender subcommand "status".
* com_si(): Don't print git version string.
* Doxify the sender_subcommand enum.
* Overhaul help texts of server and afs commands.
* com_sender: Replace memcpy by struct copy.
Andre Noll [Sat, 26 Jul 2014 11:51:35 +0000 (13:51 +0200)]
Make senders independent of afs and osl.
Although senders don't know anything about the osl databases of
the audio file selector, all senders currently include afs.h and
osl.h. This is because:
* senders are part of para_server, so they include server.h,
* server.h has an audio_file_data structure embedded in struct
misc_meta_data, so struct audio_file_data must be declared
before server.h is included,
* struct audio_file_data is declared in afs.h,
* afs.h makes use of structures defined in <osl.h>.
This patch moves the declaration of struct audio_file_data from afs.h
to afh.h, which is also included by all senders. This allows to remove
the two include directives for afs.h and osl.h from all three senders.
Andre Noll [Tue, 12 Aug 2014 13:01:59 +0000 (15:01 +0200)]
Add htacess and icons for fancy indexing.
The apache server on people.tuebingen.mpg.de has FancyIndexing via
mod_autoindex enabled. Let's use its features to provide a nicer view
of the download directory.
This adds two .png icons for tarballs and signatures, respectively.
These icons are listed in the new .htaccess file to instruct apache
to show the icons next to the download links, along with a file
description.
On the old page files were listed alphabetically. So one had to scroll
to the bottom to get to the newest tarball link. FancyIndexing lets us
specify the sort order and we use this feature to show new files first.
Andre Noll [Sat, 9 Aug 2014 10:49:56 +0000 (12:49 +0200)]
doc: Change email address to maan@tuebingen.mpg.de
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
Andre Noll [Sun, 17 Aug 2014 17:22:01 +0000 (19:22 +0200)]
Move git services to tuebingen.mpg.de.
Both the gitweb and the git daemon service have been relocated to
tuebingen.mpg.de. This commit changes the git-related URLs in the
repository to their counterparts at the new location.
The new location does not have a gitweb page dedicated to paraslash
alone. Instead, the gitweb service is provided by the gitolite
instance at git.tuebingen.mpg.de which hosts also a couple of other
repositories.
The "Changes" link of the the menu of the paraslash web pages points
to the dedicated gitweb page, so this link is removed from the menu.
There is still a gitweb link on the download page and a new one in
the README file.
Without a dedicated gitweb page, parts of the para.css style sheet
are no longer needed. This patch removes these parts, along with
git-logo.png, header and footer, which also have become unused.
Andre Noll [Tue, 12 Aug 2014 08:52:07 +0000 (10:52 +0200)]
web: Fix logo link.
The correct destination for this link is the current directory,
rather than /. The latter works only by coincidence since
paraslash.systemlinux.org is an apache vhost.
Andre Noll [Thu, 19 Jun 2014 09:46:31 +0000 (11:46 +0200)]
Add sender subcommand "status".
Currently, the si (server info) command prints information about each
sender, like the number of connected clients and the access control
lists. As this information is related to senders, the sender command
seems to be a better fit.
This commit introduces the new sender subcommand "status" for this
purpose and changes com_si() to not print the sender information any
more, making the output of com_si() bounded. It also renames the
->info() function of the senders to ->status() to make it clear that
this function is related to the new status subcommand.
The Networking paragraph of the manual is adjusted accordingly and
now contains an example of the status command.
Andre Noll [Sun, 13 Apr 2014 21:44:36 +0000 (21:44 +0000)]
Overhaul help texts of server and afs commands.
Each server command has a brief help text which is printed by
para_client help <command> and is also included in the para_server
manual page. These texts are defined in server.cmd and afs.cmd and
haven't seen much love for a long time. This commit improves most of
them and also fixes some formating issues.
Andre Noll [Wed, 1 Jan 2014 22:15:02 +0000 (22:15 +0000)]
audiod: Clean up by notifying tasks.
There are two ways to terminate para_audiod in a controlled way:
by executing the "term" command and by sending SIGINT or SIGTERM
to the process. Currently both code paths call clean_exit() from
some ->post_select function, which terminates para_audiod by calling
exit(3). Despite the name, this is "unclean" because tasks are not shut
down properly, so not all memory can be freed by this approach. While
this is not a big problem, it makes it more difficult to debug real
memory leaks.
This patch tries to overcome this problem by using notifications to
shut down the audiod tasks. Two new error codes E_AUDIOD_TERM and
E_AUDIOD_SIGNAL are introduced for the notification values. All tasks
are modified to check for notifications and now return the (negative)
notification value from their ->post_select() method if a notification
was received. Hence schedule() returns to main() and we may clean up
the resources allocated by the scheduler by calling sched_shutdown(),
along with the usual cleanup performed by clean_exit(). The latter
function is renamed to audiod_cleanup(), which is more to the point.
Andre Noll [Tue, 12 Aug 2014 06:47:52 +0000 (08:47 +0200)]
web: Top-align menu items.
Without this, elinks shows the menu items centered with respect to the
main web page. As most pages are short, this is not a real problem. But
for the longer NEWS page the menu was shown in the middle of the page,
making it hard to navigate.
Andre Noll [Mon, 11 Aug 2014 16:30:41 +0000 (18:30 +0200)]
manual: Add libopus-dev to package list for the impatient.
Although the opus libraries are not included in the two distributions
on which the paraslash code is build and tested regularly (Ubuntu 10.04
and 12.04), it is available on the newer 14.04 (Trusty) version. Most
people probably run 14.04 by now, so let's include it in the manual.
Andre Noll [Thu, 24 Jul 2014 20:42:28 +0000 (22:42 +0200)]
build: Do not hardcode gcc in depend.sh.
Although the clang compiler understands the -MM and -MG options,
we currently rely on gcc to generate the dependency files. Of course
this fails on systems where only clang is installed. The right fix
would be to use the make variable $(CC), but let's go for the minimal
fix that replaces gcc by cc in depend.sh for now.
Andre Noll [Sun, 20 Apr 2014 20:50:45 +0000 (20:50 +0000)]
build: Properly unset CPPFLAGS, LDFLAGS, LIBS.
Currently the directories specified via --with-ogg-headers and
--with-ogg-libs are taken into account also for vorbis/speex/opus
detection. This patch makes sure we start with a pristine values
for the three variables.
Andre Noll [Fri, 2 May 2014 20:07:24 +0000 (22:07 +0200)]
build: Fix --with-gcrypt-headers and --with-vorbis-headers.
The configure script sets the autoconf output variable gcrypt_cppflags
according to the configure option --with-gcrypt-headers, but
gcrypt_cppflags is never used for the build. Hence, if libgcrypt is
installed in a non-standard location, and that location is specified
as the argument to --with-gcrypt-headers, configure detects the gcrypt
header correctly, but the build fails nevertheless.
The same type of bug also exists for the --with-vorbis-headers option.
To fix this omission this patch sets both variables in Makefile.in
and references it in Makefile.real to compile the affected objects
with the correct flags.
Andre Noll [Thu, 3 Jul 2014 21:30:58 +0000 (23:30 +0200)]
afh_common: Improve documentation of clear_afh().
The doxygen comment for this public function was rather bad.
This commit changes the comment to clarify that the function does
not free the given afhi structure but only its contents.
Andre Noll [Wed, 23 Jul 2014 15:29:29 +0000 (17:29 +0200)]
Merge branch 't/sched_improvements'
Cooking for two months. This merge required to also patch gui.c due
to semantic conflics against the changes introduced by the gui_sched
branch which was merged to master in commit d15d8509 two weeks ago.
Also a small fix for server.c is needed to squelch a compiler warning
since the global "now" variable has become a const pointer.
* t/sched_improvements: (36 commits)
audiod: Fix use after free on exit.
sched: Mark global now pointer as const.
sched: Directly pass context pointer to pre/post_select().
sched: kill task->dead.
sched: Do not shadow task_info in struct task.
sched: Dont use fixed-size buffer for task names.
sched: Rename task->error to tast->status.
sched: Rename task->status to task->name.
sched: Make struct task private to sched.c.
sched: Introduce task_status().
sched: Remove ->owned_by_sched.
sched: Remove register_task().
task_register() conversion: grab client task
task_register() conversion: audiod status task
task_register() conversion: audiod command task
task_register() conversion: client task
task_register() conversion: client supervisor task
task_register() conversion: client exec task
task_register() conversion: afs command task
task_register() conversion: vss task
...
Andre Noll [Tue, 15 Jul 2014 05:04:07 +0000 (07:04 +0200)]
audiod: Fix use after free on exit.
client_close() frees the ->ct structure which is used one line later
by task_reap(). valgrind spots this use after free bug and reports
==13497== Invalid read of size 4
==13497== at 0x8059EA8: task_reap (sched.c:199)
==13497== by 0x80542FA: close_stat_pipe (audiod.c:1082)
==13497== by 0x8055632: clean_exit (audiod.c:1159)
==13497== by 0x80556B6: signal_post_select (audiod.c:1018)
==13497== by 0x8059E5F: schedule (sched.c:88)
==13497== by 0x804D41C: main (audiod.c:1437)
==13497== Address 0x4833c04 is 204 bytes inside a block of size 212 free'd
==13497== at 0x4028AC0: free (vg_replace_malloc.c:468)
==13497== by 0x80542E8: close_stat_pipe (audiod.c:1081)
==13497== by 0x8055632: clean_exit (audiod.c:1159)
==13497== by 0x80556B6: signal_post_select (audiod.c:1018)
==13497== by 0x8059E5F: schedule (sched.c:88)
==13497== by 0x804D41C: main (audiod.c:1437)
The bug was introduced recently in commit 0b43ec5d (task_register()
conversion: client task).
Andre Noll [Sun, 13 Jul 2014 14:20:56 +0000 (16:20 +0200)]
Merge branch 't/gui_sched'
Was cooking for two months, since 2014-05-11.
* t/gui_sched: (53 commits)
gui: Always initialize theme.
gui: Simplify color handling.
gui: Dont catch SIGWINCH.
gui: Call waitpid() from exec and status task.
Doxify para_gui.
gui: Speed up window refresh.
gui: Rename cmd_task to exec_task.
gui: Move static variables of cmd_post_select() into struct cmd_task.
gui: Move some variables into struct status_task.
gui: Switch to the standard paraslash scheduler.
gui: Use cpp magic to define command handlers.
gui: Execute stat command in status_post_select().
gui: Rename COMMAND/EXTERNAL/GETCH mode.
gui: Get rid of do_select()'s mode parameter and call it only once.
gui: Reorder functions.
gui: Move signal handling code out of do_select().
gui: Move input related code out of do_select().
gui: Move external command handling out of do_select().
gui: Introduce status_post_select().
gui: Improve config reload.
...
Andre Noll [Sun, 29 Jun 2014 13:49:45 +0000 (15:49 +0200)]
mvblob: Improve error diagnostics.
On errors the mvblob commands (mvmood, mvlyr, mvimg, mvpl) fail
silently. They do write an error message to the server log, but nobody
might notice the error there. This commit changes these commands to
send the message to the client instead.
Andre Noll [Sun, 11 May 2014 19:21:15 +0000 (21:21 +0200)]
Never start playback at an empty chunk.
The chunk table of ogg/* audio files often contains "empty" chunks
which correspond to time slices for which the virtual streaming system
does not need to send any data. When playback is started at an empty
chunk, an unnecessary delay results.
To overcome this issue, this commit introduces a new public helper
afh_get_start_chunk() which looks for the first non-empty chunk before
the given chunk number.
The new function is called from afh_recv.c and from vss.c so that
both para_play and para_server now avoid to start streaming at an
empty chunk.
Andre Noll [Thu, 9 Jan 2014 16:57:58 +0000 (16:57 +0000)]
Simplify set_server_start_time().
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.
Andre Noll [Thu, 9 Jan 2014 17:04:28 +0000 (17:04 +0000)]
sched: Mark global now pointer as const.
The timeval structure pointed to by the public now pointer should not
be modified outside sched.c. Fortunately play.c is the only place
which violates this rule. This patch fixes up play.c and marks the
pointer as const.
Andre Noll [Thu, 2 Jan 2014 03:24:48 +0000 (03:24 +0000)]
sched: Directly pass context pointer to pre/post_select().
The patch is large, but it's fairly straight forward: Instead of
a task pointer all ->pre_select() and ->post_select() methods now
receive the context pointer that was passed to the scheduler when
the task was registered. This allows to kill the public task_context().
Two pre_select/post_select functions are not directly called by the
scheduler: session_post_select(), generic_recv_pre_select(). These
are changed to receive a proper struct rather than a void pointer.
Note that generic_filter_pre_select() is not changed in this
manner because some filters do not provide a pre_select wrapper but set
task->pre_select to generic_filter_pre_select().
Andre Noll [Thu, 2 Jan 2014 02:07:01 +0000 (02:07 +0000)]
sched: kill task->dead.
The three possible states of a task are determined by the ->status
and ->dead fields of struct task:
status >= 0, !dead: running
status >= 0, dead: dead (about to be removed from the task list)
status < 0: zombie (dead, but not yet reaped, -status is an error code)
This commit encodes the first two states as two non-negative numbers,
so that the three states become
status == TS_RUNNING: running
status == TS_DEAD: dead
status < 0: zombie
This allows to remove ->dead which improves readability somewhat.
Andre Noll [Thu, 2 Jan 2014 01:43:21 +0000 (01:43 +0000)]
sched: Do not shadow task_info in struct task.
All fields of struct task_info have direct counterparts in struct
task. The fields of struct task are initialized in task_register()
to the corresponding fields of struct task_info. It's easier to
just embed a task_info structure in struct task instead. This also
guarantees that task_register() stays correct in case another field
is added to struct task_info.
Andre Noll [Thu, 2 Jan 2014 01:05:54 +0000 (01:05 +0000)]
sched: Rename task->status to task->name.
"status" has always been a misnomer for the user-defined description
of a task. Now that the structure has been made local, only sched.c
needs to be changed.
Andre Noll [Tue, 31 Dec 2013 17:22:57 +0000 (17:22 +0000)]
sched: Introduce task_status().
Before struct task can be made private to sched.c we must eliminate
code which directly accesses the fields of this structure. The last
offender is ->error: in many places we check this field to detect
whether some task is in an error condition.
This patch provides a public accessor function, task_status(),
for this purpose. All users of ->error are modified to call this
function instead.
Andre Noll [Wed, 8 Jan 2014 05:16:15 +0000 (05:16 +0000)]
task_register() conversion: stdin task
This renames stdin_set_defaults() to stdin_task_register() and changes
the function to register the stdin task. Before this patch, the task
was registered in the callers.
Andre Noll [Sat, 25 Jan 2014 18:41:45 +0000 (19:41 +0100)]
task_register() conversion: receivers
This adds a new public function, task_reap(), to sched.c. It is
called by para_audiod and para_play to free the memory occupied by
the receiver node after EOF. sched_shutdown() can not be used for
this purpose since the scheduler stays active during the life time of
these programs (i.e. schedule() never returns) while receiver nodes
come and go.
The new task_reap() has to face the problem that it is called
from another task's ->post_select() method, so removing the task
being reaped from the scheduler task list is not possible in
task_reap(). Hence this patch adds the new flag "dead" to struct
task. It is initially unset and is turned on in task_reap() to indicate
that (a) the task has exited (i.e. ->post_select() returned negative)
and (b) task_reap() has been called to fetch the exit status. Only
if this flag is set, the scheduler removes the task from the task list.
Andre Noll [Mon, 30 Dec 2013 19:27:04 +0000 (19:27 +0000)]
sched: Introduce alternative task API.
In the current implementation struct task is public so users of this
structure can mess with internal scheduler details as they please. This
has led to many bugs and questionable code in the past. This commit
is the first step to overcome this design mistake. At the end of this
patch series struct task can be made private to sched.c.
This commit introduces the following new public functions:
It also adds the new public task_info structure which carries the
information passed to the scheduler when a new task is registered. This
structure will stay public while struct task will become private once
all users have been converted.
task_register() is supposed to eventually replace register_task(). The
main difference of the two is that the new function returns a _pointer_
to a task structure which is allocated dynamically. Users are not
supposed to look at the fields of this pointer directly.
task_context() is a temporary helper which can be removed again at the
end of the series. Its sole purpose is to return the context pointer
which was passed at task register time as part of struct task_info.
The final new function, sched_shutdown(), deallocates the task
structures allocated during task_register() to cleanly shut down the
scheduler after all tasks have terminated.
All users need to be converted to the new API. This patch only converts
the stdout task though. The other tasks will be converted in subsequent
patches. The scheduler can tell if a task was registered using the
new API by means of the new ->owned_by_sched bit of struct task.
This boolean variable can also be removed after all tasks have been
converted.
Some users will need to query the exit status of a terminated
task. Hence we keep all tasks on the task list after ->post_select()
returned negative but call neither ->pre_select() nor ->post_select()
any more for such tasks. This leads to the concept of zombie tasks.
Andre Noll [Mon, 30 Dec 2013 17:37:41 +0000 (17:37 +0000)]
Simplify sched: Use only a single task list.
Currently the scheduler maintains two linked task lists, the pre_select
and the post_select list. This is completely unnecessary and bloats
the code for no good reason. This patch makes it use a single list
only and updates the documentation accordingly.
Andre Noll [Mon, 12 May 2014 15:51:49 +0000 (17:51 +0200)]
gui: Always initialize theme.
parse_config_file_or_die() contains the following bug: If the
configuration file ~/.paraslash/gui.conf does not exist, the current
code not only skips the gengetopt config file parser (which is correct)
but also omits to call theme_init(), which is incorrect.
The bug was introduced recently in commit 18d37e (Unify config
file parsing). Fix it by moving the call to theme_init() to
the bottom of the function so that it is called if and only if
parse_config_file_or_die() succeeds.
Andre Noll [Sun, 11 May 2014 19:47:03 +0000 (21:47 +0200)]
recv: Don't segfault on invalid chunk values.
If recv->open() fails, para_recv segfaults after
==10129== Conditional jump or move depends on uninitialised value(s)
==10129== at 0x41BA18A: vfprintf (vfprintf.c:1634)
==10129== by 0x41BE3D8: buffered_vfprintf (vfprintf.c:2311)
==10129== by 0x41B975C: vfprintf (vfprintf.c:1289)
==10129== by 0x804C6AF: stderr_log (in /home/maan/scm/paraslash/para_recv)
==10129== by 0x804A193: main (recv.c:114)
This happens for example with the afh_receiver if the given start
chunk is bigger than the end chunk, e.g. when para_recv is executed as
./para_recv -r 'afh -b -80 -e -89 -f foo.opus'
The reason for the bug is we zero-out the stdout structure too late.
Fix this by initializing the stdout task structure upfront rather
than using memset().
This bug was introduced a year ago in commit b01605d7 (Avoid unwanted
log messages during startup) which moved down the call to memset().
Andre Noll [Sat, 8 Mar 2014 20:18:21 +0000 (21:18 +0100)]
gui: Simplify color handling.
Various gui elements of para_gui can be customized through struct
gui_theme. Currently this structure contains two integers for each
each element, one for the foreground and one for the background color
of the element. This is a bit clumsy and repetitive.
This commit cuts down the number of fields of struct gui_theme by
a factor of two by introducing struct gui_color_spec as a pair of
integers.
Andre Noll [Thu, 13 Feb 2014 18:59:49 +0000 (19:59 +0100)]
gui: Dont catch SIGWINCH.
This is unnecessary since the curses library generates a KEY_RESIZE
event on SIGWINCH anyway. Hence window change events can be handled
as well in the normal input processing function. This allows to remove
the SIGWINCH part of the signal handling code.
Another advantage of handling SIGWINCH in the same way as normal
input events is that it is easier to propagate the event. This will
turn out to be useful for the upcoming gui menu changes.
Andre Noll [Mon, 27 Jan 2014 10:35:08 +0000 (11:35 +0100)]
gui: Call waitpid() from exec and status task.
This commit changes signal_post_select() to not call waitpid() via
para_reap_child() any more. Instead it notifies all tasks using the
new error code E_GUI_SIGCHLD. The exec task and the status task honor
this notification and call waitpid() for their "own" pid to check
whether the executing process or the stat process has terminated and
to obtain the exit status.
Although neither task cares deeply about the exit code, the menu
commands, which will be implemented in subsequent patches, will
care. So it's good to have the option to get this information.