Skip to content
Merged
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
54 changes: 29 additions & 25 deletions plugins/s3_auth/s3_auth.cc
Original file line number Diff line number Diff line change
Expand Up @@ -991,36 +991,40 @@ S3Request::authorizeV2(S3Config *s3)
int
event_handler(TSCont cont, TSEvent event, void *edata)
{
TSHttpTxn txnp = static_cast<TSHttpTxn>(edata);
S3Config *s3 = static_cast<S3Config *>(TSContDataGet(cont));

S3Request request(txnp);
TSHttpStatus status = TS_HTTP_STATUS_INTERNAL_SERVER_ERROR;
TSHttpTxn txnp = static_cast<TSHttpTxn>(edata);
S3Config *s3 = static_cast<S3Config *>(TSContDataGet(cont));
TSEvent enable_event = TS_EVENT_HTTP_CONTINUE;

switch (event) {
case TS_EVENT_HTTP_SEND_REQUEST_HDR:
if (request.initialize()) {
while (s3->reload_waiting) {
std::this_thread::yield();
}
{
S3Request request(txnp);
TSHttpStatus status = TS_HTTP_STATUS_INTERNAL_SERVER_ERROR;

std::shared_lock lock(s3->reload_mutex);
status = request.authorize(s3);
}
switch (event) {
case TS_EVENT_HTTP_SEND_REQUEST_HDR:
if (request.initialize()) {
while (s3->reload_waiting) {
std::this_thread::yield();
}

if (TS_HTTP_STATUS_OK == status) {
TSDebug(PLUGIN_NAME, "Successfully signed the AWS S3 URL");
} else {
TSDebug(PLUGIN_NAME, "Failed to sign the AWS S3 URL, status = %d", status);
TSHttpTxnStatusSet(txnp, status);
enable_event = TS_EVENT_HTTP_ERROR;
std::shared_lock lock(s3->reload_mutex);
status = request.authorize(s3);
}

if (TS_HTTP_STATUS_OK == status) {
TSDebug(PLUGIN_NAME, "Successfully signed the AWS S3 URL");
} else {
TSDebug(PLUGIN_NAME, "Failed to sign the AWS S3 URL, status = %d", status);
TSHttpTxnStatusSet(txnp, status);
enable_event = TS_EVENT_HTTP_ERROR;
}
break;
default:
TSError("[%s] Unknown event for this plugin", PLUGIN_NAME);
TSDebug(PLUGIN_NAME, "unknown event for this plugin");
break;
}
break;
default:
TSError("[%s] Unknown event for this plugin", PLUGIN_NAME);
TSDebug(PLUGIN_NAME, "unknown event for this plugin");
break;
// Most get S3Request out of scope in case the later plugins invalidate the TSAPI
// objects it references. Some cases were causing asserts from the destructor
}

TSHttpTxnReenable(txnp, enable_event);
Expand Down