From a6d4b3931051c0ca38a92624de1a74de7c9fad87 Mon Sep 17 00:00:00 2001 From: watchwolf Date: Sat, 14 Nov 2009 13:43:38 +0000 Subject: [PATCH] Ecore : Fix ecore con destroy git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/ecore@43689 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/ecore_con/ecore_con_url.c | 13 ++++++++++--- src/lib/ecore_file/ecore_file_download.c | 20 ++++++++++++++------ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/lib/ecore_con/ecore_con_url.c b/src/lib/ecore_con/ecore_con_url.c index e2a80c3..111b5c7 100644 --- a/src/lib/ecore_con/ecore_con_url.c +++ b/src/lib/ecore_con/ecore_con_url.c @@ -346,10 +346,13 @@ ecore_con_url_destroy(Ecore_Con_Url *url_con) } ECORE_MAGIC_SET(url_con, ECORE_MAGIC_NONE); - if (url_con->fd_handler) + if(url_con->fd != -1) { - ecore_main_fd_handler_del(url_con->fd_handler); + FD_CLR(url_con->fd, &_current_fd_set); + if (url_con->fd_handler) + ecore_main_fd_handler_del(url_con->fd_handler); url_con->fd = -1; + url_con->fd_handler = NULL; } if (url_con->curl_easy) { @@ -740,7 +743,9 @@ ecore_con_url_send(Ecore_Con_Url *url_con, const void *data, size_t length, cons url_con->received = 0; - return _ecore_con_url_perform(url_con); + int res = _ecore_con_url_perform(url_con); + + return res; #else return 0; url_con = NULL; @@ -1055,6 +1060,7 @@ _ecore_con_url_perform(Ecore_Con_Url *url_con) { if (url_con->fd_handler) ecore_main_fd_handler_del(url_con->fd_handler); + url_con->fd_handler = NULL; /* url_con still active -- set up an fd_handler */ FD_ZERO(&read_set); @@ -1063,6 +1069,7 @@ _ecore_con_url_perform(Ecore_Con_Url *url_con) /* Stupid curl, why can't I get the fd to the current added job? */ curl_multi_fdset(curlm, &read_set, &write_set, &exc_set, &fd_max); + int found = 0; for (fd = 0; fd <= fd_max; fd++) { if (!FD_ISSET(fd, &_current_fd_set)) diff --git a/src/lib/ecore_file/ecore_file_download.c b/src/lib/ecore_file/ecore_file_download.c index fb3287a..ef94874 100644 --- a/src/lib/ecore_file/ecore_file_download.c +++ b/src/lib/ecore_file/ecore_file_download.c @@ -96,8 +96,8 @@ ecore_file_download_abort_all(void) * Download @p url to the given @p dst * @param url The complete url to download * @param dst The local file to save the downloaded to - * @param job_ret Here the protocol use is http or ftp, this parameter will be fill - * with the job. The you con use ecore_file_download_abort() to cancel it. + * @param job_ret If the protocol use is http or ftp, this parameter will be fill + * with the job. Then you can use ecore_file_download_abort() to cancel it. * @param completion_cb A callback called on download complete * @param progress_cb A callback called during the download operation * @return 1 if the download start or 0 on failure @@ -133,7 +133,7 @@ ecore_file_download(const char *url, const char *dst, url += 7; /* skip hostname */ url = strchr(url, '/'); - return ecore_file_cp(url, dst); + return ecore_file_cp(url, dst); } # ifdef HAVE_CURL else if ((!strncmp(url, "http://", 7)) || @@ -207,7 +207,10 @@ _ecore_file_download_url_complete_cb(void *data, int type, void *event) if (job->completion_cb) job->completion_cb(ecore_con_url_data_get(job->url_con), job->dst, !ev->status); - ecore_file_download_abort(job); + _job_list = eina_list_remove(_job_list, job); + fclose(job->file); + free(job->dst); + free(job); return 0; } @@ -228,7 +231,12 @@ _ecore_file_download_url_progress_cb(void *data, int type, void *event) (long int) ev->down.total, (long int) ev->down.now, (long int) ev->up.total, (long int) ev->up.now) != 0) { - ecore_file_download_abort(job); + _job_list = eina_list_remove(_job_list, job); + fclose(job->file); + free(job->dst); + free(job); + + return 1; } return 0; @@ -284,7 +292,7 @@ ecore_file_download_abort(Ecore_File_Download_Job *job) { # ifdef HAVE_CURL ecore_con_url_destroy(job->url_con); -# endif +# endif _job_list = eina_list_remove(_job_list, job); fclose(job->file); free(job->dst); -- 2.7.4