#include "mgmtd/mgmt_memory.h"
#include "mgmtd/mgmt_txn.h"
-#define MGMTD_TXN_DBG(fmt, ...) \
+#define __dbg(fmt, ...) \
DEBUGD(&mgmt_debug_txn, "TXN: %s: " fmt, __func__, ##__VA_ARGS__)
-#define MGMTD_TXN_ERR(fmt, ...) \
- zlog_err("%s: ERROR: " fmt, __func__, ##__VA_ARGS__)
+#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__)
size_t indx;
struct mgmt_commit_cfg_req *cmtcfg_req;
- MGMTD_TXN_DBG(" freeing batch txn-id %" PRIu64, (*batch)->txn->txn_id);
+ __dbg(" freeing batch txn-id %" PRIu64, (*batch)->txn->txn_id);
assert((*batch)->txn && (*batch)->txn->type == MGMTD_TXN_TYPE_CONFIG);
sizeof(struct mgmt_set_cfg_req));
assert(txn_req->req.set_cfg);
mgmt_txn_reqs_add_tail(&txn->set_cfg_reqs, txn_req);
- MGMTD_TXN_DBG("Added a new SETCFG req-id: %" PRIu64
- " txn-id: %" PRIu64 ", session-id: %" PRIu64,
- txn_req->req_id, txn->txn_id, txn->session_id);
+ __dbg("Added a new SETCFG req-id: %" PRIu64 " txn-id: %" PRIu64
+ ", session-id: %" PRIu64,
+ txn_req->req_id, txn->txn_id, txn->session_id);
break;
case MGMTD_TXN_PROC_COMMITCFG:
txn->commit_cfg_req = txn_req;
- MGMTD_TXN_DBG("Added a new COMMITCFG req-id: %" PRIu64
- " txn-id: %" PRIu64 " session-id: %" PRIu64,
- txn_req->req_id, txn->txn_id, txn->session_id);
+ __dbg("Added a new COMMITCFG req-id: %" PRIu64
+ " txn-id: %" PRIu64 " session-id: %" PRIu64,
+ txn_req->req_id, txn->txn_id, txn->session_id);
FOREACH_MGMTD_BE_CLIENT_ID (id) {
txn_req->req.commit_cfg.be_phase[id] =
sizeof(struct mgmt_get_data_req));
assert(txn_req->req.get_data);
mgmt_txn_reqs_add_tail(&txn->get_cfg_reqs, txn_req);
- MGMTD_TXN_DBG("Added a new GETCFG req-id: %" PRIu64
- " txn-id: %" PRIu64 " session-id: %" PRIu64,
- txn_req->req_id, txn->txn_id, txn->session_id);
+ __dbg("Added a new GETCFG req-id: %" PRIu64 " txn-id: %" PRIu64
+ " session-id: %" PRIu64,
+ txn_req->req_id, txn->txn_id, txn->session_id);
break;
case MGMTD_TXN_PROC_GETTREE:
txn_req->req.get_tree = XCALLOC(MTYPE_MGMTD_TXN_GETTREE_REQ,
sizeof(struct txn_req_get_tree));
mgmt_txn_reqs_add_tail(&txn->get_tree_reqs, txn_req);
- MGMTD_TXN_DBG("Added a new GETTREE req-id: %" PRIu64
- " txn-id: %" PRIu64 " session-id: %" PRIu64,
- txn_req->req_id, txn->txn_id, txn->session_id);
+ __dbg("Added a new GETTREE req-id: %" PRIu64 " txn-id: %" PRIu64
+ " session-id: %" PRIu64,
+ txn_req->req_id, txn->txn_id, txn->session_id);
break;
case MGMTD_TXN_COMMITCFG_TIMEOUT:
case MGMTD_TXN_GETTREE_TIMEOUT:
enum mgmt_be_client_id id;
struct mgmt_be_client_adapter *adapter;
struct mgmt_commit_cfg_req *ccreq;
+ struct mgmt_set_cfg_req *set_cfg;
bool cleanup;
switch ((*txn_req)->req_event) {
case MGMTD_TXN_PROC_SETCFG:
- for (indx = 0; indx < (*txn_req)->req.set_cfg->num_cfg_changes;
- indx++) {
- if ((*txn_req)->req.set_cfg->cfg_changes[indx].value) {
- MGMTD_TXN_DBG("Freeing value for %s at %p ==> '%s'",
- (*txn_req)
- ->req.set_cfg
- ->cfg_changes[indx]
- .xpath,
- (*txn_req)
- ->req.set_cfg
- ->cfg_changes[indx]
- .value,
- (*txn_req)
- ->req.set_cfg
- ->cfg_changes[indx]
- .value);
- free((void *)(*txn_req)
- ->req.set_cfg->cfg_changes[indx]
- .value);
- }
+ set_cfg = (*txn_req)->req.set_cfg;
+ for (indx = 0; indx < set_cfg->num_cfg_changes; indx++) {
+ if (set_cfg->cfg_changes[indx].value)
+ free((void *)set_cfg->cfg_changes[indx].value);
}
req_list = &(*txn_req)->txn->set_cfg_reqs;
- MGMTD_TXN_DBG("Deleting SETCFG req-id: %" PRIu64
- " txn-id: %" PRIu64,
- (*txn_req)->req_id, (*txn_req)->txn->txn_id);
+ __dbg("Deleting SETCFG req-id: %" PRIu64 " txn-id: %" PRIu64,
+ (*txn_req)->req_id, (*txn_req)->txn->txn_id);
XFREE(MTYPE_MGMTD_TXN_SETCFG_REQ, (*txn_req)->req.set_cfg);
break;
case MGMTD_TXN_PROC_COMMITCFG:
- MGMTD_TXN_DBG("Deleting COMMITCFG req-id: %" PRIu64
- " txn-id: %" PRIu64,
- (*txn_req)->req_id, (*txn_req)->txn->txn_id);
+ __dbg("Deleting COMMITCFG req-id: %" PRIu64 " txn-id: %" PRIu64,
+ (*txn_req)->req_id, (*txn_req)->txn->txn_id);
ccreq = &(*txn_req)->req.commit_cfg;
cleanup = (ccreq->phase >= MGMTD_COMMIT_PHASE_TXN_CREATE &&
->req.get_data->xpaths[indx]);
}
req_list = &(*txn_req)->txn->get_cfg_reqs;
- MGMTD_TXN_DBG("Deleting GETCFG req-id: %" PRIu64
- " txn-id: %" PRIu64,
- (*txn_req)->req_id, (*txn_req)->txn->txn_id);
+ __dbg("Deleting GETCFG req-id: %" PRIu64 " txn-id: %" PRIu64,
+ (*txn_req)->req_id, (*txn_req)->txn->txn_id);
if ((*txn_req)->req.get_data->reply)
XFREE(MTYPE_MGMTD_TXN_GETDATA_REPLY,
(*txn_req)->req.get_data->reply);
XFREE(MTYPE_MGMTD_TXN_GETDATA_REQ, (*txn_req)->req.get_data);
break;
case MGMTD_TXN_PROC_GETTREE:
- MGMTD_TXN_DBG("Deleting GETTREE req-id: %" PRIu64
- " of txn-id: %" PRIu64,
- (*txn_req)->req_id, (*txn_req)->txn->txn_id);
+ __dbg("Deleting GETTREE req-id: %" PRIu64 " of txn-id: %" PRIu64,
+ (*txn_req)->req_id, (*txn_req)->txn->txn_id);
req_list = &(*txn_req)->txn->get_tree_reqs;
lyd_free_all((*txn_req)->req.get_tree->client_results);
XFREE(MTYPE_MGMTD_XPATH, (*txn_req)->req.get_tree->xpath);
if (req_list) {
mgmt_txn_reqs_del(req_list, *txn_req);
- MGMTD_TXN_DBG("Removed req-id: %" PRIu64
- " from request-list (left:%zu)",
- (*txn_req)->req_id, mgmt_txn_reqs_count(req_list));
+ __dbg("Removed req-id: %" PRIu64 " from request-list (left:%zu)",
+ (*txn_req)->req_id, mgmt_txn_reqs_count(req_list));
}
MGMTD_TXN_UNLOCK(&(*txn_req)->txn);
assert(txn);
cmt_stats = mgmt_fe_get_session_commit_stats(txn->session_id);
- MGMTD_TXN_DBG("Processing %zu SET_CONFIG requests txn-id:%" PRIu64
- " session-id: %" PRIu64,
- mgmt_txn_reqs_count(&txn->set_cfg_reqs), txn->txn_id,
- txn->session_id);
+ __dbg("Processing %zu SET_CONFIG requests txn-id:%" PRIu64
+ " session-id: %" PRIu64,
+ mgmt_txn_reqs_count(&txn->set_cfg_reqs), txn->txn_id,
+ txn->session_id);
FOREACH_TXN_REQ_IN_LIST (&txn->set_cfg_reqs, txn_req) {
assert(txn_req->req_event == MGMTD_TXN_PROC_SETCFG);
/* We expect the user to have locked the DST DS */
if (!mgmt_ds_is_locked(txn_req->req.set_cfg->dst_ds_ctx,
txn->session_id)) {
- MGMTD_TXN_ERR("DS %u not locked for implicit commit txn-id: %" PRIu64
- " session-id: %" PRIu64 " err: %s",
- txn_req->req.set_cfg->dst_ds_id,
- txn->txn_id, txn->session_id,
- strerror(ret));
+ __log_err("DS %u not locked for implicit commit txn-id: %" PRIu64
+ " session-id: %" PRIu64 " err: %s",
+ txn_req->req.set_cfg->dst_ds_id,
+ txn->txn_id, txn->session_id,
+ strerror(ret));
mgmt_fe_send_set_cfg_reply(
txn->session_id, txn->txn_id,
txn_req->req.set_cfg->ds_id,
txn_req->req_id,
MGMTD_SUCCESS, NULL,
false) != 0) {
- MGMTD_TXN_ERR("Failed to send SET_CONFIG_REPLY txn-id %" PRIu64
- " session-id: %" PRIu64,
- txn->txn_id, txn->session_id);
+ __log_err("Failed to send SET_CONFIG_REPLY txn-id %" PRIu64
+ " session-id: %" PRIu64,
+ txn->txn_id, txn->session_id);
}
mgmt_txn_process_set_cfg_done:
left = mgmt_txn_reqs_count(&txn->set_cfg_reqs);
if (left) {
- MGMTD_TXN_DBG("Processed maximum number of Set-Config requests (%d/%d/%d). Rescheduling for rest.",
- num_processed, MGMTD_TXN_MAX_NUM_SETCFG_PROC,
- (int)left);
+ __dbg("Processed maximum number of Set-Config requests (%d/%d/%d). Rescheduling for rest.",
+ num_processed, MGMTD_TXN_MAX_NUM_SETCFG_PROC, (int)left);
mgmt_txn_register_event(txn, MGMTD_TXN_PROC_SETCFG);
}
}
txn->commit_cfg_req->req.commit_cfg
.validate_only,
result, error_if_any) != 0) {
- MGMTD_TXN_ERR("Failed to send COMMIT-CONFIG-REPLY txn-id: %" PRIu64
- " session-id: %" PRIu64,
- txn->txn_id, txn->session_id);
+ __log_err("Failed to send COMMIT-CONFIG-REPLY txn-id: %" PRIu64
+ " session-id: %" PRIu64,
+ txn->txn_id, txn->session_id);
}
if (txn->commit_cfg_req->req.commit_cfg.implicit && txn->session_id &&
success ? MGMTD_SUCCESS
: MGMTD_INTERNAL_ERROR,
error_if_any, true) != 0) {
- MGMTD_TXN_ERR("Failed to send SET-CONFIG-REPLY txn-id: %" PRIu64
- " session-id: %" PRIu64,
- txn->txn_id, txn->session_id);
+ __log_err("Failed to send SET-CONFIG-REPLY txn-id: %" PRIu64
+ " session-id: %" PRIu64,
+ txn->txn_id, txn->session_id);
}
if (success) {
{
enum mgmt_be_client_id id;
- MGMTD_TXN_DBG("txn-id: %" PRIu64 ", Phase '%s'",
- txn->txn_id, mgmt_txn_commit_phase_str(txn));
+ __dbg("txn-id: %" PRIu64 ", Phase '%s'", txn->txn_id,
+ mgmt_txn_commit_phase_str(txn));
/*
* Check if all clients has moved to next phase or not.
*/
cmtcfg_req->phase++;
- MGMTD_TXN_DBG("Move entire txn-id: %" PRIu64 " to phase '%s'",
- txn->txn_id, mgmt_txn_commit_phase_str(txn));
+ __dbg("Move entire txn-id: %" PRIu64 " to phase '%s'", txn->txn_id,
+ mgmt_txn_commit_phase_str(txn));
mgmt_txn_register_event(txn, MGMTD_TXN_PROC_COMMITCFG);
if (!value)
value = (char *)MGMTD_BE_CONTAINER_NODE_VAL;
- MGMTD_TXN_DBG("XPATH: %s, Value: '%s'", xpath,
- value ? value : "NIL");
+ __dbg("XPATH: %s, Value: '%s'", xpath, value ? value : "NIL");
clients = mgmt_be_interested_clients(xpath, true);
batch->value[batch->num_cfg_data].encoded_str_val =
value;
- MGMTD_TXN_DBG(" -- %s, batch item:%d", adapter->name,
- (int)batch->num_cfg_data);
+ __dbg(" -- %s, batch item:%d", adapter->name,
+ (int)batch->num_cfg_data);
batch->num_cfg_data++;
num_chgs++;
snprintf(err_buf, sizeof(err_buf),
"No validator module found for XPATH: '%s",
xpath);
- MGMTD_TXN_ERR("***** %s", err_buf);
+ __log_err("***** %s", err_buf);
}
cmtcfg_req->clients |= chg_clients;
* come back.
*/
- MGMTD_TXN_DBG("txn-id: %" PRIu64 " session-id: %" PRIu64
- " Phase '%s'",
- txn->txn_id, txn->session_id,
- mgmt_txn_commit_phase_str(txn));
+ __dbg("txn-id: %" PRIu64 " session-id: %" PRIu64 " Phase '%s'",
+ txn->txn_id, txn->session_id, mgmt_txn_commit_phase_str(txn));
return 0;
}
(void)mgmt_txn_send_commit_cfg_reply(
txn, MGMTD_INTERNAL_ERROR,
"Internal Error! Could not send config data to backend!");
- MGMTD_TXN_ERR("Could not send CFGDATA_CREATE txn-id: %" PRIu64
- " to client '%s", txn->txn_id, adapter->name);
+ __log_err("Could not send CFGDATA_CREATE txn-id: %" PRIu64
+ " to client '%s",
+ txn->txn_id, adapter->name);
return -1;
}
if (!txn->commit_cfg_req)
return;
- MGMTD_TXN_ERR("Backend timeout txn-id: %" PRIu64 " aborting commit",
- txn->txn_id);
+ __log_err("Backend timeout txn-id: %" PRIu64 " aborting commit",
+ txn->txn_id);
/*
* Send a COMMIT_CONFIG_REPLY with failure.
mgmt_txn_req_free(&txn_req);
if (ret) {
- MGMTD_TXN_ERR("Error sending the results of GETTREE for txn-id %" PRIu64
- " req_id %" PRIu64 " to requested type %u",
- txn->txn_id, req_id, get_tree->result_type);
+ __log_err("Error sending the results of GETTREE for txn-id %" PRIu64
+ " req_id %" PRIu64 " to requested type %u",
+ txn->txn_id, req_id, get_tree->result_type);
(void)mgmt_fe_adapter_txn_error(txn->txn_id, req_id, false, ret,
"Error converting results of GETTREE");
assert(txn->type == MGMTD_TXN_TYPE_SHOW);
- MGMTD_TXN_ERR("Backend timeout txn-id: %" PRIu64 " ending get-tree",
- txn->txn_id);
+ __log_err("Backend timeout txn-id: %" PRIu64 " ending get-tree",
+ txn->txn_id);
/*
* Send a get-tree data reply.
txn = (struct mgmt_txn_ctx *)EVENT_ARG(thread);
assert(txn);
- MGMTD_TXN_DBG("Processing COMMIT_CONFIG for txn-id: %" PRIu64
- " session-id: %" PRIu64 " Phase '%s'",
- txn->txn_id, txn->session_id,
- mgmt_txn_commit_phase_str(txn));
+ __dbg("Processing COMMIT_CONFIG for txn-id: %" PRIu64
+ " session-id: %" PRIu64 " Phase '%s'",
+ txn->txn_id, txn->session_id, mgmt_txn_commit_phase_str(txn));
assert(txn->commit_cfg_req);
cmtcfg_req = &txn->commit_cfg_req->req.commit_cfg;
* Backend by now.
*/
#ifndef MGMTD_LOCAL_VALIDATIONS_ENABLED
- MGMTD_TXN_DBG("txn-id: %" PRIu64 " session-id: %" PRIu64
- " trigger sending CFG_VALIDATE_REQ to all backend clients",
- txn->txn_id, txn->session_id);
+ __dbg("txn-id: %" PRIu64 " session-id: %" PRIu64
+ " trigger sending CFG_VALIDATE_REQ to all backend clients",
+ txn->txn_id, txn->session_id);
#else /* ifndef MGMTD_LOCAL_VALIDATIONS_ENABLED */
- MGMTD_TXN_DBG("txn-id: %" PRIu64 " session-id: %" PRIu64
- " trigger sending CFG_APPLY_REQ to all backend clients",
- txn->txn_id, txn->session_id);
+ __dbg("txn-id: %" PRIu64 " session-id: %" PRIu64
+ " trigger sending CFG_APPLY_REQ to all backend clients",
+ txn->txn_id, txn->session_id);
#endif /* ifndef MGMTD_LOCAL_VALIDATIONS_ENABLED */
break;
case MGMTD_COMMIT_PHASE_APPLY_CFG:
data_reply->next_indx = (!get_reply->last_batch ? get_req->total_reply
: -1);
- MGMTD_TXN_DBG("Sending %zu Get-Config/Data replies next-index:%" PRId64,
- data_reply->n_data, data_reply->next_indx);
+ __dbg("Sending %zu Get-Config/Data replies next-index:%" PRId64,
+ data_reply->n_data, data_reply->next_indx);
switch (txn_req->req_event) {
case MGMTD_TXN_PROC_GETCFG:
txn_req->txn->txn_id, get_req->ds_id,
txn_req->req_id, MGMTD_SUCCESS,
data_reply, NULL) != 0) {
- MGMTD_TXN_ERR("Failed to send GET-CONFIG-REPLY txn-id: %" PRIu64
- " session-id: %" PRIu64
- " req-id: %" PRIu64,
- txn_req->txn->txn_id,
- txn_req->txn->session_id, txn_req->req_id);
+ __log_err("Failed to send GET-CONFIG-REPLY txn-id: %" PRIu64
+ " session-id: %" PRIu64 " req-id: %" PRIu64,
+ txn_req->txn->txn_id,
+ txn_req->txn->session_id, txn_req->req_id);
}
break;
case MGMTD_TXN_PROC_SETCFG:
case MGMTD_TXN_PROC_GETTREE:
case MGMTD_TXN_GETTREE_TIMEOUT:
case MGMTD_TXN_COMMITCFG_TIMEOUT:
- MGMTD_TXN_ERR("Invalid Txn-Req-Event %u", txn_req->req_event);
+ __log_err("Invalid Txn-Req-Event %u", txn_req->req_event);
break;
}
get_reply->num_reply++;
get_req->total_reply++;
- MGMTD_TXN_DBG(" [%d] XPATH: '%s', Value: '%s'", get_req->total_reply,
- data->xpath, data_value->encoded_str_val);
+ __dbg(" [%d] XPATH: '%s', Value: '%s'", get_req->total_reply,
+ data->xpath, data_value->encoded_str_val);
if (get_reply->num_reply == MGMTD_MAX_NUM_DATA_REPLY_IN_BATCH)
mgmt_txn_send_getcfg_reply_data(txn_req, get_req);
*/
get_reply = get_data->reply;
for (indx = 0; indx < get_data->num_xpaths; indx++) {
- MGMTD_TXN_DBG("Trying to get all data under '%s'",
- get_data->xpaths[indx]);
+ __dbg("Trying to get all data under '%s'",
+ get_data->xpaths[indx]);
mgmt_init_get_data_reply(get_reply);
/*
* mgmt_ds_iter_data works on path prefixes, but the user may
get_data->xpaths[indx],
txn_iter_get_config_data_cb,
(void *)txn_req) == -1) {
- MGMTD_TXN_DBG("Invalid Xpath '%s",
- get_data->xpaths[indx]);
+ __dbg("Invalid Xpath '%s", get_data->xpaths[indx]);
mgmt_fe_send_get_reply(txn->session_id, txn->txn_id,
get_data->ds_id, txn_req->req_id,
MGMTD_INTERNAL_ERROR, NULL,
"Invalid xpath");
goto mgmt_txn_get_config_failed;
}
- MGMTD_TXN_DBG("Got %d remaining data-replies for xpath '%s'",
- get_reply->num_reply, get_data->xpaths[indx]);
+ __dbg("Got %d remaining data-replies for xpath '%s'",
+ get_reply->num_reply, get_data->xpaths[indx]);
get_reply->last_batch = true;
mgmt_txn_send_getcfg_reply_data(txn_req, get_data);
}
txn = (struct mgmt_txn_ctx *)EVENT_ARG(thread);
assert(txn);
- MGMTD_TXN_DBG("Processing %zu GET_CONFIG requests txn-id: %" PRIu64
- " session-id: %" PRIu64,
- mgmt_txn_reqs_count(&txn->get_cfg_reqs), txn->txn_id,
- txn->session_id);
+ __dbg("Processing %zu GET_CONFIG requests txn-id: %" PRIu64
+ " session-id: %" PRIu64,
+ mgmt_txn_reqs_count(&txn->get_cfg_reqs), txn->txn_id,
+ txn->session_id);
FOREACH_TXN_REQ_IN_LIST (&txn->get_cfg_reqs, txn_req) {
error = false;
assert(cfg_root);
if (mgmt_txn_get_config(txn, txn_req, cfg_root) != 0) {
- MGMTD_TXN_ERR("Unable to retrieve config from DS %d txn-id: %" PRIu64
- " session-id: %" PRIu64
- " req-id: %" PRIu64,
- txn_req->req.get_data->ds_id, txn->txn_id,
- txn->session_id, txn_req->req_id);
+ __log_err("Unable to retrieve config from DS %d txn-id: %" PRIu64
+ " session-id: %" PRIu64 " req-id: %" PRIu64,
+ txn_req->req.get_data->ds_id, txn->txn_id,
+ txn->session_id, txn_req->req_id);
error = true;
}
}
if (mgmt_txn_reqs_count(&txn->get_cfg_reqs)) {
- MGMTD_TXN_DBG("Processed maximum number of Get-Config requests (%d/%d). Rescheduling for rest.",
- num_processed, MGMTD_TXN_MAX_NUM_GETCFG_PROC);
+ __dbg("Processed maximum number of Get-Config requests (%d/%d). Rescheduling for rest.",
+ num_processed, MGMTD_TXN_MAX_NUM_GETCFG_PROC);
mgmt_txn_register_event(txn, MGMTD_TXN_PROC_GETCFG);
}
}
txn->txn_id = mgmt_txn_mm->next_txn_id++;
hash_get(mgmt_txn_mm->txn_hash, txn, hash_alloc_intern);
- MGMTD_TXN_DBG("Added new '%s' txn-id: %" PRIu64,
- mgmt_txn_type2str(type), txn->txn_id);
+ __dbg("Added new '%s' txn-id: %" PRIu64,
+ mgmt_txn_type2str(type), txn->txn_id);
if (type == MGMTD_TXN_TYPE_CONFIG)
mgmt_txn_mm->cfg_txn = txn;
static void mgmt_txn_lock(struct mgmt_txn_ctx *txn, const char *file, int line)
{
txn->refcount++;
- MGMTD_TXN_DBG("%s:%d --> Lock %s txn-id: %" PRIu64 " refcnt: %d", file,
- line, mgmt_txn_type2str(txn->type), txn->txn_id,
- txn->refcount);
+ __dbg("%s:%d --> Lock %s txn-id: %" PRIu64 " refcnt: %d", file, line,
+ mgmt_txn_type2str(txn->type), txn->txn_id, txn->refcount);
}
static void mgmt_txn_unlock(struct mgmt_txn_ctx **txn, const char *file,
assert(*txn && (*txn)->refcount);
(*txn)->refcount--;
- MGMTD_TXN_DBG("%s:%d --> Unlock %s txn-id: %" PRIu64 " refcnt: %d",
- file, line, mgmt_txn_type2str((*txn)->type),
- (*txn)->txn_id, (*txn)->refcount);
+ __dbg("%s:%d --> Unlock %s txn-id: %" PRIu64 " refcnt: %d", file, line,
+ mgmt_txn_type2str((*txn)->type), (*txn)->txn_id, (*txn)->refcount);
if (!(*txn)->refcount) {
if ((*txn)->type == MGMTD_TXN_TYPE_CONFIG)
if (mgmt_txn_mm->cfg_txn == *txn)
hash_release(mgmt_txn_mm->txn_hash, *txn);
mgmt_txns_del(&mgmt_txn_mm->txn_list, *txn);
- MGMTD_TXN_DBG("Deleted %s txn-id: %" PRIu64
- " session-id: %" PRIu64,
- mgmt_txn_type2str((*txn)->type), (*txn)->txn_id,
- (*txn)->session_id);
+ __dbg("Deleted %s txn-id: %" PRIu64 " session-id: %" PRIu64,
+ mgmt_txn_type2str((*txn)->type), (*txn)->txn_id,
+ (*txn)->session_id);
XFREE(MTYPE_MGMTD_TXN, *txn);
}
return -1;
if (implicit_commit && mgmt_txn_reqs_count(&txn->set_cfg_reqs)) {
- MGMTD_TXN_ERR(
+ __log_err(
"For implicit commit config only one SETCFG-REQ can be allowed!");
return -1;
}
continue;
}
- MGMTD_TXN_DBG("XPath: '%s', Value: '%s'",
- cfg_req[indx]->data->xpath,
- (cfg_req[indx]->data->value &&
- cfg_req[indx]->data->value->encoded_str_val
- ? cfg_req[indx]->data->value->encoded_str_val
- : "NULL"));
+ __dbg("XPath: '%s', Value: '%s'", cfg_req[indx]->data->xpath,
+ (cfg_req[indx]->data->value &&
+ cfg_req[indx]->data->value->encoded_str_val
+ ? cfg_req[indx]->data->value->encoded_str_val
+ : "NULL"));
strlcpy(cfg_chg->xpath, cfg_req[indx]->data->xpath,
sizeof(cfg_chg->xpath));
cfg_chg->value =
->data->value->encoded_str_val)
: NULL);
if (cfg_chg->value)
- MGMTD_TXN_DBG("Allocated value at %p ==> '%s'",
- cfg_chg->value, cfg_chg->value);
+ __dbg("Allocated value at %p ==> '%s'", cfg_chg->value,
+ cfg_chg->value);
(*num_chgs)++;
}
return -1;
if (txn->commit_cfg_req) {
- MGMTD_TXN_ERR("Commit already in-progress txn-id: %" PRIu64
- " session-id: %" PRIu64 ". Cannot start another",
- txn->txn_id, txn->session_id);
+ __log_err("Commit already in-progress txn-id: %" PRIu64
+ " session-id: %" PRIu64 ". Cannot start another",
+ txn->txn_id, txn->session_id);
return -1;
}
*/
txn = mgmt_txn_create_new(0, MGMTD_TXN_TYPE_CONFIG);
if (!txn) {
- MGMTD_TXN_ERR("Failed to create CONFIG Transaction for downloading CONFIGs for client '%s'",
- adapter->name);
+ __log_err("Failed to create CONFIG Transaction for downloading CONFIGs for client '%s'",
+ adapter->name);
nb_config_diff_del_changes(adapter_cfgs);
return -1;
}
- MGMTD_TXN_DBG("Created initial txn-id: %" PRIu64
- " for BE client '%s'",
- txn->txn_id, adapter->name);
+ __dbg("Created initial txn-id: %" PRIu64 " for BE client '%s'",
+ txn->txn_id, adapter->name);
/*
* Set the changeset for transaction to commit and trigger the
* commit request.
cmtcfg_req = &txn->commit_cfg_req->req.commit_cfg;
if (!success) {
- MGMTD_TXN_ERR("CFGDATA_CREATE_REQ sent to '%s' failed txn-id: %" PRIu64
- " err: %s", adapter->name, txn->txn_id,
- error_if_any ? error_if_any : "None");
+ __log_err("CFGDATA_CREATE_REQ sent to '%s' failed txn-id: %" PRIu64
+ " err: %s",
+ adapter->name, txn->txn_id,
+ error_if_any ? error_if_any : "None");
mgmt_txn_send_commit_cfg_reply(
txn, MGMTD_INTERNAL_ERROR,
error_if_any
return 0;
}
- MGMTD_TXN_DBG("CFGDATA_CREATE_REQ sent to '%s' was successful txn-id: %" PRIu64
- " err: %s", adapter->name, txn->txn_id,
- error_if_any ? error_if_any : "None");
+ __dbg("CFGDATA_CREATE_REQ sent to '%s' was successful txn-id: %" PRIu64
+ " err: %s",
+ adapter->name, txn->txn_id, error_if_any ? error_if_any : "None");
cmtcfg_req->be_phase[adapter->id] = MGMTD_COMMIT_PHASE_APPLY_CFG;
cmtcfg_req = &txn->commit_cfg_req->req.commit_cfg;
if (!success) {
- MGMTD_TXN_ERR("CFGDATA_APPLY_REQ sent to '%s' failed txn-id: %" PRIu64
- " err: %s",
- adapter->name, txn->txn_id,
- error_if_any ? error_if_any : "None");
+ __log_err("CFGDATA_APPLY_REQ sent to '%s' failed txn-id: %" PRIu64
+ " err: %s",
+ adapter->name, txn->txn_id,
+ error_if_any ? error_if_any : "None");
mgmt_txn_send_commit_cfg_reply(
txn, MGMTD_INTERNAL_ERROR,
error_if_any
for (indx = 0;
indx < num_reqs && indx < MGMTD_MAX_NUM_DATA_REPLY_IN_BATCH;
indx++) {
- MGMTD_TXN_DBG("XPath: '%s'", data_req[indx]->data->xpath);
+ __dbg("XPath: '%s'", data_req[indx]->data->xpath);
txn_req->req.get_data->xpaths[indx] =
strdup(data_req[indx]->data->xpath);
txn_req->req.get_data->num_xpaths++;
FOREACH_BE_CLIENT_BITS (id, clients) {
ret = mgmt_be_send_native(id, msg);
if (ret) {
- MGMTD_TXN_ERR("Could not send get-tree message to backend client %s",
- mgmt_be_client_id2name(id));
+ __log_err("Could not send get-tree message to backend client %s",
+ mgmt_be_client_id2name(id));
continue;
}
- MGMTD_TXN_DBG("Sent get-tree req to backend client %s",
- mgmt_be_client_id2name(id));
+ __dbg("Sent get-tree req to backend client %s",
+ mgmt_be_client_id2name(id));
/* record that we sent the request to the client */
get_tree->sent_clients |= (1u << id);
struct mgmt_txn_req *txn_req;
if (!txn) {
- MGMTD_TXN_ERR("Error reply from %s cannot find txn-id %" PRIu64,
- adapter->name, txn_id);
+ __log_err("Error reply from %s cannot find txn-id %" PRIu64,
+ adapter->name, txn_id);
return -1;
}
if (txn_req->req_id == req_id)
break;
if (!txn_req) {
- MGMTD_TXN_ERR("Error reply from %s for txn-id %" PRIu64
- " cannot find req_id %" PRIu64,
- adapter->name, txn_id, req_id);
+ __log_err("Error reply from %s for txn-id %" PRIu64
+ " cannot find req_id %" PRIu64,
+ adapter->name, txn_id, req_id);
return -1;
}
- MGMTD_TXN_ERR("Error reply from %s for txn-id %" PRIu64
- " req_id %" PRIu64,
- adapter->name, txn_id, req_id);
+ __log_err("Error reply from %s for txn-id %" PRIu64 " req_id %" PRIu64,
+ adapter->name, txn_id, req_id);
switch (txn_req->req_event) {
case MGMTD_TXN_PROC_GETTREE:
LY_ERR err;
if (!txn) {
- MGMTD_TXN_ERR("GETTREE reply from %s for a missing txn-id %" PRIu64,
- adapter->name, txn_id);
+ __log_err("GETTREE reply from %s for a missing txn-id %" PRIu64,
+ adapter->name, txn_id);
return -1;
}
if (txn_req->req_id == req_id)
break;
if (!txn_req) {
- MGMTD_TXN_ERR("GETTREE reply from %s for txn-id %" PRIu64
- " missing req_id %" PRIu64,
- adapter->name, txn_id, req_id);
+ __log_err("GETTREE reply from %s for txn-id %" PRIu64
+ " missing req_id %" PRIu64,
+ adapter->name, txn_id, req_id);
return -1;
}
LYD_PARSE_STRICT | LYD_PARSE_ONLY,
0 /*LYD_VALIDATE_OPERATIONAL*/, &tree);
if (err) {
- MGMTD_TXN_ERR("GETTREE reply from %s for txn-id %" PRIu64
- " req_id %" PRIu64
- " error parsing result of type %u",
- adapter->name, txn_id, req_id,
- data_msg->result_type);
+ __log_err("GETTREE reply from %s for txn-id %" PRIu64
+ " req_id %" PRIu64 " error parsing result of type %u",
+ adapter->name, txn_id, req_id, data_msg->result_type);
}
if (!err) {
/* TODO: we could merge ly_errs here if it's not binary */
err = lyd_merge_siblings(&get_tree->client_results,
tree, LYD_MERGE_DESTRUCT);
if (err) {
- MGMTD_TXN_ERR("GETTREE reply from %s for txn-id %" PRIu64
- " req_id %" PRIu64 " error merging result",
- adapter->name, txn_id, req_id);
+ __log_err("GETTREE reply from %s for txn-id %" PRIu64
+ " req_id %" PRIu64 " error merging result",
+ adapter->name, txn_id, req_id);
}
}
if (!get_tree->partial_error)
*/
txn = mgmt_txn_create_new(0, MGMTD_TXN_TYPE_CONFIG);
if (!txn) {
- MGMTD_TXN_ERR(
+ __log_err(
"Failed to create CONFIG Transaction for downloading CONFIGs");
return -1;
}
- MGMTD_TXN_DBG("Created rollback txn-id: %" PRIu64, txn->txn_id);
+ __dbg("Created rollback txn-id: %" PRIu64, txn->txn_id);
/*
* Set the changeset for transaction to commit and trigger the commit