From c4f3f19ce33e24fb8f348cad6f8917979b6ced27 Mon Sep 17 00:00:00 2001 From: Sanjay Singh Date: Thu, 27 May 2021 16:41:27 -0700 Subject: [PATCH 1/6] Update TSHttpTxnAborted API to distinguish client aborts --- include/ts/ts.h | 3 ++- plugins/esi/esi.cc | 3 ++- src/traffic_server/InkAPI.cc | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) 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/src/traffic_server/InkAPI.cc b/src/traffic_server/InkAPI.cc index db2d1544551..5aeb8be2e56 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); + *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; From 39e825ab0994adc93c6ebbb30f13222c5301563d Mon Sep 17 00:00:00 2001 From: Sanjay Singh Date: Mon, 7 Jun 2021 16:58:36 -0700 Subject: [PATCH 2/6] Fixed the TSHttpTxnAborted call in the lua API --- plugins/lua/ts_lua_http.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/lua/ts_lua_http.c b/plugins/lua/ts_lua_http.c index 3cd4aec0f91..f93c646687f 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); From 052b31fca99d8b1920b51e68c00ac10b6f672f61 Mon Sep 17 00:00:00 2001 From: Sanjay Singh Date: Mon, 7 Jun 2021 17:11:24 -0700 Subject: [PATCH 3/6] Fixed function call with reference of the variable --- plugins/lua/ts_lua_http.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/lua/ts_lua_http.c b/plugins/lua/ts_lua_http.c index f93c646687f..74687e2a18d 100644 --- a/plugins/lua/ts_lua_http.c +++ b/plugins/lua/ts_lua_http.c @@ -768,7 +768,7 @@ ts_lua_http_is_aborted(lua_State *L) GET_HTTP_CONTEXT(http_ctx, L); bool client_abort = false; - if (TSHttpTxnAborted(http_ctx->txnp), client_abort) { + if (TSHttpTxnAborted(http_ctx->txnp), &client_abort) { lua_pushnumber(L, 1); } else { lua_pushnumber(L, 0); From 142944d097b9ea99f510b528d660fc1bf6484dbc Mon Sep 17 00:00:00 2001 From: Sanjay Singh Date: Tue, 8 Jun 2021 11:05:53 -0700 Subject: [PATCH 4/6] fixing the function call --- plugins/lua/ts_lua_http.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/lua/ts_lua_http.c b/plugins/lua/ts_lua_http.c index 74687e2a18d..e9ee63d6ad5 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); - bool client_abort = false; - if (TSHttpTxnAborted(http_ctx->txnp), &client_abort) { + //bool client_abort = false; + if (TSHttpTxnAborted(http_ctx->txnp, &client_abort)) { lua_pushnumber(L, 1); } else { lua_pushnumber(L, 0); From fff14d12412c0c69b6e453c482e548ec823e589f Mon Sep 17 00:00:00 2001 From: Sanjay Singh Date: Tue, 8 Jun 2021 12:33:00 -0700 Subject: [PATCH 5/6] fixing the function call --- plugins/lua/ts_lua_http.c | 2 +- src/traffic_server/InkAPI.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/lua/ts_lua_http.c b/plugins/lua/ts_lua_http.c index e9ee63d6ad5..8fd5a0395fe 100644 --- a/plugins/lua/ts_lua_http.c +++ b/plugins/lua/ts_lua_http.c @@ -767,7 +767,7 @@ ts_lua_http_is_aborted(lua_State *L) ts_lua_http_ctx *http_ctx; GET_HTTP_CONTEXT(http_ctx, L); - //bool client_abort = false; + bool client_abort = false; if (TSHttpTxnAborted(http_ctx->txnp, &client_abort)) { lua_pushnumber(L, 1); } else { diff --git a/src/traffic_server/InkAPI.cc b/src/traffic_server/InkAPI.cc index 5aeb8be2e56..b015eea4645 100644 --- a/src/traffic_server/InkAPI.cc +++ b/src/traffic_server/InkAPI.cc @@ -5681,7 +5681,7 @@ TSHttpTxnAborted(TSHttpTxn txnp, bool *client_abort) sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS); *client_abort = false; - HttpSM *sm = (HttpSM *)txnp; + 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: From 21bcb5af552fbea46834b31340da7f30b11a0177 Mon Sep 17 00:00:00 2001 From: Sanjay Singh Date: Tue, 15 Jun 2021 15:22:39 -0700 Subject: [PATCH 6/6] Updating the api docs for TSHttpTxnAborted --- doc/developer-guide/api/functions/TSHttpTxnAborted.en.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 -------------