示例#1
0
/**
 * Encode/send an error response
 *
 * Part of the public interface
 *
 * @param tids
 * @param req
 * @param err_msg
 * @return
 */
int tids_send_err_response (TIDS_INSTANCE *tids, TID_REQ *req, const char *err_msg) {
  TID_RESP *resp = NULL;
  int rc = 0;

  if ((!tids) || (!req) || (!err_msg)) {
    tr_debug("tids_send_err_response: Invalid parameters.");
    return -1;
  }

  /* If we already sent a response, don't send another no matter what. */
  if (req->resp_sent)
    return 0;

  if (NULL == (resp = tids_create_response(req, req))) {
    tr_crit("tids_send_err_response: Can't create response.");
    return -1;
  }

  /* mark this as an error response, and include the error message */
  resp->result = TID_ERROR;
  resp->err_msg = tr_new_name((char *)err_msg);
  resp->error_path = req->path;

  rc = tids_send_response(tids, req, resp);

  tid_resp_free(resp);
  return rc;
}
示例#2
0
void tr_msg_free_decoded(TR_MSG *msg)
{
  if (msg) {
    switch (msg->msg_type) {
    case TID_REQUEST:
      tid_req_free(tr_msg_get_req(msg));
      break;
    case TID_RESPONSE:
      tid_resp_free(tr_msg_get_resp(msg));
      break;
    case TRP_UPDATE:
      trp_upd_free(tr_msg_get_trp_upd(msg));
      break;
    case TRP_REQUEST:
      trp_req_free(tr_msg_get_trp_req(msg));
    default:
      break;
    }
    free (msg);
  }
}