Mercurial > audlegacy-plugins
changeset 944:fe18e45e6660 trunk
[svn] - protect some functions with a mutex.
author | nenolod |
---|---|
date | Thu, 12 Apr 2007 12:33:04 -0700 |
parents | 584ab2a62af5 |
children | 4f7a55282201 |
files | ChangeLog src/curl/curl.c |
diffstat | 2 files changed, 32 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Thu Apr 12 12:02:56 2007 -0700 +++ b/ChangeLog Thu Apr 12 12:33:04 2007 -0700 @@ -1,3 +1,11 @@ +2007-04-12 19:02:56 +0000 William Pitcock <nenolod@sacredspiral.co.uk> + revision [2016] + - if handle->cancel = TRUE, immediately abort the fread operation. + + trunk/src/curl/curl.c | 2 ++ + 1 file changed, 2 insertions(+) + + 2007-04-12 18:35:08 +0000 William Pitcock <nenolod@sacredspiral.co.uk> revision [2012] - comment out debug cflags
--- a/src/curl/curl.c Thu Apr 12 12:02:56 2007 -0700 +++ b/src/curl/curl.c Thu Apr 12 12:33:04 2007 -0700 @@ -32,7 +32,7 @@ #define BUFFER_SIZE 256 * 1024 #define REVERSE_SEEK_SIZE 2048 -#define DEBUG_CONNECTION 0 +#define DEBUG_CONNECTION 1 #define DEBUG_OPEN_CLOSE 1 #define DEBUG_SEEK 0 #define DEBUG_READ 0 @@ -83,6 +83,8 @@ } proxy_info; gchar *local_ip; + + GMutex *curl_mutex; }; void curl_vfs_rewind_impl(VFSFile * file); @@ -461,6 +463,14 @@ if (DEBUG_CONNECTION) g_print("Connect %p\n", handle); + g_mutex_lock(handle->curl_mutex); + + if (handle->curl == NULL) + { + g_mutex_unlock(handle->curl_mutex); + return NULL; + } + if (handle->no_data) curl_easy_setopt(handle->curl, CURLOPT_NOBODY, 1); else @@ -478,6 +488,7 @@ handle->icy_interval = 0; result = curl_easy_perform(handle->curl); + if (result == CURLE_OK) update_length(handle); // We expect to get CURLE_WRITE_ERROR if we cancel. @@ -489,10 +500,15 @@ { g_print("Got curl error %d: %s\n", result, curl_easy_strerror(result)); handle->failed = 1; + curl_easy_cleanup(handle->curl); + handle->curl = NULL; } if (DEBUG_CONNECTION) g_print("Done %p%s", handle, handle->cancel ? " (aborted)\n" : "\n"); handle->cancel = 1; + + g_mutex_unlock(handle->curl_mutex); + return NULL; } @@ -562,6 +578,7 @@ handle->failed = 0; handle->no_data = 0; handle->stream_stack = NULL; + handle->curl_mutex = g_mutex_new(); curl_easy_setopt(handle->curl, CURLOPT_URL, url); curl_easy_setopt(handle->curl, CURLOPT_WRITEFUNCTION, curl_writecb); @@ -663,7 +680,12 @@ g_free(handle->name); if (handle->stream_stack != NULL) g_slist_free(handle->stream_stack); - curl_easy_cleanup(handle->curl); + + if (handle->curl != NULL) + curl_easy_cleanup(handle->curl); + + if (handle->curl_mutex != NULL) + g_mutex_free(handle->curl_mutex); if (handle->local_ip != NULL) g_free(handle->local_ip);