-
Notifications
You must be signed in to change notification settings - Fork 21
Replace entire cpprest usage with libcurl #66
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
Replace entire cpprest usage with libcurl #66
Conversation
This reverts commit 7d22e10.
| #include <curl/curl.h> | ||
| #include "do_event.h" | ||
|
|
||
| class CurlMultiOperation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| ==================================================================== | ||
|
|
||
| microsoft/cpprestsdk 18212a2a7967e12d740bfb957e500892b3463c88 - MIT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| #include "do_common.h" | ||
| #include "download.h" | ||
|
|
||
| #include <cmath> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this unused? #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is used for std::round on line 455. I think it was being brought in by one of cpprest's headers earlier.
build/bootstrap.sh
Outdated
|
|
||
| # Open-source library dependencies | ||
| # Boost libs for DO | ||
| # Boost libs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can just delete this comment now. Before it was to distinguish which were used for DO and which were used for cpprest #Closed
| _requestContext.hrTranslatedStatusCode = S_OK; | ||
| _requestContext.responseOnHeadersAvailableInvoked = false; | ||
| _requestContext.responseOnCompleteInvoked = false; | ||
| _callbackContext = callerContext; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will remove in the next PR.
| DoLogVerbose("New http_client for %s", szUrl); | ||
|
|
||
| // Set options that are generic to all requests | ||
| curl_easy_setopt(_requestContext.curlHandle, CURLOPT_FOLLOWLOCATION, static_cast<long>(1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will make libcurl follow the redirect automatically but we still get headers back for the 302 response before getting headers for the 200.
|
|
||
| // Set options that are generic to all requests | ||
| curl_easy_setopt(_requestContext.curlHandle, CURLOPT_FOLLOWLOCATION, static_cast<long>(1)); | ||
| curl_easy_setopt(_requestContext.curlHandle, CURLOPT_MAXREDIRS, static_cast<long>(10)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. It can happen so we limit it.
jimson-msft
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
![]()
client-lite/src/exe/docs.cpp
Outdated
|
|
||
| ConfigManager clientConfigs; | ||
| auto downloadManager = std::make_shared<DownloadManager>(clientConfigs); | ||
| CurlMultiOperation curlOperations; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| } | ||
| } | ||
|
|
||
| void CurlMultiOperation::_WorkerThread() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider renaming this to _DoWork() #Resolved
|
|
||
| if (_activeHandles.Empty()) | ||
| { | ||
| _cv.wait(lock, [this](){ return !_fKeepRunning || !_handlesToAdd.empty(); }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this is non-empty, wouldn't cv wait here forever? There's no way to drain/clear the vector except for line 89 right? for example if AddHandle() is called while this thread is executing between line 89 and 99 - wouldn't this e stuck unless fkeepRunning gets set to false? #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is the opposite - wait() will return if _handlesToAdd becomes non-empty or _fKeepRunning becomes false.
Also note that AddHandle will wait if we were executing line 89-99 at that time (same mutex).
| DO_ASSERT(false); // TODO(shishirb) how to handle? | ||
| break; | ||
|
|
||
| case 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you might have mentioned this when we went over this, but for case 0: it indicates the process timed out? Should a comment be added on why we leave this case empty? #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0 = timeout, yes. Note this case isn't empty but falls through to call curl_multi_perform. I've added some comments in the next iteration.
* Agent now uses the curl lib with the multi interface with the select model of doing work. * Agent: Explicit link to pthread lib (cpprest was doing it on our behalf). * DownloadManagerTests: use polling, temporarily increase wait time * Add libcurl to bootstrap. Remove cpprest.
* Agent now uses the curl lib with the multi interface with the select model of doing work. * Agent: Explicit link to pthread lib (cpprest was doing it on our behalf). * DownloadManagerTests: use polling, temporarily increase wait time * Add libcurl to bootstrap. Remove cpprest.
* Agent now uses the curl lib with the multi interface with the select model of doing work. * Agent: Explicit link to pthread lib (cpprest was doing it on our behalf). * DownloadManagerTests: use polling, temporarily increase wait time * Add libcurl to bootstrap. Remove cpprest.
No description provided.