Andre Noll [Sat, 12 Apr 2008 17:18:58 +0000 (19:18 +0200)]
Kill mmd_lock() and mmd_unlock().
They were only wrappers for mutex_lock() and mutex_unlock().
So export the lock, use mutex_lock() and mutex_unlock()
everywhere and remove the wrappers.
Andre Noll [Sat, 12 Apr 2008 12:35:16 +0000 (14:35 +0200)]
chunk_queue: Store a pointer to the data and the chunk size.
Storing the chunk number has the disadvantage that the
queuing code must call into vss to get the chunk. This
is unneccessary and requires the map pointer of vss.c
to be global.
Andre Noll [Sun, 6 Apr 2008 10:50:29 +0000 (12:50 +0200)]
client.c: supervisor task should use post_select instead of pre_select.
This allows to get rid of the ugly min_delay hack. This works
because the supervisor task is registered _after_ the client
task. So when the client task changes its state to either
CL_RECEIVING or CL_SENDING in its post_select function, the
supervisor task will start the stdin/stout task in the same
iteration of the scheduler post_select loop.
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.