Move libcurl initialization to urlinstTransfer() (#537870).
Recent trees have been giving errors when we get to the stage2 download
point, such as this one:
Unable to retrieve http://download.fedoraproject.org/pub/fedora/linux/development/x86_64/os//images/install.img.
libcurl needs to be initialized inside urlinstTransfer() so it has the
latest network state for the system. The above error is caused by old
DNS settings. libcurl won't automatically do a res_init(), so we need
to set up a new curl instance and use that.
Since this patch moves curl usage to be exclusively within
urlinstTransfer(), move 'curl' to that function as well and remove it
from loaderData.
Add curl cleanup calls at the end of urlinstTransfer().
---
loader/loader.c | 4 ----
loader/loader.h | 3 ---
loader/urls.c | 35 ++++++++++++++++++++++-------------
3 files changed, 22 insertions(+), 20 deletions(-)
- CURL *curl;
-
/* Proxy info needs to be in the loaderData so we can get these
* settings off the command line, too.
*/
diff --git a/loader/urls.c b/loader/urls.c
index 495516a..0d1c92b 100644
--- a/loader/urls.c
+++ b/loader/urls.c
@@ -37,6 +37,7 @@
#include <unistd.h>
#include <netdb.h>
#include <errno.h>
+#include <curl/curl.h>
+ /* Initialize libcurl */
+ curl_global_init(CURL_GLOBAL_SSL);
+ curl = curl_easy_init();
+
/* Clear out all the old settings, since libcurl preserves them for as
* long as you use the same handle and settings might have changed.
*/
- curl_easy_reset(loaderData->curl);
+ curl_easy_reset(curl);
/* If a proxy was provided, add the options for that now. */
if (loaderData->proxy && strcmp(loaderData->proxy, "")) {
- curl_easy_setopt(loaderData->curl, CURLOPT_PROXY, loaderData->proxy);
+ curl_easy_setopt(curl, CURLOPT_PROXY, loaderData->proxy);
/* Only set up the progress bar if we've got a UI to display it. */
@@ -164,13 +170,13 @@ int urlinstTransfer(struct loaderData_s *loaderData, struct iurlinfo *ui,
/* Finally, do the transfer. */
- status = curl_easy_perform(loaderData->curl);
+ status = curl_easy_perform(curl);
if (status)
logMessage(ERROR, "Error downloading %s: %s", ui->url, curl_easy_strerror(status));
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
11-18-2009, 08:58 PM
Chris Lumens
Move libcurl initialization to urlinstTransfer() (#537870).
> Recent trees have been giving errors when we get to the stage2 download
> point, such as this one:
>
> Unable to retrieve http://download.fedoraproject.org/pub/fedora/linux/development/x86_64/os//images/install.img.
>
> libcurl needs to be initialized inside urlinstTransfer() so it has the
> latest network state for the system. The above error is caused by old
> DNS settings. libcurl won't automatically do a res_init(), so we need
> to set up a new curl instance and use that.
>
> Since this patch moves curl usage to be exclusively within
> urlinstTransfer(), move 'curl' to that function as well and remove it
> from loaderData.
That's too bad, but okay. At least we know what's going on.
> /* Clear out all the old settings, since libcurl preserves them for as
> * long as you use the same handle and settings might have changed.
> */
> - curl_easy_reset(loaderData->curl);
> + curl_easy_reset(curl);
We shouldn't need to call curl_easy_reset since we're getting rid of the
handle at the end of every call to urlinstTransfer, right?
- Chris
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
11-18-2009, 09:31 PM
David Cantrell
Move libcurl initialization to urlinstTransfer() (#537870).
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Wed, 18 Nov 2009, Chris Lumens wrote:
Recent trees have been giving errors when we get to the stage2 download
point, such as this one:
Unable to retrieve http://download.fedoraproject.org/pub/fedora/linux/development/x86_64/os//images/install.img.
libcurl needs to be initialized inside urlinstTransfer() so it has the
latest network state for the system. The above error is caused by old
DNS settings. libcurl won't automatically do a res_init(), so we need
to set up a new curl instance and use that.
Since this patch moves curl usage to be exclusively within
urlinstTransfer(), move 'curl' to that function as well and remove it
from loaderData.
That's too bad, but okay. At least we know what's going on.
/* Clear out all the old settings, since libcurl preserves them for as
* long as you use the same handle and settings might have changed.
*/
- curl_easy_reset(loaderData->curl);
+ curl_easy_reset(curl);
We shouldn't need to call curl_easy_reset since we're getting rid of the
handle at the end of every call to urlinstTransfer, right?
That's a good point. I'll remove the curl_easy_reset() line and test.
Assuming loader doesn't explode and spew library guts all over me, I'll
commit.