ecore_con: make dns resolver thread stop blocking when canceled

Summary:
if the user or system attempts to cancel this thread then it should
stop blocking and exit in order to avoid potentially exiting after
efl has expected ecore-con to stop being active

@fix
fix T7041
Depends on D6354

Reviewers: ManMower, devilhorns

Reviewed By: ManMower

Subscribers: cedric, #committers

Tags: #efl

Maniphest Tasks: T7041

Differential Revision: https://phab.enlightenment.org/D6355
This commit is contained in:
Mike Blumenkrantz 2018-06-25 15:13:22 -04:00
parent 1e47db6a71
commit 0e40fad446
4 changed files with 12 additions and 10 deletions

View File

@ -73,7 +73,7 @@ static int _ecore_con_init_count = 0;
int _ecore_con_log_dom = -1;
Eina_Bool _efl_net_proxy_helper_can_do (void);
int _efl_net_proxy_helper_url_req_send(const char *url);
int _efl_net_proxy_helper_url_req_send(const char *url, Ecore_Thread *eth);
char **_efl_net_proxy_helper_url_wait (int id);
void _efl_net_proxy_helper_init (void);
void _efl_net_proxy_helper_shutdown (void);
@ -2038,7 +2038,7 @@ _efl_net_ip_connect_async_run_socks5h(Efl_Net_Ip_Connect_Async_Data *d, const ch
}
static void
_efl_net_ip_connect_async_run(void *data, Ecore_Thread *thread EINA_UNUSED)
_efl_net_ip_connect_async_run(void *data, Ecore_Thread *thread)
{
Efl_Net_Ip_Connect_Async_Data *d = data;
const char *host, *port, *proxy;
@ -2076,7 +2076,7 @@ _efl_net_ip_connect_async_run(void *data, Ecore_Thread *thread EINA_UNUSED)
}
else
{
proxies = ecore_con_libproxy_proxies_get(url);
proxies = ecore_con_libproxy_proxies_get(url, thread);
eina_stringshare_del(url);
}
}
@ -2578,9 +2578,9 @@ efl_net_udp_datagram_size_query(SOCKET fd)
}
char **
ecore_con_libproxy_proxies_get(const char *url)
ecore_con_libproxy_proxies_get(const char *url, Ecore_Thread *eth)
{
int id = _efl_net_proxy_helper_url_req_send(url);
int id = _efl_net_proxy_helper_url_req_send(url, eth);
if (id < 0) return NULL;
return _efl_net_proxy_helper_url_wait(id);
}

View File

@ -95,7 +95,7 @@ extern int sd_fd_max;
/* init must be called from main thread */
void ecore_con_libproxy_proxies_free(char **proxies);
/* BLOCKING! should be called from a worker thread */
char **ecore_con_libproxy_proxies_get(const char *url);
char **ecore_con_libproxy_proxies_get(const char *url, Ecore_Thread *eth);
Eina_Bool ecore_con_server_check(const Ecore_Con_Server *svr);

View File

@ -321,7 +321,7 @@ _efl_net_proxy_helper_cb_send_do(void *data)
}
int
_efl_net_proxy_helper_url_req_send(const char *url)
_efl_net_proxy_helper_url_req_send(const char *url, Ecore_Thread *eth)
{
char *buf;
int id = -1;
@ -339,6 +339,7 @@ _efl_net_proxy_helper_url_req_send(const char *url)
locks--;
}
eina_spinlock_release(&_efl_net_proxy_helper_queue_lock);
if (ecore_thread_check(eth)) return -1;
// create request to quque up to look up responses for
req = calloc(1, sizeof(Efl_Net_Proxy_Helper_Req));
if (!req) return -1;
@ -352,9 +353,10 @@ _efl_net_proxy_helper_url_req_send(const char *url)
buf = alloca(strlen(url) + 256);
sprintf(buf, "P %i %s\n", req->id, url);
req->str = strdup(buf);
if (!req->str)
if ((!req->str) || ecore_thread_check(eth))
{
eina_thread_queue_free(req->thq);
free(req->str);
free(req);
return -1;
}

View File

@ -1226,10 +1226,10 @@ typedef struct _Efl_Net_Dialer_Http_Libproxy_Context {
} Efl_Net_Dialer_Http_Libproxy_Context;
static void
_efl_net_dialer_http_libproxy_run(void *data, Ecore_Thread *thread EINA_UNUSED)
_efl_net_dialer_http_libproxy_run(void *data, Ecore_Thread *thread)
{
Efl_Net_Dialer_Http_Libproxy_Context *ctx = data;
char **proxies = ecore_con_libproxy_proxies_get(ctx->url);
char **proxies = ecore_con_libproxy_proxies_get(ctx->url, thread);
char **itr;
if (!proxies) return;