Skip to content
Closed
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
8 changes: 4 additions & 4 deletions lib/atscppapi/src/utils_internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ using namespace atscppapi;

namespace
{
// This is the highest txn arg that can be used, we choose this
// value to minimize the likelihood of it causing any problems.
const int MAX_TXN_ARG = 15;
const int TRANSACTION_STORAGE_INDEX = MAX_TXN_ARG;
/// The index used to store required transaction based data.
int TRANSACTION_STORAGE_INDEX = -1;

void
resetTransactionHandles(Transaction &transaction, TSEvent event)
Expand Down Expand Up @@ -99,6 +97,8 @@ handleTransactionEvents(TSCont cont, TSEvent event, void *edata)
void
setupTransactionManagement()
{
// Reserve a transaction slot
TSAssert(TS_SUCCESS == TSHttpArgIndexReserve("atscppapi", "ATS CPP API", &TRANSACTION_STORAGE_INDEX));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you want to check with TSHttpArgIndexNameLookup first?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, OK I guess this is safe because of the pthread_once in utils::internal::initTransactionManagement(). It seems a little fragile to me though. I think it would be more obvious if this was just done in GlobalPlugin::GlobalPlugin() and the intermediate functions were removed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the problem with GlobalPlugin::GlobalPlugin is it can be called multiple times, once for each global plugin defined. I think only one transaction arg is required, though, for all global plugins.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, you would use TSHttpArgIndexNameLookup.

// We must always have a cleanup handler available
TSMutex mutex = NULL;
TSCont cont = TSContCreate(handleTransactionEvents, mutex);
Expand Down