Debug code bug fix; removal of CurlEasyHandle::getErrorString()
CurlEasyHandle::mErrorBuffer (CURLOPT_ERRORBUFFER) can NOT be used to retrieve information about an error returned by curl_multi_info_read in CURLMsg::data::result. This buffer is only initialized when a curl_easy_* call returns an error, and those errors are already printed automagically. Initialize the buffer with an empty string upon invokation of an curl_easy_* call, so we are sure the error belongs to the last call.
This commit is contained in:
@@ -653,6 +653,10 @@ void CurlEasyHandle::setErrorBuffer(void)
|
||||
mErrorBuffer = NULL;
|
||||
}
|
||||
}
|
||||
if (mErrorBuffer)
|
||||
{
|
||||
mErrorBuffer[0] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
CURLcode CurlEasyHandle::getinfo_priv(CURLINFO info, void* data)
|
||||
@@ -1448,15 +1452,7 @@ void CurlResponderBuffer::processOutput(AICurlEasyRequest_wat& curl_easy_request
|
||||
else
|
||||
{
|
||||
responseCode = 499;
|
||||
responseReason = AICurlInterface::strerror(code) + " : ";
|
||||
if (code == CURLE_FAILED_INIT)
|
||||
{
|
||||
responseReason += "Curl Easy Handle initialization failed.";
|
||||
}
|
||||
else
|
||||
{
|
||||
responseReason += curl_easy_request_w->getErrorString();
|
||||
}
|
||||
responseReason = AICurlInterface::strerror(code);
|
||||
curl_easy_request_w->setopt(CURLOPT_FRESH_CONNECT, TRUE);
|
||||
}
|
||||
|
||||
|
||||
@@ -160,10 +160,6 @@ class CurlEasyHandle : public boost::noncopyable, protected AICurlEasyHandleEven
|
||||
// Returns true if this easy handle was added to a curl multi handle.
|
||||
bool active(void) const { return mActiveMultiHandle; }
|
||||
|
||||
// If there was an error code as result, then this returns a human readable error string.
|
||||
// Only valid when setErrorBuffer was called and the curl_easy function returned an error.
|
||||
std::string getErrorString(void) const { return mErrorBuffer ? mErrorBuffer : "(null)"; }
|
||||
|
||||
// Returns true when it is expected that the parent will revoke callbacks before the curl
|
||||
// easy handle is removed from the multi handle; that usually happens when an external
|
||||
// error demands termination of the request (ie, an expiration).
|
||||
@@ -203,8 +199,7 @@ class CurlEasyHandle : public boost::noncopyable, protected AICurlEasyHandleEven
|
||||
// to set the options on a curl easy handle.
|
||||
//
|
||||
// Calling sendRequest() will then connect to the given URL and perform
|
||||
// the data exchange. If an error occurs related to this handle, it can
|
||||
// be read by calling getErrorString().
|
||||
// the data exchange. Use getResult() to determine if an error occurred.
|
||||
//
|
||||
// Note that the life cycle of a CurlEasyRequest is controlled by AICurlEasyRequest:
|
||||
// a CurlEasyRequest is only ever created as base class of a ThreadSafeCurlEasyRequest,
|
||||
@@ -264,13 +259,13 @@ class CurlEasyRequest : public CurlEasyHandle {
|
||||
// This actually adds the headers that were collected with addHeader.
|
||||
void finalizeRequest(std::string const& url);
|
||||
|
||||
// Store result code that is returned by getResult.
|
||||
// Called by MultiHandle::check_run_count() to store result code that is returned by getResult.
|
||||
void store_result(CURLcode result) { mResult = result; }
|
||||
|
||||
// Called when the curl easy handle is done.
|
||||
// Called by MultiHandle::check_run_count() when the curl easy handle is done.
|
||||
void done(AICurlEasyRequest_wat& curl_easy_request_w) { finished(curl_easy_request_w); }
|
||||
|
||||
// Fill info with the transfer info.
|
||||
// Called by MultiHandle::check_run_count() to fill info with the transfer info.
|
||||
void getTransferInfo(AICurlInterface::TransferInfo* info);
|
||||
|
||||
// If result != CURLE_FAILED_INIT then also info was filled.
|
||||
|
||||
@@ -480,7 +480,6 @@ static LLSD blocking_request(
|
||||
llwarns << "CURL REQ HEADERS: " << headers.asString() << llendl;
|
||||
llwarns << "CURL REQ BODY: " << ostr.str() << llendl;
|
||||
llwarns << "CURL HTTP_STATUS: " << http_status << llendl;
|
||||
llwarns << "CURL ERROR: " << curlEasyRequest_w->getErrorString() << llendl;
|
||||
llwarns << "CURL ERROR BODY: " << http_buffer.asString() << llendl;
|
||||
response["body"] = http_buffer.asString();
|
||||
}
|
||||
|
||||
@@ -340,8 +340,8 @@ void LLXMLRPCTransaction::Impl::curlEasyRequestCallback(bool success)
|
||||
if (result != CURLE_OK)
|
||||
{
|
||||
setCurlStatus(result);
|
||||
llwarns << "LLXMLRPCTransaction CURL error "
|
||||
<< mCurlCode << ": " << curlEasyRequest_w->getErrorString() << llendl;
|
||||
llwarns << "LLXMLRPCTransaction CURL error: "
|
||||
<< AICurlInterface::strerror(mCurlCode) << llendl;
|
||||
llwarns << "LLXMLRPCTransaction request URI: "
|
||||
<< mURI << llendl;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user