-/* $OpenBSD: application_agentx.c,v 1.12 2023/10/24 14:11:14 martijn Exp $ */
+/* $OpenBSD: application_agentx.c,v 1.13 2023/10/27 10:23:58 martijn Exp $ */
/*
* Copyright (c) 2022 Martijn van Duren <martijn@openbsd.org>
*
{
struct appl_agentx_session *session;
- event_del(&(conn->conn_rev));
- event_del(&(conn->conn_wev));
-
while ((session = TAILQ_FIRST(&(conn->conn_sessions))) != NULL) {
if (conn->conn_ax == NULL)
appl_agentx_session_free(session);
reason);
}
+ event_del(&(conn->conn_rev));
+ event_del(&(conn->conn_wev));
+
RB_REMOVE(appl_agentx_conns, &appl_agentx_conns, conn);
+ if (conn->conn_ax != NULL)
+ (void)ax_send(conn->conn_ax);
ax_free(conn->conn_ax);
if (conn->conn_backend)
fatalx("AgentX(%"PRIu32"): disappeared unexpected",
pdu->ap_header.aph_transactionid,
pdu->ap_header.aph_packetid, smi_getticks(),
APPL_ERROR_NOERROR, 0, NULL, 0);
- appl_agentx_send(-1, EV_WRITE, conn);
+ event_add(&(conn->conn_wev), NULL);
break;
case AX_PDU_TYPE_INDEXALLOCATE:
case AX_PDU_TYPE_INDEXDEALLOCATE:
APPL_ERROR_PROCESSINGERROR, 1,
pdu->ap_payload.ap_vbl.ap_varbind,
pdu->ap_payload.ap_vbl.ap_nvarbind);
- appl_agentx_send(-1, EV_WRITE, conn);
+ event_add(&(conn->conn_wev), NULL);
break;
case AX_PDU_TYPE_ADDAGENTCAPS:
case AX_PDU_TYPE_REMOVEAGENTCAPS:
pdu->ap_header.aph_transactionid,
pdu->ap_header.aph_packetid, smi_getticks(),
error, 0, NULL, 0);
- appl_agentx_send(-1, EV_WRITE, conn);
+ event_add(&(conn->conn_wev), NULL);
ax_pdu_free(pdu);
if (session == NULL || error != APPL_ERROR_PARSEERROR)
ax_response(conn->conn_ax, session->sess_id,
pdu->ap_header.aph_transactionid, pdu->ap_header.aph_packetid,
smi_getticks(), APPL_ERROR_NOERROR, 0, NULL, 0);
- appl_agentx_send(-1, EV_WRITE, conn);
+ event_add(&(conn->conn_wev), NULL);
return;
fail:
ax_response(conn->conn_ax, 0, pdu->ap_header.aph_transactionid,
pdu->ap_header.aph_packetid, 0, error, 0, NULL, 0);
- appl_agentx_send(-1, EV_WRITE, conn);
+ event_add(&(conn->conn_wev), NULL);
if (session != NULL)
free(session->sess_descr.aos_string);
free(session);
ax_response(conn->conn_ax, pdu->ap_header.aph_sessionid,
pdu->ap_header.aph_transactionid, pdu->ap_header.aph_packetid,
smi_getticks(), error, 0, NULL, 0);
- appl_agentx_send(-1, EV_WRITE, conn);
+ event_add(&(conn->conn_wev), NULL);
if (error == APPL_ERROR_NOERROR)
return;
session->sess_conn->conn_ax->ax_byteorder = session->sess_byteorder;
ax_close(session->sess_conn->conn_ax, session->sess_id,
(enum ax_close_reason) reason);
- appl_agentx_send(-1, EV_WRITE, session->sess_conn);
+ event_add(&(session->sess_conn->conn_wev), NULL);
strlcpy(name, session->sess_backend.ab_name, sizeof(name));
appl_agentx_session_free(session);
ax_response(session->sess_conn->conn_ax, session->sess_id,
pdu->ap_header.aph_transactionid, pdu->ap_header.aph_packetid,
smi_getticks(), error, 0, NULL, 0);
- appl_agentx_send(-1, EV_WRITE, session->sess_conn);
+ event_add(&(session->sess_conn->conn_wev), NULL);
}
void
ax_response(session->sess_conn->conn_ax, session->sess_id,
pdu->ap_header.aph_transactionid, pdu->ap_header.aph_packetid,
smi_getticks(), error, 0, NULL, 0);
- appl_agentx_send(-1, EV_WRITE, session->sess_conn);
+ event_add(&(session->sess_conn->conn_wev), NULL);
}
#define AX_PDU_FLAG_INDEX (AX_PDU_FLAG_NEW_INDEX | AX_PDU_FLAG_ANY_INDEX)
requestid, context, srl, nsr) == -1)
appl_response(backend, requestid, APPL_ERROR_GENERR, 1, vblist);
else
- appl_agentx_send(-1, EV_WRITE, session->sess_conn);
+ event_add(&(session->sess_conn->conn_wev), NULL);
free(srl);
if (context != NULL)
free(context->aos_string);
requestid, context, srl, nsr) == -1)
appl_response(backend, requestid, APPL_ERROR_GENERR, 1, vblist);
else
- appl_agentx_send(-1, EV_WRITE, session->sess_conn);
+ event_add(&(session->sess_conn->conn_wev), NULL);
free(srl);
if (context != NULL)
free(context->aos_string);