#define __log_err(fmt, ...) zlog_err("%s: ERROR: " fmt, __func__, ##__VA_ARGS__)
#define MGMTD_TXN_LOCK(txn) mgmt_txn_lock(txn, __FILE__, __LINE__)
-#define MGMTD_TXN_UNLOCK(txn) mgmt_txn_unlock(txn, __FILE__, __LINE__)
+#define MGMTD_TXN_UNLOCK(txn, in_hash_free) mgmt_txn_unlock(txn, in_hash_free, __FILE__, __LINE__)
enum mgmt_txn_event {
MGMTD_TXN_PROC_SETCFG = 1,
}
static void mgmt_txn_lock(struct mgmt_txn_ctx *txn, const char *file, int line);
-static void mgmt_txn_unlock(struct mgmt_txn_ctx **txn, const char *file,
+static void mgmt_txn_unlock(struct mgmt_txn_ctx **txn, bool in_hash_free, const char *file,
int line);
static int mgmt_txn_send_be_txn_delete(struct mgmt_txn_ctx *txn,
struct mgmt_be_client_adapter *adapter);
}
}
- MGMTD_TXN_UNLOCK(&(*batch)->txn);
+ MGMTD_TXN_UNLOCK(&(*batch)->txn, false);
XFREE(MTYPE_MGMTD_TXN_CFG_BATCH, *batch);
*batch = NULL;
(*txn_req)->req_id, mgmt_txn_reqs_count(req_list));
}
- MGMTD_TXN_UNLOCK(&(*txn_req)->txn);
+ MGMTD_TXN_UNLOCK(&(*txn_req)->txn, false);
XFREE(MTYPE_MGMTD_TXN_REQ, (*txn_req));
*txn_req = NULL;
}
return txn;
}
-static void mgmt_txn_delete(struct mgmt_txn_ctx **txn)
+static void mgmt_txn_delete(struct mgmt_txn_ctx **txn, bool in_hash_free)
{
- MGMTD_TXN_UNLOCK(txn);
+ MGMTD_TXN_UNLOCK(txn, in_hash_free);
}
static unsigned int mgmt_txn_hash_key(const void *data)
{
struct mgmt_txn_ctx *txn = data;
- mgmt_txn_delete(&txn);
+ mgmt_txn_delete(&txn, true);
}
static void mgmt_txn_hash_init(void)
mgmt_txn_type2str(txn->type), txn->txn_id, txn->refcount);
}
-static void mgmt_txn_unlock(struct mgmt_txn_ctx **txn, const char *file,
- int line)
+static void mgmt_txn_unlock(struct mgmt_txn_ctx **txn, bool in_hash_free, const char *file, int line)
{
assert(*txn && (*txn)->refcount);
EVENT_OFF((*txn)->proc_comm_cfg);
EVENT_OFF((*txn)->comm_cfg_timeout);
EVENT_OFF((*txn)->get_tree_timeout);
- hash_release(mgmt_txn_mm->txn_hash, *txn);
+ if (!in_hash_free)
+ hash_release(mgmt_txn_mm->txn_hash, *txn);
+
mgmt_txns_del(&mgmt_txn_mm->txn_list, *txn);
__dbg("Deleted %s txn-id: %" PRIu64 " session-id: %" PRIu64,
{
/* TODO: Any other cleanup applicable */
- mgmt_txn_delete(txn);
+ mgmt_txn_delete(txn, false);
}
static void mgmt_txn_cleanup_all_txns(void)
if (!txn)
return;
- mgmt_txn_delete(&txn);
+ mgmt_txn_delete(&txn, false);
*txn_id = MGMTD_TXN_ID_NONE;
}