1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

Don't check is_in_progress_state before calling cancel_download

With commit 637f1e82e6 ('NET: Merge
change_connection into cancel_download'), cancel_download returns
immediately if the connection is not in a result state, so save some
code by not checking is_in_progress_state before calling cancel_download.
This commit is contained in:
Miciah Dashiel Butler Masters 2006-02-12 15:41:21 +00:00 committed by Miciah Dashiel Butler Masters
parent 2c087e52e7
commit daad05c055
4 changed files with 7 additions and 14 deletions

View File

@ -351,8 +351,7 @@ bittorrent_fetch_callback(struct download *download, void *data)
return; return;
if (cached->redirect && fetcher->redirects++ < MAX_REDIRECTS) { if (cached->redirect && fetcher->redirects++ < MAX_REDIRECTS) {
if (is_in_progress_state(download->state)) cancel_download(download, 0);
cancel_download(download, 0);
download->state = S_WAIT_REDIR; download->state = S_WAIT_REDIR;
@ -427,8 +426,7 @@ end_bittorrent_fetch(void *fetcher_data)
assert(fetcher && !fetcher->callback); assert(fetcher && !fetcher->callback);
/* Stop any running connections. */ /* Stop any running connections. */
if (is_in_progress_state(fetcher->download.state)) cancel_download(&fetcher->download, 0);
cancel_download(&fetcher->download, 0);
mem_free(fetcher); mem_free(fetcher);
} }

View File

@ -140,8 +140,7 @@ abort_download(struct file_download *file_download)
if (file_download->dlg_data) if (file_download->dlg_data)
cancel_dialog(file_download->dlg_data, NULL); cancel_dialog(file_download->dlg_data, NULL);
if (is_in_progress_state(file_download->download.state)) cancel_download(&file_download->download, file_download->stop);
cancel_download(&file_download->download, file_download->stop);
if (file_download->uri) done_uri(file_download->uri); if (file_download->uri) done_uri(file_download->uri);
if (file_download->handle != -1) { if (file_download->handle != -1) {
@ -389,8 +388,7 @@ download_data(struct download *download, struct file_download *file_download)
file_download->remotetime = parse_date(&cached->last_modified, NULL, 0, 1); file_download->remotetime = parse_date(&cached->last_modified, NULL, 0, 1);
if (cached->redirect && file_download->redirect_cnt++ < MAX_REDIRECTS) { if (cached->redirect && file_download->redirect_cnt++ < MAX_REDIRECTS) {
if (is_in_progress_state(download->state)) cancel_download(&file_download->download, 0);
cancel_download(&file_download->download, 0);
assertm(compare_uri(cached->uri, file_download->uri, 0), assertm(compare_uri(cached->uri, file_download->uri, 0),
"Redirecting using bad base URI"); "Redirecting using bad base URI");
@ -899,8 +897,7 @@ void
done_type_query(struct type_query *type_query) done_type_query(struct type_query *type_query)
{ {
/* Unregister any active download */ /* Unregister any active download */
if (is_in_progress_state(type_query->download.state)) cancel_download(&type_query->download, 0);
cancel_download(&type_query->download, 0);
object_unlock(type_query->cached); object_unlock(type_query->cached);
done_uri(type_query->uri); done_uri(type_query->uri);

View File

@ -1123,8 +1123,7 @@ abort_loading(struct session *ses, int interrupt)
if (have_location(ses)) { if (have_location(ses)) {
struct location *loc = cur_loc(ses); struct location *loc = cur_loc(ses);
if (is_in_progress_state(loc->download.state)) cancel_download(&loc->download, interrupt);
cancel_download(&loc->download, interrupt);
abort_files_load(ses, interrupt); abort_files_load(ses, interrupt);
} }
abort_preloading(ses, interrupt); abort_preloading(ses, interrupt);

View File

@ -206,8 +206,7 @@ dump_loading_callback(struct download *download, void *p)
if (cached && cached->redirect && dump_redir_count++ < MAX_REDIRECTS) { if (cached && cached->redirect && dump_redir_count++ < MAX_REDIRECTS) {
struct uri *uri = cached->redirect; struct uri *uri = cached->redirect;
if (is_in_progress_state(download->state)) cancel_download(download, 0);
cancel_download(download, 0);
load_uri(uri, cached->uri, download, PRI_MAIN, 0, -1); load_uri(uri, cached->uri, download, PRI_MAIN, 0, -1);
return; return;