changeset 950:668110a6a412 trunk

[svn] - curl: do NOT use signals with the new multi-thread layout, and take care of the url string value
author giacomo
date Fri, 13 Apr 2007 05:23:27 -0700
parents d3b9627861de
children df18b664f4e0
files ChangeLog src/curl/curl.c
diffstat 2 files changed, 17 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Apr 12 15:03:53 2007 -0700
+++ b/ChangeLog	Fri Apr 13 05:23:27 2007 -0700
@@ -1,3 +1,11 @@
+2007-04-12 22:03:53 +0000  William Pitcock <nenolod@sacredspiral.co.uk>
+  revision [2032]
+  - revert r2028.
+  
+  trunk/src/curl/curl.c |    4 ++--
+  1 file changed, 2 insertions(+), 2 deletions(-)
+
+
 2007-04-12 21:55:59 +0000  William Pitcock <nenolod@sacredspiral.co.uk>
   revision [2030]
   - add DEBUG_CURL to enable curl internal debugging messages
--- a/src/curl/curl.c	Thu Apr 12 15:03:53 2007 -0700
+++ b/src/curl/curl.c	Fri Apr 13 05:23:27 2007 -0700
@@ -48,6 +48,8 @@
 struct _CurlHandle {
   CURL *curl;
 
+  gchar *url; // URL string, must remain present until curl no longer needs it
+
   gssize length; // the length of the file
   gssize rd_abs; // the absolute position for reading from the stream
   gssize wr_abs; // the absolute position where the input connection is
@@ -548,17 +550,15 @@
 curl_vfs_fopen_impl(const gchar * path,
 		    const gchar * mode)
 {
-  gchar *url;
   CurlHandle *handle;
   VFSFile *file;
   if (!path || !mode)
     return NULL;
 
-  url = g_strdup(path);
-
   file = g_new0(VFSFile, 1);
 
   handle = g_new0(CurlHandle, 1);
+  handle->url = g_strdup(path);
   handle->curl = curl_easy_init();
   handle->rd_index = 0;
   handle->wr_index = 0;
@@ -576,12 +576,13 @@
   handle->curl_mutex = g_mutex_new();
   handle->curl_cond = g_cond_new();
 
-  curl_easy_setopt(handle->curl, CURLOPT_URL, url);
+  curl_easy_setopt(handle->curl, CURLOPT_URL, handle->url);
   curl_easy_setopt(handle->curl, CURLOPT_WRITEFUNCTION, curl_writecb);
   curl_easy_setopt(handle->curl, CURLOPT_WRITEDATA, handle);
   curl_easy_setopt(handle->curl, CURLOPT_HEADERDATA, handle);
 
   curl_easy_setopt(handle->curl, CURLOPT_CONNECTTIMEOUT, 3);
+  curl_easy_setopt(handle->curl, CURLOPT_NOSIGNAL, 1);
 
   curl_easy_setopt(handle->curl, CURLOPT_SSL_VERIFYPEER, 0);
   curl_easy_setopt(handle->curl, CURLOPT_SSL_VERIFYHOST, 0);
@@ -652,7 +653,7 @@
   file->base = &curl_const;
 
   if (DEBUG_OPEN_CLOSE)
-    g_print("Open %s with curl => %p\n", url, handle);
+    g_print("Open %s with curl => %p\n", handle->url, handle);
 
   return file;
 }
@@ -698,6 +699,9 @@
 	  vfs_fclose(handle->download);
 	}
 
+      if (handle->url != NULL)
+        g_free(handle->url);
+
       g_free(handle);
     }
   return ret;