Mercurial > audlegacy-plugins
changeset 1155:6f5a4f0b6fb4 trunk
[svn] - curl: allow user to customize connect timeout value using a connect_timeout entry in config file
author | giacomo |
---|---|
date | Thu, 31 May 2007 10:33:46 -0700 |
parents | 5a8f6bfe3e4e |
children | 46476de8fc64 |
files | ChangeLog src/curl/curl.c |
diffstat | 2 files changed, 58 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Wed May 30 09:13:31 2007 -0700 +++ b/ChangeLog Thu May 31 10:33:46 2007 -0700 @@ -1,3 +1,10 @@ +2007-05-30 16:13:31 +0000 Tony Vroon <chainsaw@gentoo.org> + revision [2474] + Updated turkish translation by Murat ?\197?\158enel, closes bug #959. + trunk/po/tr.po | 1082 +++++++++++++++++++++++++++------------------------------ + 1 file changed, 515 insertions(+), 567 deletions(-) + + 2007-05-30 04:57:06 +0000 William Pitcock <nenolod@sacredspiral.co.uk> revision [2472] Fix handling of SPC efb register when echo instruction has been
--- a/src/curl/curl.c Wed May 30 09:13:31 2007 -0700 +++ b/src/curl/curl.c Thu May 31 10:33:46 2007 -0700 @@ -31,6 +31,7 @@ #define BUFFER_SIZE 256 * 1024 #define REVERSE_SEEK_SIZE 2048 +#define DEFAULT_CONNECT_TIMEOUT 3 #define DEBUG_CONNECTION 0 #define DEBUG_OPEN_CLOSE 1 @@ -42,6 +43,13 @@ #define DEBUG_ICY_VERBOSE 0 #define DEBUG_METADATA_REPORT 0 #define DEBUG_CURL 0 +#define DEBUG_SETTINGS 1 + +#if DEBUG_SETTINGS>0 +#define DEBUG_SETTINGS_MSG(...) g_print(__VA_ARGS__); +#else +#define DEBUG_SETTINGS_MSG(...) +#endif typedef struct _CurlHandle CurlHandle; @@ -91,6 +99,12 @@ GCond *curl_cond; }; +typedef struct { + gint connect_timeout; +} CurlOptions; + +CurlOptions curl_options; + void curl_vfs_rewind_impl(VFSFile * file); glong curl_vfs_ftell_impl(VFSFile * file); gboolean curl_vfs_feof_impl(VFSFile * file); @@ -583,7 +597,10 @@ curl_easy_setopt(handle->curl, CURLOPT_WRITEDATA, handle); curl_easy_setopt(handle->curl, CURLOPT_HEADERDATA, handle); - curl_easy_setopt(handle->curl, CURLOPT_CONNECTTIMEOUT, 3); + if ( curl_options.connect_timeout > 0 ) + curl_easy_setopt(handle->curl, CURLOPT_CONNECTTIMEOUT, curl_options.connect_timeout); + else + curl_easy_setopt(handle->curl, CURLOPT_CONNECTTIMEOUT, DEFAULT_CONNECT_TIMEOUT); curl_easy_setopt(handle->curl, CURLOPT_NOSIGNAL, 1); curl_easy_setopt(handle->curl, CURLOPT_SSL_VERIFYPEER, 0); @@ -1018,14 +1035,47 @@ curl_vfs_metadata_impl }; +static void curl_load_settings(void) +{ + ConfigDb *cfgfile = bmp_cfg_db_open(); + DEBUG_SETTINGS_MSG("curl - load settings called\n"); + + if ( ( !bmp_cfg_db_get_int( cfgfile , "curl" , + "connect_timeout" , &(curl_options.connect_timeout) ) ) || + ( curl_options.connect_timeout < 1 ) ) + { + curl_options.connect_timeout = -1; /* -1 means "use default value" */ + DEBUG_SETTINGS_MSG("curl - connect_timeout set to default value (%i)\n", DEFAULT_CONNECT_TIMEOUT); + } + DEBUG_SETTINGS_MSG("curl - connect_timeout value set (%i)\n", curl_options.connect_timeout); + + bmp_cfg_db_close( cfgfile ); + return; +} + +static void curl_save_settings(void) +{ + ConfigDb *cfgfile = bmp_cfg_db_open(); + DEBUG_SETTINGS_MSG("curl - save settings called\n"); + + bmp_cfg_db_set_int( cfgfile , "curl" , + "connect_timeout" , curl_options.connect_timeout ); + DEBUG_SETTINGS_MSG("curl - connect_timeout value saved (%i)\n", curl_options.connect_timeout); + + bmp_cfg_db_close( cfgfile ); + return; +} + static void init(void) { + curl_load_settings(); vfs_register_transport(&curl_const); vfs_register_transport(&curl_https_const); } static void cleanup(void) { + curl_save_settings(); #if 0 vfs_unregister_transport(&curl_const); vfs_unregister_transport(&curl_https_const);