/** * Handle session context destroy. * * Handles TS_EVENT_HTTP_SSN_CLOSE (session close) close event from the * ATS. * * @param[in,out] ctx session context */ static void tsib_ssn_ctx_destroy(tsib_ssn_ctx * ssndata) { if (ssndata == NULL) { return; } /* To avoid the risk of sequencing issues with this coming before TXN_CLOSE, * we just mark the session as closing, but leave actually closing it * for the TXN_CLOSE if there's a TXN */ if (ssndata->txn_count == 0) { /* No outstanding TXN_CLOSE to come. */ if (ssndata->iconn != NULL) { ib_conn_t *conn = ssndata->iconn; ssndata->iconn = NULL; tx_list_destroy(conn); TSDebug("ironbee", "tsib_ssn_ctx_destroy: calling ib_state_notify_conn_closed()"); ib_state_notify_conn_closed(conn->ib, conn); TSDebug("ironbee", "CONN DESTROY: conn=%p", conn); ib_conn_destroy(conn); } /* Store off the continuation pointer */ TSCont contp = ssndata->contp; TSContDataSet(contp, NULL); ssndata->contp = NULL; TSContDestroy(contp); TSfree(ssndata); } else { ssndata->closing = 1; } }
/** * nginx connection pool cleanup function to notify IronBee * and destroy the ironbee connection object. * * @param[in] arg the connection rec */ static void conn_end(void *arg) { ngxib_conn_t *conn = arg; ib_state_notify_conn_closed(conn->engine, conn->iconn); ib_conn_destroy(conn->iconn); ngxib_release_engine(conn->engine, conn->log); }
static void ib_ssn_ctx_destroy(ib_ssn_ctx * data) { if (data) { if (data->iconn) ib_state_notify_conn_closed(ironbee, data->iconn); TSfree(data); } }
/** * Handle transaction context destroy. * * Handles TS_EVENT_HTTP_TXN_CLOSE (transaction close) close event from the * ATS. * * @param[in,out] ctx Transaction context */ static void tsib_txn_ctx_destroy(tsib_txn_ctx *txndata) { if (txndata == NULL) { return; } ib_tx_t *tx = txndata->tx; tsib_ssn_ctx *ssndata = txndata->ssn; assert(tx != NULL); assert(ssndata != NULL); txndata->tx = NULL; ib_log_debug_tx(tx, "TX DESTROY: conn=>%p tx_count=%zd tx=%p id=%s txn_count=%d", tx->conn, tx->conn->tx_count, tx, tx->id, ssndata->txn_count); tx_finish(tx); ib_lock_lock(ssndata->mutex); ib_tx_destroy(tx); txndata->ssn = NULL; /* Decrement the txn count on the ssn, and destroy ssn if it's closing. * We trust TS not to create more TXNs after signalling SSN close! */ if (ssndata->closing && ssndata->txn_count <= 1) { if (ssndata->iconn) { tx_list_destroy(ssndata->iconn); ib_conn_t *conn = ssndata->iconn; ib_engine_t *ib = conn->ib; ssndata->iconn = NULL; TSDebug("ironbee", "tsib_txn_ctx_destroy: calling ib_state_notify_conn_closed()"); ib_state_notify_conn_closed(ib, conn); TSDebug("ironbee", "CONN DESTROY: conn=%p", conn); ib_conn_destroy(conn); } TSContDataSet(ssndata->contp, NULL); TSContDestroy(ssndata->contp); ib_lock_unlock(ssndata->mutex); ib_lock_destroy_malloc(ssndata->mutex); TSfree(ssndata); } else { --(ssndata->txn_count); ib_lock_unlock(ssndata->mutex); } TSfree(txndata); }
/** * @internal * * Called by the connection cleanup routine, handling a disconnect. */ static apr_status_t ironbee_disconnection(void *data) { conn_rec *c= (conn_rec *)data; ironbee_conn_context *ctx_in; if (data == NULL) { return OK; } ctx_in = (ironbee_conn_context *)apr_table_get(c->notes, "IRONBEE_CTX_IN"); ib_state_notify_conn_closed(ironbee, ctx_in->iconn); return OK; }