]> git.proxmox.com Git - mirror_lxc.git/commit
commands: make state server interface flexible
authorChristian Brauner <christian.brauner@ubuntu.com>
Sun, 2 Jul 2017 13:42:07 +0000 (15:42 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Sat, 8 Jul 2017 22:14:46 +0000 (00:14 +0200)
commit92e350183244023264af973092cccdb013dea394
treec2a9ed41d2e7772e8a99aeeb95d6c0738f7db0a7
parent54446942fea68b01be9af90cb4a52981265c112b
commands: make state server interface flexible

This adds a little more flexibility to the state server. The idea is to have a
command socket function "lxc_cmd_add_state_client()" whose only task is to add
a new state client to the container's in-memory handler. This function returns
either the state of the container if it is already in the requested state or it
will return the newly registered client's fd in one of its arguments to the
caller. We then provide a separate helper function "lxc_cmd_sock_rcv_state()"
which can be passed the returned client fd and listens on the fd for the
requested state.
This is useful when we want to first register a client, then send a signal to
the container and wait for a state. This ensure that the client fd is
registered before the signal can have any effect and can e.g. be used to catch
something like the "STOPPING" state that is very ephemeral.

Additionally we provide a convenience function "lxc_cmd_sock_get_state()" which
combines both tasks and is used in e.g. "lxc_wait()".

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/Makefile.am
src/lxc/commands.c
src/lxc/commands.h
src/lxc/commands_utils.c [new file with mode: 0644]
src/lxc/commands_utils.h [new file with mode: 0644]
src/lxc/lxccontainer.c
src/lxc/state.c