Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[XrdTpc] Add curl handle cleanup on redirections or errors #1023

Merged
merged 1 commit into from
Jul 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/XrdTpc/XrdTpcTPC.cc
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ int TPCHandler::ProcessPushReq(const std::string & resource, XrdHttpExtReq &req)
AtomicEnd(m_monid_mutex);
std::unique_ptr<XrdSfsFile> fh(m_sfs->newFile(name, file_monid));
if (!fh.get()) {
curl_easy_cleanup(curl);
char msg[] = "Failed to initialize internal transfer file handle";
return req.SendSimpleResp(500, NULL, NULL, msg, 0);
}
Expand All @@ -467,8 +468,10 @@ int TPCHandler::ProcessPushReq(const std::string & resource, XrdHttpExtReq &req)
int open_results = OpenWaitStall(*fh, full_url, SFS_O_RDONLY, 0644,
req.GetSecEntity(), authz);
if (SFS_REDIRECT == open_results) {
curl_easy_cleanup(curl);
return RedirectTransfer(redirect_resource, req, fh->error);
} else if (SFS_OK != open_results) {
curl_easy_cleanup(curl);
int code;
char msg_generic[] = "Failed to open local resource";
const char *msg = fh->error.getErrText(code);
Expand Down Expand Up @@ -506,6 +509,7 @@ int TPCHandler::ProcessPullReq(const std::string &resource, XrdHttpExtReq &req)
char *name = req.GetSecEntity().name;
std::unique_ptr<XrdSfsFile> fh(m_sfs->newFile(name, m_monid++));
if (!fh.get()) {
curl_easy_cleanup(curl);
char msg[] = "Failed to initialize internal transfer file handle";
return req.SendSimpleResp(500, NULL, NULL, msg, 0);
}
Expand All @@ -529,6 +533,7 @@ int TPCHandler::ProcessPullReq(const std::string &resource, XrdHttpExtReq &req)
} catch (...) { // Handled below
}
if (stream_req < 0 || stream_req > 100) {
curl_easy_cleanup(curl);
char msg[] = "Invalid request for number of streams";
m_log.Emsg("ProcessPullReq", msg);
return req.SendSimpleResp(500, NULL, NULL, msg, 0);
Expand All @@ -542,8 +547,10 @@ int TPCHandler::ProcessPullReq(const std::string &resource, XrdHttpExtReq &req)
int open_result = OpenWaitStall(*fh, full_url, mode|SFS_O_WRONLY, 0644,
req.GetSecEntity(), authz);
if (SFS_REDIRECT == open_result) {
curl_easy_cleanup(curl);
return RedirectTransfer(redirect_resource, req, fh->error);
} else if (SFS_OK != open_result) {
curl_easy_cleanup(curl);
int code;
char msg_generic[] = "Failed to open local resource";
const char *msg = fh->error.getErrText(code);
Expand Down