Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion doc/developer-guide/api/functions/TSHttpTxnAborted.en.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Synopsis

#include <ts/ts.h>

.. c:function:: TSReturnCode TSHttpTxnAborted(TSHttpTxn txnp)
.. c:function:: TSReturnCode TSHttpTxnAborted(TSHttpTxn txnp, bool *client_abort)

Description
-----------
Expand All @@ -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
-------------

Expand Down
3 changes: 2 additions & 1 deletion include/ts/ts.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion plugins/esi/esi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/lua/ts_lua_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions src/traffic_server/InkAPI.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down