From 39c9e7b471f29ec1df8b4fc407bb3fe2ac96cb9e Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Fri, 22 Aug 2014 00:28:51 +0200 Subject: libctrl: Add support for 'deferred control commands' Sometimes a control interface command cannot be processed and responded immediately, but we need to process it asynchronously. In order to support this, we introduce the 'ctrl_cmd_def', which represents such a deferred command. It is created by the service implementing the command using ctrl_cmd_def_make(), and a response is later sent using ctrl_cmd_def_send(). ctrl_cmd_def_is_zombie() must be called to handle the case where the control connection has disconnected/died between receiving the command and sending the response. --- include/osmocom/ctrl/control_cmd.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'include/osmocom/ctrl/control_cmd.h') diff --git a/include/osmocom/ctrl/control_cmd.h b/include/osmocom/ctrl/control_cmd.h index 9e949631..8f2eaa25 100644 --- a/include/osmocom/ctrl/control_cmd.h +++ b/include/osmocom/ctrl/control_cmd.h @@ -45,6 +45,9 @@ struct ctrl_connection { /* Pending commands for this connection */ struct llist_head cmds; + + /* Pending deferred commands for this connection */ + struct llist_head def_cmds; }; struct ctrl_cmd { @@ -75,6 +78,18 @@ struct ctrl_cmd_map { enum ctrl_type type; }; +/* deferred control command, i.e. responded asynchronously */ +struct ctrl_cmd_def { + struct llist_head list; /* ctrl_connection.def_cmds */ + struct ctrl_cmd *cmd; + void *data; /* opaque user data */ +}; + +struct ctrl_cmd_def * +ctrl_cmd_def_make(const void *ctx, struct ctrl_cmd *cmd, void *data, unsigned int secs); +int ctrl_cmd_def_is_zombie(struct ctrl_cmd_def *cd); +int ctrl_cmd_def_send(struct ctrl_cmd_def *cd); + int ctrl_cmd_exec(vector vline, struct ctrl_cmd *command, vector node, void *data); int ctrl_cmd_install(enum ctrl_node_type node, struct ctrl_cmd_element *cmd); int ctrl_cmd_send(struct osmo_wqueue *queue, struct ctrl_cmd *cmd); -- cgit v1.2.3