From: Sebastian Dransfeld Date: Sat, 13 Jan 2007 01:49:42 +0000 (+0000) Subject: Limit curl run to 0.2 seconds. X-Git-Tag: submit/devel/efl/20131022.203902~18932 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c07d9dd245f77cd44b1788d47a28fe0e196344c6;p=platform%2Fupstream%2Fefl.git Limit curl run to 0.2 seconds. SVN revision: 27937 --- diff --git a/legacy/ecore/src/lib/ecore_file/ecore_file_download.c b/legacy/ecore/src/lib/ecore_file/ecore_file_download.c index dfe0e98..3ca6b3c 100644 --- a/legacy/ecore/src/lib/ecore_file/ecore_file_download.c +++ b/legacy/ecore/src/lib/ecore_file/ecore_file_download.c @@ -195,6 +195,7 @@ _ecore_file_download_curl(const char *url, const char *dst, int flags; int n_remaining, still_running; Ecore_File_Download_Job *job; + double start = 0.0; job = calloc(1, sizeof(Ecore_File_Download_Job)); if (!job) return NULL; @@ -216,7 +217,7 @@ _ecore_file_download_curl(const char *url, const char *dst, curl_easy_setopt(job->curl, CURLOPT_URL, url); curl_easy_setopt(job->curl, CURLOPT_WRITEDATA, job->file); - if(progress_cb) + if (progress_cb) { curl_easy_setopt(job->curl, CURLOPT_NOPROGRESS, FALSE); curl_easy_setopt(job->curl, CURLOPT_PROGRESSDATA, job); @@ -230,7 +231,11 @@ _ecore_file_download_curl(const char *url, const char *dst, ecore_list_append(_job_list, job); curl_multi_add_handle(curlm, job->curl); - while (curl_multi_perform(curlm, &still_running) == CURLM_CALL_MULTI_PERFORM); + start = ecore_time_get(); + while (curl_multi_perform(curlm, &still_running) == CURLM_CALL_MULTI_PERFORM) + { + if ((ecore_time_get() - start) > 0.2) break; + } /* check for completed jobs */ while ((curlmsg = curl_multi_info_read(curlm, &n_remaining)) != NULL) @@ -312,9 +317,13 @@ _ecore_file_download_curl_fd_handler(void *data __UNUSED__, Ecore_Fd_Handler *fd Ecore_File_Download_Job *job; CURLMsg *curlmsg; int n_remaining, still_running; + double start = 0.0; - /* FIXME: Can this run for a long time? Maybe limit how long it can run */ - while (curl_multi_perform(curlm, &still_running) == CURLM_CALL_MULTI_PERFORM); + start = ecore_time_get(); + while (curl_multi_perform(curlm, &still_running) == CURLM_CALL_MULTI_PERFORM) + { + if ((ecore_time_get() - start) > 0.2) break; + } /* Loop jobs and check if any are done */ while ((curlmsg = curl_multi_info_read(curlm, &n_remaining)) != NULL)