]> git.tuebingen.mpg.de Git - paraslash.git/commit
client: Only start stdin task for addblob commands.
authorAndre Noll <maan@systemlinux.org>
Wed, 26 Jun 2013 18:28:58 +0000 (20:28 +0200)
committerAndre Noll <maan@systemlinux.org>
Wed, 26 Jun 2013 20:18:11 +0000 (22:18 +0200)
commit72ffa7817c55630c113cc9aa213608ca5518f67c
tree2401f49a90adf54b4432f76448fdf8a4cae18bf9
parent85a6aec201576a1ec57e78d91f73e45d9d6fae21
client: Only start stdin task for addblob commands.

Currently the command

para_client -- ls -lv | grep a

fails in a rather strange way, emitting many error messages like

grep: writing output: Resource temporarily unavailable

This is because O_NONBLOCK is a file status flag rather than a file
descriptor flag, i.e. nonblocking mode is a property of the file
description rather than the file descriptor.

In the above command both stdin of the para_client process and
stdout of the grep process refer to the same file description (the
terminal). para_client sets stdin to nonblocking mode, hence stdout
of the grep process is also in nonblocking mode.

We avoid this problem by changing client.c to only set stdin to
nonblocking mode if we actually need to read from stdin, i.e. only
for the addblob commands. This is achieved by registering the stdin
task (which sets the O_NONBLOCK flag) only if the client status
is CL_SENDING.

For addblob commands the client status changes from CL_EXECUTING to
CL_SENDING, so we can not simply terminate the supervisor task any more
after the stdout task has been registered. Instead we must keep this
task alive and (a) remember that stdout has already been started, and
(b) start the stdin task in case the client status becomes CL_SENDING.

Unfortunately, there is no simple way to store this bit of information
as we don't have a dedicated supervisor structure yet. Therefore this
patch introduces this structure as a task struct plus a single boolean.
client.c