0
0
mirror of https://github.com/rkd77/elinks.git synced 2025-06-30 22:19:29 -04:00

NET: Fix regression from the latest change_connection changes

This makes move_download not assume that there is a connection attached
when it is called. This is the case pretty often for file:// downloads when
dialogs are involved (query file) and the reason why it explicitly checks
if the connection state is 'in result state'. Anyway, fill the new download
struct with variabled from the old one instead of taking variables from the
connection struct.

This patch also adds some assertions and a few comments.
This commit is contained in:
Jonas Fonseca 2006-02-04 23:20:40 +01:00 committed by Jonas Fonseca
parent 318a9b29fa
commit 347970988d

View File

@ -986,20 +986,23 @@ cancel_download(struct download *download, int interrupt)
assert(download);
if_assert_failed return;
/* Did the connection already end? */
if (is_in_result_state(download->state))
return;
assertm(download->conn, "last state is %d", download->state);
check_queue_bugs();
download->state = S_INTERRUPTED;
del_from_list(download);
conn = download->conn;
conn->pri[download->pri]--;
assertm(conn->pri[download->pri] >= 0, "priority counter underflow");
if_assert_failed conn->pri[download->pri] = 0;
del_from_list(download);
download->state = S_INTERRUPTED;
if (list_empty(conn->downloads)) {
/* Necessary because of assertion in get_priority(). */
conn->pri[PRI_CANCEL]++;
@ -1016,15 +1019,21 @@ cancel_download(struct download *download, int interrupt)
void
move_download(struct download *old, struct download *new,
enum connection_priority newpri)
enum connection_priority newpri)
{
struct connection *conn = old->conn;
new->conn = conn;
new->cached = conn->cached;
new->prev_error = conn->prev_error;
new->progress = conn->progress;
new->state = conn->state;
assert(old);
/* The download doesn't necessarily have a connection attached, for
* example the file protocol loads it's object immediately. This is
* catched by the result state check below. */
new->conn = old->conn;
new->cached = old->cached;
new->prev_error = old->prev_error;
new->progress = old->progress;
new->state = old->state;
new->pri = newpri;
if (is_in_result_state(old->state)) {
@ -1033,6 +1042,8 @@ move_download(struct download *old, struct download *new,
return;
}
assertm(old->conn, "last state is %d", old->state);
conn->pri[new->pri]++;
add_to_list(conn->downloads, new);