From: Christian Hopps Date: Tue, 16 May 2023 12:23:09 +0000 (-0400) Subject: mgmtd: Add note to SETCFG_REQ and debug logging X-Git-Tag: base_9.0~29^2~10 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=7a0894b5325e85f9d3d27d867bd091abec1ef0e4;p=matthieu%2Ffrr.git mgmtd: Add note to SETCFG_REQ and debug logging - convert impossible situation into assert Signed-off-by: Christian Hopps --- diff --git a/mgmtd/mgmt_fe_adapter.c b/mgmtd/mgmt_fe_adapter.c index 7327940c19..7509d24a6a 100644 --- a/mgmtd/mgmt_fe_adapter.c +++ b/mgmtd/mgmt_fe_adapter.c @@ -755,6 +755,11 @@ mgmt_fe_session_handle_lockds_req_msg(struct mgmt_fe_session_ctx *session, return 0; } +/* + * TODO: this function has too many conditionals relating to complex error + * conditions. It needs to be simplified and these complex error conditions + * probably need to just disconnect the client with a suitably loud log message. + */ static int mgmt_fe_session_handle_setcfg_req_msg(struct mgmt_fe_session_ctx *session, Mgmtd__FeSetConfigReq *setcfg_req) @@ -796,8 +801,8 @@ mgmt_fe_session_handle_setcfg_req_msg(struct mgmt_fe_session_ctx *session, * from another session is already in progress. */ cfg_session_id = mgmt_config_txn_in_progress(); - if (cfg_session_id != MGMTD_SESSION_ID_NONE - && cfg_session_id != session->session_id) { + if (cfg_session_id != MGMTD_SESSION_ID_NONE) { + assert(cfg_session_id != session->session_id); mgmt_fe_send_setcfg_reply( session, setcfg_req->ds_id, setcfg_req->req_id, false, @@ -811,6 +816,10 @@ mgmt_fe_session_handle_setcfg_req_msg(struct mgmt_fe_session_ctx *session, * Try taking write-lock on the requested DS (if not already). */ if (!session->ds_write_locked[setcfg_req->ds_id]) { + MGMTD_FE_ADAPTER_ERR( + "SETCFG_REQ on session-id: %" PRIu64 + " without obtaining lock", + session->session_id); if (mgmt_fe_session_write_lock_ds(setcfg_req->ds_id, ds_ctx, session) != 0) {