]> granicus.if.org Git - curl/commitdiff
- Kamil Dudka made the curl tool properly call curl_global_init() before any
authorDaniel Stenberg <daniel@haxx.se>
Wed, 11 Mar 2009 22:56:03 +0000 (22:56 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 11 Mar 2009 22:56:03 +0000 (22:56 +0000)
  other libcurl function.

CHANGES
include/curl/curl.h
src/main.c

diff --git a/CHANGES b/CHANGES
index d68072cac54af59c334675b9d90b2fc6023f6818..682a03f51a7fd96eaa6db2132182bb79bb186e25 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,10 @@
 
                                   Changelog
 
+Daniel Stenberg (11 Mar 2009)
+- Kamil Dudka made the curl tool properly call curl_global_init() before any
+  other libcurl function.
+
 Yang Tse (11 Mar 2009)
 - Added missing TELNET timeout support for Windows builds. This issue was
   reported by Pierre Brico.
index 8d952caabf477497de8e8ae6d1e14181bc8dfce8..7ecb6317b121502bdaf7c8ae9a3291295b4b6d7b 100644 (file)
@@ -1510,7 +1510,9 @@ CURL_EXTERN void curl_free(void *p);
  * DESCRIPTION
  *
  * curl_global_init() should be invoked exactly once for each application that
- * uses libcurl
+ * uses libcurl and before any call of other libcurl function.
+ *
+ * This function is not thread-safe!
  */
 CURL_EXTERN CURLcode curl_global_init(long flags);
 
index aabd659fe3811ef67739daff8a61d341ef9c0fd2..26fa3c85bfb76c5f3866071eaf86498005b3c6be 100644 (file)
@@ -3969,6 +3969,12 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
 
   memset(&heads, 0, sizeof(struct OutStruct));
 
+  /* initialize curl library - do not call any libcurl functions before */
+  if (main_init() != CURLE_OK) {
+    helpf(config->errors, "error initializing curl library\n");
+    return CURLE_FAILED_INIT;
+  }
+
 #ifdef CURLDEBUG
   /* this sends all memory debug messages to a logfile named memdump */
   env = curlx_getenv("CURL_MEMDEBUG");
@@ -4015,10 +4021,6 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
 #endif
 
   /* inits */
-  if (main_init() != CURLE_OK) {
-    helpf(config->errors, "error initializing curl library\n");
-    return CURLE_FAILED_INIT;
-  }
   config->postfieldsize = -1;
   config->showerror=TRUE;
   config->use_httpget=FALSE;