Andre Noll [Tue, 1 Apr 2008 22:41:49 +0000 (00:41 +0200)]
audiod: Get rid of the audiod task.
It's simpler to start/stop the decoders from status_pre_select()
because this is the point where we get the recent status info from
para_server.
In particular, this allows to kill the min_delay crap in
the audiod_pre_select() which now gets called from
status_pre_select(). Rename it to start_stop_decoders() as
this is what that function does.
Andre Noll [Tue, 1 Apr 2008 20:01:28 +0000 (22:01 +0200)]
audiod: Rewrite status task logic.
As the status task does not use any file descriptors, it's
OK to do everything in one function. So kill status_post_select()
and move the code to status_pre_select().
Andre Noll [Tue, 1 Apr 2008 19:55:26 +0000 (21:55 +0200)]
kill_task(): Only set task error status.
It's not safe to call unregister_task() at this point as
this function might be called from pre_select() or post_select().
Just set the task's error value to -E_TASK_KILLED. The task
will then be unregistered on the next iteration of the
scheduler loop.
Andre Noll [Sun, 30 Mar 2008 20:56:16 +0000 (22:56 +0200)]
Simplify the scheduling code.
- Get rid of sched->select_ret. Tasks shouldn't care about the
return value of the select call.
- Kill task->private_data. Use container_of() instead.
- Remove task->event_handler. It is never necessary and only
makes the code more convoluted. The scheduler unregisters
tasks as soon as either the pre_select or the post_select
functions return an error.
- Rename task->ret to task->error and get rid of a couple
of error fields in other structs that usually only contained
a copy of the task's error value.
This conversion likely introduces many bugs that have to be
shaken out in subsequent patches. Hopefully it will result in
less error-prone code in the long run.
Andre Noll [Tue, 25 Mar 2008 07:47:34 +0000 (08:47 +0100)]
Fix afs signal handling.
afs must not abort on SIGPIPE as the client may close the
connection at any time. This bug was there forever but showed
up only now because the recent callback changes made the afs
process write to the command handler socket multiple times.
Also ignore SIGUSR1 instead of catching and ignoring it.
Andre Noll [Mon, 24 Mar 2008 23:18:01 +0000 (00:18 +0100)]
Complete the afs callback conversion.
This makes it possible for the callbacks to pass a partial
result buffer through the command handler <-> callback socket.
This removes a serious limitation of previous paraslash-0.3.x
versions: As callbacks could not send data directly to the
command handler they had to store the full command output in
a buffer. This buffer was sent to the command handler after the
callback returns.
The problem with this approach is that it caused the callbacks
to allocate large amounts of memory. If that amount exceeded what
can be stored in a shared memory area (32MB on Linux), the command
even failed.
The fix consists of adding a max_size field and a max_size_handler
function pointer to the para_buffer structure. Whenever para_printf()
would need to allocate more memory than specified by max_size, it
calls the max_size_handler which is supposed to send out the data.
para_printf then prints the requested data into the old but now
empty buffer.
Almost all users set the max_size_handler to pass_buffer_as_shm(),
a helper function implemented in afs.c that copies the buffer to
a shared memory area and sends its identifier through the socket.
Andre Noll [Mon, 24 Mar 2008 15:04:21 +0000 (16:04 +0100)]
Introduce pass_object_as_shm().
This singles out the code for passing data from the callback
to the command handler. The plan is to change the callbacks
so that they call this function whenever the result buffer
is too large to fit into a shared memory area.
Andre Noll [Mon, 24 Mar 2008 14:20:28 +0000 (15:20 +0100)]
make send_callback_request() and friends take a result handler.
This is a first step to overcome a design flaw in the afs
callback code: The output of the commands is currently
stored in an osl object that is copied to a shared memory
area whose shmid is passed back to the command handler
via the local socket. This method limits the size of the
command output to the maximal size that can be stored in
a shared memory area which is not enough to hold large
outputs like that of ls -c.
This patch allows the command handlers to pass a result handler
function instead of an osl object. This result handler is
called for each shared memory area that gets sent through the
local socket.
Further patches will change the callbacks so that they pass
multiple result buffers instead of returning a single buffer.
This has the additional advantage that partial command output
produced by the callback can be sent even before the callback
returns. This parital output is seen immediately by the command
handler.
Andre Noll [Wed, 19 Mar 2008 20:51:46 +0000 (21:51 +0100)]
Fix use of uninitialized afhi->header_len.
In aft's add_one_audio_file() we set the header len and
the header offset to zero so that the get_file_info()
functions of the audio format handlers that do not use
headers don't need to zero these fields.
However, this is not the right place to do that as para_afh
also calls get_file_info() via compute_afhi() but missed to
clear these fields which leads to a segmentation fault.
Fix this bug by moving the zeroing to compute_afhi().
Andre Noll [Sat, 16 Feb 2008 14:33:50 +0000 (15:33 +0100)]
Sender code consolidation, on/off commands for the dccp sender.
This patch moves a bunch of code from the http sender to
send_common.c to make it available also for the dccp sender.
To this aim a new structure sender_status is introduced which
holds the configuration and the current status of the http/dccp
sender. Most of the new functions in send_common.c take a pointer
to such a structure.
This allows to implement the off/on/allow/deny/info commands
as a one-liner for both the dccp and the http sender.
The new server config option dccp_max_clients allows to restrict the
number of simultaneous connections to the dccp sender.
Andre Noll [Sun, 10 Feb 2008 11:49:29 +0000 (12:49 +0100)]
Speed up open_current_receiver().
To my surprise, this function showed up in the profiling info.
This is due to the fact that the old code was parsing the
FORMAT status item in audiod_pre_select() which gets called
on each iteration of the sheduler. However, this status item
gets only modified on audio file change.
So parse the status item string only once, when we receive it,
and store the current audio format number in the new field of
struct status_task.