mirror of https://gerrit.osmocom.org/libosmocore
ctrl: Don't expose write_queue in ctrl_cmd_send() api
ctrl_cmd_send() should always have taken a 'struct ctrl_connection' as argument, not directly its write_queue member. Let's offer a ctrl_cmd_send2() which fixes the problem, and deprecate the old ctrl_cmd_send(). Related: OS#5751 Change-Id: Ic81af56e7ea6921ba39168727ef64c308e9c6754
This commit is contained in:
parent
ada88ce655
commit
319a77e519
|
@ -124,7 +124,6 @@ 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);
|
||||
int ctrl_cmd_send_to_all(struct ctrl_handle *ctrl, struct ctrl_cmd *cmd);
|
||||
struct ctrl_cmd *ctrl_cmd_parse3(void *ctx, struct msgb *msg, bool *parse_failed);
|
||||
struct ctrl_cmd *ctrl_cmd_parse2(void *ctx, struct msgb *msg);
|
||||
|
|
|
@ -28,7 +28,8 @@ struct ctrl_handle {
|
|||
};
|
||||
|
||||
|
||||
int ctrl_cmd_send(struct osmo_wqueue *queue, struct ctrl_cmd *cmd);
|
||||
int ctrl_cmd_send(struct osmo_wqueue *queue, struct ctrl_cmd *cmd) OSMO_DEPRECATED("Use ctrl_cmd_send2() instead.");
|
||||
int ctrl_cmd_send2(struct ctrl_connection *ccon, struct ctrl_cmd *cmd);
|
||||
int ctrl_cmd_send_trap(struct ctrl_handle *ctrl, const char *name, char *value);
|
||||
struct ctrl_handle *ctrl_handle_alloc(void *ctx, void *data, ctrl_cmd_lookup lookup);
|
||||
struct ctrl_handle *ctrl_handle_alloc2(void *ctx, void *data,
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include <osmocom/ctrl/control_cmd.h>
|
||||
#include <osmocom/ctrl/control_if.h>
|
||||
|
||||
#include <osmocom/core/msgb.h>
|
||||
#include <osmocom/core/talloc.h>
|
||||
|
@ -647,7 +648,7 @@ int ctrl_cmd_def_send(struct ctrl_cmd_def *cd)
|
|||
cmd->type = CTRL_TYPE_ERROR;
|
||||
}
|
||||
|
||||
rc = ctrl_cmd_send(&cmd->ccon->write_queue, cmd);
|
||||
rc = ctrl_cmd_send2(cmd->ccon, cmd);
|
||||
|
||||
talloc_free(cmd);
|
||||
llist_del(&cd->list);
|
||||
|
|
|
@ -106,17 +106,27 @@ int ctrl_cmd_send_to_all(struct ctrl_handle *ctrl, struct ctrl_cmd *cmd)
|
|||
llist_for_each_entry(ccon, &ctrl->ccon_list, list_entry) {
|
||||
if (ccon == cmd->ccon)
|
||||
continue;
|
||||
if (ctrl_cmd_send(&ccon->write_queue, cmd))
|
||||
if (ctrl_cmd_send2(ccon, cmd))
|
||||
ret++;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*! Encode a CTRL command and append it to the given write queue
|
||||
/*! Encode a CTRL command and append it to the given ctrl_connection
|
||||
* \param[inout] queue write queue to which encoded \a cmd shall be appended
|
||||
* \param[in] cmd decoded command representation
|
||||
* \returns 0 in case of success; negative on error */
|
||||
int ctrl_cmd_send(struct osmo_wqueue *queue, struct ctrl_cmd *cmd)
|
||||
{
|
||||
struct ctrl_connection *ccon = container_of(queue, struct ctrl_connection, write_queue);
|
||||
return ctrl_cmd_send2(ccon, cmd);
|
||||
}
|
||||
|
||||
/*! Encode a CTRL command and append it to the given ctrl_connection
|
||||
* \param[inout] queue write queue to which encoded \a cmd shall be appended
|
||||
* \param[in] cmd decoded command representation
|
||||
* \returns 0 in case of success; negative on error */
|
||||
int ctrl_cmd_send2(struct ctrl_connection *ccon, struct ctrl_cmd *cmd)
|
||||
{
|
||||
int ret;
|
||||
struct msgb *msg;
|
||||
|
@ -130,7 +140,7 @@ int ctrl_cmd_send(struct osmo_wqueue *queue, struct ctrl_cmd *cmd)
|
|||
ipa_prepend_header_ext(msg, IPAC_PROTO_EXT_CTRL);
|
||||
ipa_prepend_header(msg, IPAC_PROTO_OSMO);
|
||||
|
||||
ret = osmo_wqueue_enqueue(queue, msg);
|
||||
ret = osmo_wqueue_enqueue(&ccon->write_queue, msg);
|
||||
if (ret != 0) {
|
||||
LOGP(DLCTRL, LOGL_ERROR, "Failed to enqueue the command.\n");
|
||||
msgb_free(msg);
|
||||
|
@ -464,7 +474,7 @@ int ctrl_handle_msg(struct ctrl_handle *ctrl, struct ctrl_connection *ccon, stru
|
|||
|
||||
send_reply:
|
||||
/* There is a reply or error that should be reported back to the sender. */
|
||||
ctrl_cmd_send(&ccon->write_queue, cmd);
|
||||
ctrl_cmd_send2(ccon, cmd);
|
||||
just_free:
|
||||
talloc_free(cmd);
|
||||
return 0;
|
||||
|
|
|
@ -15,6 +15,7 @@ ctrl_cmd_parse;
|
|||
ctrl_cmd_parse2;
|
||||
ctrl_cmd_parse3;
|
||||
ctrl_cmd_send;
|
||||
ctrl_cmd_send2;
|
||||
ctrl_cmd_send_to_all;
|
||||
ctrl_cmd_send_trap;
|
||||
ctrl_cmd_trap;
|
||||
|
|
Loading…
Reference in New Issue