summaryrefslogtreecommitdiff
path: root/src/lib/ecore_con
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2015-05-20 15:34:37 +0100
committerTom Hacohen <tom@stosb.com>2015-05-20 16:10:50 +0100
commit7c769163d9eb122412675dca621e83ed7648e60e (patch)
tree345aba47fffbea904ff3b731efefb915424cc89d /src/lib/ecore_con
parent29d11200c67dd9058a5175330159b115d8ed44f0 (diff)
Ecore con url: Fix wrong object destruction.
Because we defer the deletion of this object until we get all the responses from the network, we must manually free it. A better solution would possibly be to just free the requests upon object deletion instead of deferring the deletion. @fix
Diffstat (limited to 'src/lib/ecore_con')
-rw-r--r--src/lib/ecore_con/ecore_con_url.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/src/lib/ecore_con/ecore_con_url.c b/src/lib/ecore_con/ecore_con_url.c
index 626f7d4bae..021b6f22df 100644
--- a/src/lib/ecore_con/ecore_con_url.c
+++ b/src/lib/ecore_con/ecore_con_url.c
@@ -472,6 +472,8 @@ _efl_network_url_eo_base_constructor(Efl_Network_Url *url_obj, Efl_Network_Url_D
472 return NULL; 472 return NULL;
473 } 473 }
474 474
475 eo_manual_free_set(url_obj, EINA_TRUE);
476
475 return url_obj; 477 return url_obj;
476} 478}
477 479
@@ -484,7 +486,6 @@ _efl_network_url_eo_base_finalize(Efl_Network_Url *url_obj, Efl_Network_Url_Data
484 486
485 if (!url_con->url) 487 if (!url_con->url)
486 { 488 {
487 ecore_con_url_free(url_obj);
488 return NULL; 489 return NULL;
489 } 490 }
490 491
@@ -555,7 +556,7 @@ _efl_network_url_eo_base_finalize(Efl_Network_Url *url_obj, Efl_Network_Url_Data
555 */ 556 */
556 _c->curl_easy_setopt(url_con->curl_easy, CURLOPT_CONNECTTIMEOUT, 30); 557 _c->curl_easy_setopt(url_con->curl_easy, CURLOPT_CONNECTTIMEOUT, 30);
557 _c->curl_easy_setopt(url_con->curl_easy, CURLOPT_FOLLOWLOCATION, 1); 558 _c->curl_easy_setopt(url_con->curl_easy, CURLOPT_FOLLOWLOCATION, 1);
558 return url_obj; 559 return eo_do_super_ret(url_obj, MY_CLASS, url_obj, eo_finalize());
559} 560}
560 561
561EAPI Ecore_Con_Url * 562EAPI Ecore_Con_Url *
@@ -594,10 +595,24 @@ ecore_con_url_free(Ecore_Con_Url *url_obj)
594 eo_del(url_obj); 595 eo_del(url_obj);
595} 596}
596 597
598static void
599_ecore_con_url_free_internal(Ecore_Con_Url *url_obj)
600{
601 Efl_Network_Url_Data *url_con = eo_data_scope_get(url_obj, MY_CLASS);
602 char *s;
603
604 if (_c) _c->curl_slist_free_all(url_con->headers);
605 EINA_LIST_FREE(url_con->additional_headers, s)
606 free(s);
607 EINA_LIST_FREE(url_con->response_headers, s)
608 free(s);
609 eina_stringshare_del(url_con->url);
610 if (url_con->post_data) free(url_con->post_data);
611}
612
597EOLIAN static void 613EOLIAN static void
598_efl_network_url_eo_base_destructor(Efl_Network_Url *url_obj, Efl_Network_Url_Data *url_con) 614_efl_network_url_eo_base_destructor(Efl_Network_Url *url_obj, Efl_Network_Url_Data *url_con)
599{ 615{
600 char *s;
601 eo_do_super(url_obj, MY_CLASS, eo_destructor()); 616 eo_do_super(url_obj, MY_CLASS, eo_destructor());
602 617
603 if (!_c) return; 618 if (!_c) return;
@@ -626,13 +641,8 @@ _efl_network_url_eo_base_destructor(Efl_Network_Url *url_obj, Efl_Network_Url_Da
626 url_con->dead = EINA_TRUE; 641 url_con->dead = EINA_TRUE;
627 if (url_con->event_count) return; 642 if (url_con->event_count) return;
628 643
629 if (_c) _c->curl_slist_free_all(url_con->headers); 644 eo_manual_free_set(url_obj, EINA_FALSE);
630 EINA_LIST_FREE(url_con->additional_headers, s) 645 _ecore_con_url_free_internal(url_obj);
631 free(s);
632 EINA_LIST_FREE(url_con->response_headers, s)
633 free(s);
634 eina_stringshare_del(url_con->url);
635 if (url_con->post_data) free(url_con->post_data);
636} 646}
637 647
638EOLIAN static const char * 648EOLIAN static const char *
@@ -1702,7 +1712,11 @@ _ecore_con_event_url_free(Ecore_Con_Url *url_obj, void *ev)
1702 1712
1703 free(ev); 1713 free(ev);
1704 url_con->event_count--; 1714 url_con->event_count--;
1705 if (url_con->dead && (!url_con->event_count)) ecore_con_url_free(url_obj); 1715 if (url_con->dead && (!url_con->event_count))
1716 {
1717 _ecore_con_url_free_internal(url_obj);
1718 eo_manual_free(url_obj);
1719 }
1706} 1720}
1707 1721
1708#include "efl_network_url.eo.c" 1722#include "efl_network_url.eo.c"