ping
On Thu, 2021-09-09 at 21:49 +0200, Martijn van Duren wrote:
> When calling agentx_index_start we short-circuit the call to the agentx
> master when the index is dynamic. This is in accordance with the RFC.
> At the moment we don't do the same thing when calling
> agentx_index_close. Diff below addresses this.
>
> Largest part is a reindent of agentx_index_close_finalize.
>
> OK?
>
> martijn@
>
> Index: agentx.c
> ===================================================================
> RCS file: /cvs/src/lib/libagentx/agentx.c,v
> retrieving revision 1.10
> diff -u -p -r1.10 agentx.c
> --- agentx.c 2 Jun 2021 08:40:09 -0000 1.10
> +++ agentx.c 9 Sep 2021 19:47:52 -0000
> @@ -1818,6 +1818,9 @@ agentx_index_close(struct agentx_index *
> if (axs->axs_cstate == AX_CSTATE_WAITCLOSE)
> return 0;
>
> + if (axi->axi_type == AXI_TYPE_DYNAMIC)
> + return agentx_index_close_finalize(NULL, axi);
> +
> /* We might be able to bundle, but if we fail we'd have to reorganise */
> packetid = ax_indexdeallocate(ax->ax_ax, axs->axs_id,
> AGENTX_CONTEXT_CTX(axc), &(axi->axi_vb), 1);
> @@ -1849,55 +1852,58 @@ agentx_index_close_finalize(struct ax_pd
> __func__);
> #endif
>
> - if (pdu->ap_payload.ap_response.ap_error != AX_PDU_ERROR_NOERROR) {
> - agentx_log_axc_warnx(axc,
> - "index %s: couldn't deallocate: %s",
> - ax_oid2string(&(axi->axi_vb.avb_oid)),
> - ax_error2string(resp->ap_error));
> - agentx_reset(ax);
> - return -1;
> - }
> + if (pdu != NULL) {
> + if (pdu->ap_payload.ap_response.ap_error !=
> + AX_PDU_ERROR_NOERROR) {
> + agentx_log_axc_warnx(axc,
> + "index %s: couldn't deallocate: %s",
> + ax_oid2string(&(axi->axi_vb.avb_oid)),
> + ax_error2string(resp->ap_error));
> + agentx_reset(ax);
> + return -1;
> + }
>
> - if (resp->ap_nvarbind != 1) {
> - agentx_log_axc_warnx(axc,
> - "index %s: unexpected number of indices",
> - ax_oid2string(&(axr->axr_oid)));
> - agentx_reset(ax);
> - return -1;
> - }
> - if (resp->ap_varbindlist[0].avb_type != axi->axi_vb.avb_type) {
> - agentx_log_axc_warnx(axc, "index %s: unexpected index type",
> - ax_oid2string(&(axr->axr_oid)));
> - agentx_reset(ax);
> - return -1;
> - }
> - if (ax_oid_cmp(&(resp->ap_varbindlist[0].avb_oid),
> - &(axi->axi_vb.avb_oid)) != 0) {
> - agentx_log_axc_warnx(axc, "index %s: unexpected oid",
> - ax_oid2string(&(axr->axr_oid)));
> - agentx_reset(ax);
> - return -1;
> - }
> - switch (axi->axi_vb.avb_type) {
> - case AX_DATA_TYPE_INTEGER:
> - if (axi->axi_vb.avb_data.avb_int32 !=
> - resp->ap_varbindlist[0].avb_data.avb_int32) {
> + if (resp->ap_nvarbind != 1) {
> agentx_log_axc_warnx(axc,
> - "index %s: unexpected index value",
> + "index %s: unexpected number of indices",
> ax_oid2string(&(axr->axr_oid)));
> agentx_reset(ax);
> return -1;
> }
> - break;
> - default:
> - agentx_log_axc_fatalx(axc, "%s: Unsupported index type",
> - __func__);
> + if (resp->ap_varbindlist[0].avb_type != axi->axi_vb.avb_type) {
> + agentx_log_axc_warnx(axc, "index %s: unexpected index "
> + "type", ax_oid2string(&(axr->axr_oid)));
> + agentx_reset(ax);
> + return -1;
> + }
> + if (ax_oid_cmp(&(resp->ap_varbindlist[0].avb_oid),
> + &(axi->axi_vb.avb_oid)) != 0) {
> + agentx_log_axc_warnx(axc, "index %s: unexpected oid",
> + ax_oid2string(&(axr->axr_oid)));
> + agentx_reset(ax);
> + return -1;
> + }
> + switch (axi->axi_vb.avb_type) {
> + case AX_DATA_TYPE_INTEGER:
> + if (axi->axi_vb.avb_data.avb_int32 !=
> + resp->ap_varbindlist[0].avb_data.avb_int32) {
> + agentx_log_axc_warnx(axc,
> + "index %s: unexpected index value",
> + ax_oid2string(&(axr->axr_oid)));
> + agentx_reset(ax);
> + return -1;
> + }
> + break;
> + default:
> + agentx_log_axc_fatalx(axc, "%s: Unsupported index type",
> + __func__);
> + }
> +
> + agentx_log_axc_info(axc, "index %s: deallocated",
> + ax_oid2string(&(axi->axi_vb.avb_oid)));
> }
>
> axi->axi_cstate = AX_CSTATE_CLOSE;
> -
> - agentx_log_axc_info(axc, "index %s: deallocated",
> - ax_oid2string(&(axi->axi_vb.avb_oid)));
>
> if (axi->axi_dstate == AX_DSTATE_CLOSE) {
> agentx_index_free_finalize(axi);
>