summaryrefslogtreecommitdiff
path: root/src/lib/ecore_con
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@yahoo.com>2016-12-23 22:53:52 +0200
committerDaniel Zaoui <daniel.zaoui@yahoo.com>2016-12-23 23:02:45 +0200
commit3235c83c360988603765d6b781aae65e0d7e6618 (patch)
tree4e0ef6ca75be152d826ae2eda9220c17da105fbc /src/lib/ecore_con
parent757cc83413c196ca599324efb8db52157b2c8203 (diff)
Ecore_Con_Url/Curl: add referencing on _c structure
The _c structure used to store the Curl function pointers needs referencing to be sure it is not freed although still needed. The non-referencing was leading to a crash during the destruction of the dialers. The _c was still used although it has been freed by ecore_con_url_shutdown.
Diffstat (limited to 'src/lib/ecore_con')
-rw-r--r--src/lib/ecore_con/ecore_con_url_curl.c9
-rw-r--r--src/lib/ecore_con/ecore_con_url_curl.h2
2 files changed, 9 insertions, 2 deletions
diff --git a/src/lib/ecore_con/ecore_con_url_curl.c b/src/lib/ecore_con/ecore_con_url_curl.c
index 4b325a15cf..e0d5f93c6b 100644
--- a/src/lib/ecore_con/ecore_con_url_curl.c
+++ b/src/lib/ecore_con/ecore_con_url_curl.c
@@ -244,7 +244,11 @@ _c_init(void)
244{ 244{
245 long ms = 0; 245 long ms = 0;
246 246
247 if (_c) return EINA_TRUE; 247 if (_c)
248 {
249 _c->ref++;
250 return EINA_TRUE;
251 }
248 if (_c_fail) 252 if (_c_fail)
249 { 253 {
250 ERR("Cannot find libcurl at runtime!"); 254 ERR("Cannot find libcurl at runtime!");
@@ -252,6 +256,7 @@ _c_init(void)
252 } 256 }
253 _c = calloc(1, sizeof(Ecore_Con_Curl)); 257 _c = calloc(1, sizeof(Ecore_Con_Curl));
254 if (!_c) goto error; 258 if (!_c) goto error;
259 _c->ref++;
255 260
256#define LOAD(x) \ 261#define LOAD(x) \
257 if (!_c->mod) { \ 262 if (!_c->mod) { \
@@ -342,7 +347,7 @@ error:
342void 347void
343_c_shutdown(void) 348_c_shutdown(void)
344{ 349{
345 if (!_c) return; 350 if (!_c || _c->ref--) return;
346 if (_c->_curlm) 351 if (_c->_curlm)
347 { 352 {
348 _c->curl_multi_cleanup(_c->_curlm); 353 _c->curl_multi_cleanup(_c->_curlm);
diff --git a/src/lib/ecore_con/ecore_con_url_curl.h b/src/lib/ecore_con/ecore_con_url_curl.h
index 42eae54c05..ae79c4c5cb 100644
--- a/src/lib/ecore_con/ecore_con_url_curl.h
+++ b/src/lib/ecore_con/ecore_con_url_curl.h
@@ -451,6 +451,8 @@ struct _Ecore_Con_Curl
451 const char *string); 451 const char *string);
452 time_t (*curl_getdate)(const char *p, const time_t *unused); 452 time_t (*curl_getdate)(const char *p, const time_t *unused);
453 curl_version_info_data *(*curl_version_info)(CURLversion); 453 curl_version_info_data *(*curl_version_info)(CURLversion);
454
455 int ref; /* Reference on the structure */
454}; 456};
455 457
456#define CURL_MIN_TIMEOUT 100 458#define CURL_MIN_TIMEOUT 100