mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-08 18:20:15 +00:00
mgmtd: complex redux in txn cleanup
Signed-off-by: Christian Hopps <chopps@labn.net>
This commit is contained in:
parent
70ff6bb80b
commit
c9d153e5e9
@ -494,6 +494,8 @@ static void mgmt_txn_req_free(struct mgmt_txn_req **txn_req)
|
|||||||
struct mgmt_txn_reqs_head *pending_list = NULL;
|
struct mgmt_txn_reqs_head *pending_list = NULL;
|
||||||
enum mgmt_be_client_id id;
|
enum mgmt_be_client_id id;
|
||||||
struct mgmt_be_client_adapter *adapter;
|
struct mgmt_be_client_adapter *adapter;
|
||||||
|
struct mgmt_commit_cfg_req *ccreq;
|
||||||
|
bool cleanup;
|
||||||
|
|
||||||
switch ((*txn_req)->req_event) {
|
switch ((*txn_req)->req_event) {
|
||||||
case MGMTD_TXN_PROC_SETCFG:
|
case MGMTD_TXN_PROC_SETCFG:
|
||||||
@ -526,32 +528,38 @@ static void mgmt_txn_req_free(struct mgmt_txn_req **txn_req)
|
|||||||
MGMTD_TXN_DBG("Deleting COMMITCFG req-id: %" PRIu64
|
MGMTD_TXN_DBG("Deleting COMMITCFG req-id: %" PRIu64
|
||||||
" txn-id: %" PRIu64,
|
" txn-id: %" PRIu64,
|
||||||
(*txn_req)->req_id, (*txn_req)->txn->txn_id);
|
(*txn_req)->req_id, (*txn_req)->txn->txn_id);
|
||||||
|
|
||||||
|
ccreq = &(*txn_req)->req.commit_cfg;
|
||||||
|
cleanup = (ccreq->curr_phase >= MGMTD_COMMIT_PHASE_TXN_CREATE &&
|
||||||
|
ccreq->curr_phase < MGMTD_COMMIT_PHASE_TXN_DELETE);
|
||||||
|
|
||||||
FOREACH_MGMTD_BE_CLIENT_ID (id) {
|
FOREACH_MGMTD_BE_CLIENT_ID (id) {
|
||||||
/*
|
/*
|
||||||
* Send TXN_DELETE to cleanup state for this
|
* Send TXN_DELETE to cleanup state for this
|
||||||
* transaction on backend
|
* transaction on backend
|
||||||
*/
|
*/
|
||||||
if ((*txn_req)->req.commit_cfg.curr_phase >=
|
|
||||||
MGMTD_COMMIT_PHASE_TXN_CREATE &&
|
/*
|
||||||
(*txn_req)->req.commit_cfg.curr_phase <
|
* Get rid of the batches first so we don't end up doing
|
||||||
MGMTD_COMMIT_PHASE_TXN_DELETE &&
|
* anything more with them
|
||||||
(*txn_req)
|
*/
|
||||||
->req.commit_cfg.subscr_info
|
mgmt_txn_cleanup_be_cfg_batches((*txn_req)->txn, id);
|
||||||
.xpath_subscr[id]) {
|
if (ccreq->batches) {
|
||||||
adapter = mgmt_be_get_adapter_by_id(id);
|
hash_clean(ccreq->batches,
|
||||||
if (adapter)
|
mgmt_txn_cfgbatch_hash_free);
|
||||||
mgmt_txn_send_be_txn_delete(
|
hash_free(ccreq->batches);
|
||||||
(*txn_req)->txn, adapter);
|
ccreq->batches = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
mgmt_txn_cleanup_be_cfg_batches((*txn_req)->txn,
|
/*
|
||||||
id);
|
* If we were in the middle of the state machine then
|
||||||
if ((*txn_req)->req.commit_cfg.batches) {
|
* send a txn delete message
|
||||||
hash_clean((*txn_req)->req.commit_cfg.batches,
|
*/
|
||||||
mgmt_txn_cfgbatch_hash_free);
|
adapter = mgmt_be_get_adapter_by_id(id);
|
||||||
hash_free((*txn_req)->req.commit_cfg.batches);
|
if (adapter && cleanup &&
|
||||||
(*txn_req)->req.commit_cfg.batches = NULL;
|
ccreq->subscr_info.xpath_subscr[id])
|
||||||
}
|
mgmt_txn_send_be_txn_delete((*txn_req)->txn,
|
||||||
|
adapter);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MGMTD_TXN_PROC_GETCFG:
|
case MGMTD_TXN_PROC_GETCFG:
|
||||||
@ -1424,24 +1432,16 @@ static int
|
|||||||
mgmt_txn_send_be_txn_delete(struct mgmt_txn_ctx *txn,
|
mgmt_txn_send_be_txn_delete(struct mgmt_txn_ctx *txn,
|
||||||
struct mgmt_be_client_adapter *adapter)
|
struct mgmt_be_client_adapter *adapter)
|
||||||
{
|
{
|
||||||
struct mgmt_commit_cfg_req *cmtcfg_req;
|
struct mgmt_commit_cfg_req *cmtcfg_req =
|
||||||
struct mgmt_txn_be_cfg_batch *cfg_btch;
|
&txn->commit_cfg_req->req.commit_cfg;
|
||||||
|
|
||||||
assert(txn->type == MGMTD_TXN_TYPE_CONFIG && txn->commit_cfg_req);
|
assert(txn->type == MGMTD_TXN_TYPE_CONFIG);
|
||||||
|
assert(!mgmt_txn_batches_count(&cmtcfg_req->curr_batches[adapter->id]));
|
||||||
|
|
||||||
cmtcfg_req = &txn->commit_cfg_req->req.commit_cfg;
|
if (!cmtcfg_req->subscr_info.xpath_subscr[adapter->id])
|
||||||
if (cmtcfg_req->subscr_info.xpath_subscr[adapter->id]) {
|
return 0;
|
||||||
adapter = mgmt_be_get_adapter_by_id(adapter->id);
|
|
||||||
(void)mgmt_be_send_txn_req(adapter, txn->txn_id, false);
|
|
||||||
|
|
||||||
FOREACH_TXN_CFG_BATCH_IN_LIST (
|
return mgmt_be_send_txn_req(adapter, txn->txn_id, false);
|
||||||
&txn->commit_cfg_req->req.commit_cfg
|
|
||||||
.curr_batches[adapter->id],
|
|
||||||
cfg_btch)
|
|
||||||
cfg_btch->comm_phase = MGMTD_COMMIT_PHASE_TXN_DELETE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mgmt_txn_cfg_commit_timedout(struct event *thread)
|
static void mgmt_txn_cfg_commit_timedout(struct event *thread)
|
||||||
|
Loading…
Reference in New Issue
Block a user