diff --git a/doc/developer-guide/api/functions/TSHttpTxnAborted.en.rst b/doc/developer-guide/api/functions/TSHttpTxnAborted.en.rst index afa0658a4a7..e5cef8503fe 100644 --- a/doc/developer-guide/api/functions/TSHttpTxnAborted.en.rst +++ b/doc/developer-guide/api/functions/TSHttpTxnAborted.en.rst @@ -28,7 +28,7 @@ Synopsis #include -.. c:function:: TSReturnCode TSHttpTxnAborted(TSHttpTxn txnp) +.. c:function:: TSReturnCode TSHttpTxnAborted(TSHttpTxn txnp, bool *client_abort) Description ----------- @@ -37,6 +37,10 @@ Description transaction is aborted. This function should be used to determine whether a transaction has been aborted before attempting to cache the results. +Broadly, transaction aborts can be classified into either client side aborts or +server side. To distinguish between these, we have another boolean parameter +which gets set to TRUE in case of client side aborts. + Return values ------------- diff --git a/include/ts/ts.h b/include/ts/ts.h index 61e7d45e251..3a11469a6e8 100644 --- a/include/ts/ts.h +++ b/include/ts/ts.h @@ -2356,10 +2356,11 @@ tsapi TSReturnCode TSAIOThreadNumSet(int thread_num); /** Check if transaction was aborted (due client/server errors etc.) + Client_abort is set as True, in case the abort was caused by the Client. @return 1 if transaction was aborted */ -tsapi TSReturnCode TSHttpTxnAborted(TSHttpTxn txnp); +tsapi TSReturnCode TSHttpTxnAborted(TSHttpTxn txnp, bool *client_abort); tsapi TSVConn TSVConnCreate(TSEventFunc event_funcp, TSMutex mutexp); tsapi TSVConn TSVConnFdCreate(int fd); diff --git a/plugins/esi/esi.cc b/plugins/esi/esi.cc index 9d223b5f997..67b6fe9e5e0 100644 --- a/plugins/esi/esi.cc +++ b/plugins/esi/esi.cc @@ -578,7 +578,8 @@ removeCacheKey(TSHttpTxn txnp) static void cacheNodeList(ContData *cont_data) { - if (TSHttpTxnAborted(cont_data->txnp) == TS_SUCCESS) { + bool client_abort; + if (TSHttpTxnAborted(cont_data->txnp, &client_abort) == TS_SUCCESS) { TSDebug(cont_data->debug_tag, "[%s] Not caching node list as txn has been aborted", __FUNCTION__); return; } diff --git a/plugins/lua/ts_lua_http.c b/plugins/lua/ts_lua_http.c index 3cd4aec0f91..8fd5a0395fe 100644 --- a/plugins/lua/ts_lua_http.c +++ b/plugins/lua/ts_lua_http.c @@ -767,8 +767,8 @@ ts_lua_http_is_aborted(lua_State *L) ts_lua_http_ctx *http_ctx; GET_HTTP_CONTEXT(http_ctx, L); - - if (TSHttpTxnAborted(http_ctx->txnp)) { + bool client_abort = false; + if (TSHttpTxnAborted(http_ctx->txnp, &client_abort)) { lua_pushnumber(L, 1); } else { lua_pushnumber(L, 0); diff --git a/src/traffic_server/InkAPI.cc b/src/traffic_server/InkAPI.cc index db2d1544551..b015eea4645 100644 --- a/src/traffic_server/InkAPI.cc +++ b/src/traffic_server/InkAPI.cc @@ -5676,16 +5676,18 @@ TSHttpTxnShutDown(TSHttpTxn txnp, TSEvent event) } TSReturnCode -TSHttpTxnAborted(TSHttpTxn txnp) +TSHttpTxnAborted(TSHttpTxn txnp, bool *client_abort) { sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS); - HttpSM *sm = (HttpSM *)txnp; + *client_abort = false; + HttpSM *sm = (HttpSM *)txnp; switch (sm->t_state.squid_codes.log_code) { case SQUID_LOG_ERR_CLIENT_ABORT: case SQUID_LOG_ERR_CLIENT_READ_ERROR: case SQUID_LOG_TCP_SWAPFAIL: // check for client abort and cache read error + *client_abort = true; return TS_SUCCESS; default: break;