* [w3m-dev 04321] Re: w3m's bugs from bugs.debian.org
* http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=185006#22 * main.c (sig_chld): save exit code to d->err. (addDownloadList): initialize d->running and d->err. (DownloadListBuffer): check d->err. * fm.h (_DownloadList): add running and err. * file.c (save2tmp): check returned value of Strfputs(). (doFileSave): exit code is depend on the returned value of save2tmp().
This commit is contained in:
@@ -1,3 +1,16 @@
|
|||||||
|
2010-07-19 d+w3m@vdr.jp
|
||||||
|
|
||||||
|
* [w3m-dev 04321] Re: w3m's bugs from bugs.debian.org
|
||||||
|
* http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=185006#22
|
||||||
|
* main.c (sig_chld): save exit code to d->err.
|
||||||
|
(addDownloadList): initialize d->running and d->err.
|
||||||
|
(DownloadListBuffer): check d->err.
|
||||||
|
|
||||||
|
* fm.h (_DownloadList): add running and err.
|
||||||
|
|
||||||
|
* file.c (save2tmp): check returned value of Strfputs().
|
||||||
|
(doFileSave): exit code is depend on the returned value of save2tmp().
|
||||||
|
|
||||||
2010-07-19 d+w3m@vdr.jp
|
2010-07-19 d+w3m@vdr.jp
|
||||||
|
|
||||||
* [w3m-dev 04238] [patch] simple preserve space
|
* [w3m-dev 04238] [patch] simple preserve space
|
||||||
@@ -8974,4 +8987,4 @@ a * [w3m-dev 03276] compile error on EWS4800
|
|||||||
* release-0-2-1
|
* release-0-2-1
|
||||||
* import w3m-0.2.1
|
* import w3m-0.2.1
|
||||||
|
|
||||||
$Id: ChangeLog,v 1.1009 2010/07/19 09:00:34 htrb Exp $
|
$Id: ChangeLog,v 1.1010 2010/07/19 11:45:23 htrb Exp $
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: file.c,v 1.256 2010/07/19 09:00:34 htrb Exp $ */
|
/* $Id: file.c,v 1.257 2010/07/19 11:45:24 htrb Exp $ */
|
||||||
#include "fm.h"
|
#include "fm.h"
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include "myctype.h"
|
#include "myctype.h"
|
||||||
@@ -7761,7 +7761,13 @@ save2tmp(URLFile uf, char *tmpf)
|
|||||||
{
|
{
|
||||||
Str buf = Strnew_size(SAVE_BUF_SIZE);
|
Str buf = Strnew_size(SAVE_BUF_SIZE);
|
||||||
while (UFread(&uf, buf, SAVE_BUF_SIZE)) {
|
while (UFread(&uf, buf, SAVE_BUF_SIZE)) {
|
||||||
Strfputs(buf, ff);
|
if (Strfputs(buf, ff) != buf->length) {
|
||||||
|
bcopy(env_bak, AbortLoading, sizeof(JMP_BUF));
|
||||||
|
TRAP_OFF;
|
||||||
|
fclose(ff);
|
||||||
|
current_content_length = 0;
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
linelen += buf->length;
|
linelen += buf->length;
|
||||||
showProgress(&linelen, &trbyte);
|
showProgress(&linelen, &trbyte);
|
||||||
}
|
}
|
||||||
@@ -8090,16 +8096,20 @@ doFileSave(URLFile uf, char *defstr)
|
|||||||
flush_tty();
|
flush_tty();
|
||||||
pid = fork();
|
pid = fork();
|
||||||
if (!pid) {
|
if (!pid) {
|
||||||
|
int err;
|
||||||
if ((uf.content_encoding != CMP_NOCOMPRESS) && AutoUncompress) {
|
if ((uf.content_encoding != CMP_NOCOMPRESS) && AutoUncompress) {
|
||||||
uncompress_stream(&uf, &tmpf);
|
uncompress_stream(&uf, &tmpf);
|
||||||
if (tmpf)
|
if (tmpf)
|
||||||
unlink(tmpf);
|
unlink(tmpf);
|
||||||
}
|
}
|
||||||
setup_child(FALSE, 0, UFfileno(&uf));
|
setup_child(FALSE, 0, UFfileno(&uf));
|
||||||
if (!save2tmp(uf, p) && PreserveTimestamp && uf.modtime != -1)
|
err = save2tmp(uf, p);
|
||||||
|
if (err == 0 && PreserveTimestamp && uf.modtime != -1)
|
||||||
setModtime(p, uf.modtime);
|
setModtime(p, uf.modtime);
|
||||||
UFclose(&uf);
|
UFclose(&uf);
|
||||||
unlink(lock);
|
unlink(lock);
|
||||||
|
if (err != 0)
|
||||||
|
exit(-err);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
addDownloadList(pid, uf.url, p, lock, current_content_length);
|
addDownloadList(pid, uf.url, p, lock, current_content_length);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: fm.h,v 1.139 2010/07/19 09:00:34 htrb Exp $ */
|
/* $Id: fm.h,v 1.140 2010/07/19 11:45:24 htrb Exp $ */
|
||||||
/*
|
/*
|
||||||
* w3m: WWW wo Miru utility
|
* w3m: WWW wo Miru utility
|
||||||
*
|
*
|
||||||
@@ -517,7 +517,8 @@ typedef struct _DownloadList {
|
|||||||
char *lock;
|
char *lock;
|
||||||
clen_t size;
|
clen_t size;
|
||||||
time_t time;
|
time_t time;
|
||||||
int ok;
|
int running;
|
||||||
|
int err;
|
||||||
struct _DownloadList *next;
|
struct _DownloadList *next;
|
||||||
struct _DownloadList *prev;
|
struct _DownloadList *prev;
|
||||||
} DownloadList;
|
} DownloadList;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: main.c,v 1.260 2010/07/18 14:10:09 htrb Exp $ */
|
/* $Id: main.c,v 1.261 2010/07/19 11:45:24 htrb Exp $ */
|
||||||
#define MAINPROGRAM
|
#define MAINPROGRAM
|
||||||
#include "fm.h"
|
#include "fm.h"
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
@@ -323,21 +323,26 @@ static void
|
|||||||
sig_chld(int signo)
|
sig_chld(int signo)
|
||||||
{
|
{
|
||||||
int p_stat;
|
int p_stat;
|
||||||
#ifdef HAVE_WAITPID
|
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
|
#ifdef HAVE_WAITPID
|
||||||
while ((pid = waitpid(-1, &p_stat, WNOHANG)) > 0) {
|
while ((pid = waitpid(-1, &p_stat, WNOHANG)) > 0) {
|
||||||
;
|
|
||||||
}
|
|
||||||
#elif HAVE_WAIT3
|
#elif HAVE_WAIT3
|
||||||
int pid;
|
|
||||||
|
|
||||||
while ((pid = wait3(&p_stat, WNOHANG, NULL)) > 0) {
|
while ((pid = wait3(&p_stat, WNOHANG, NULL)) > 0) {
|
||||||
;
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
wait(&p_stat);
|
if ((pid = wait(&p_stat)) > 0) {
|
||||||
#endif
|
#endif
|
||||||
|
DownloadList *d;
|
||||||
|
|
||||||
|
if (WIFEXITED(p_stat)) {
|
||||||
|
for (d = FirstDL; d != NULL; d = d->next) {
|
||||||
|
if (d->pid == pid) {
|
||||||
|
d->err = WEXITSTATUS(p_stat);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
mySignal(SIGCHLD, sig_chld);
|
mySignal(SIGCHLD, sig_chld);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -6348,7 +6353,8 @@ addDownloadList(pid_t pid, char *url, char *save, char *lock, clen_t size)
|
|||||||
d->lock = lock;
|
d->lock = lock;
|
||||||
d->size = size;
|
d->size = size;
|
||||||
d->time = time(0);
|
d->time = time(0);
|
||||||
d->ok = FALSE;
|
d->running = TRUE;
|
||||||
|
d->err = 0;
|
||||||
d->next = NULL;
|
d->next = NULL;
|
||||||
d->prev = LastDL;
|
d->prev = LastDL;
|
||||||
if (LastDL)
|
if (LastDL)
|
||||||
@@ -6368,7 +6374,7 @@ checkDownloadList(void)
|
|||||||
if (!FirstDL)
|
if (!FirstDL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
for (d = FirstDL; d != NULL; d = d->next) {
|
for (d = FirstDL; d != NULL; d = d->next) {
|
||||||
if (!d->ok && !lstat(d->lock, &st))
|
if (d->running && !lstat(d->lock, &st))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -6408,15 +6414,16 @@ DownloadListBuffer(void)
|
|||||||
"<form method=internal action=download><hr>\n");
|
"<form method=internal action=download><hr>\n");
|
||||||
for (d = LastDL; d != NULL; d = d->prev) {
|
for (d = LastDL; d != NULL; d = d->prev) {
|
||||||
if (lstat(d->lock, &st))
|
if (lstat(d->lock, &st))
|
||||||
d->ok = TRUE;
|
d->running = FALSE;
|
||||||
Strcat_charp(src, "<pre>\n");
|
Strcat_charp(src, "<pre>\n");
|
||||||
Strcat(src, Sprintf("%s\n --> %s\n ", html_quote(d->url),
|
Strcat(src, Sprintf("%s\n --> %s\n ", html_quote(d->url),
|
||||||
html_quote(conv_from_system(d->save))));
|
html_quote(conv_from_system(d->save))));
|
||||||
duration = cur_time - d->time;
|
duration = cur_time - d->time;
|
||||||
if (!stat(d->save, &st)) {
|
if (!stat(d->save, &st)) {
|
||||||
size = st.st_size;
|
size = st.st_size;
|
||||||
if (d->ok) {
|
if (!d->running) {
|
||||||
d->size = size;
|
if (!d->err)
|
||||||
|
d->size = size;
|
||||||
duration = st.st_mtime - d->time;
|
duration = st.st_mtime - d->time;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6435,7 +6442,7 @@ DownloadListBuffer(void)
|
|||||||
Strcat_char(src, '_');
|
Strcat_char(src, '_');
|
||||||
Strcat_char(src, '\n');
|
Strcat_char(src, '\n');
|
||||||
}
|
}
|
||||||
if (!d->ok && size < d->size)
|
if ((d->running || d->err) && size < d->size)
|
||||||
Strcat(src, Sprintf(" %s / %s bytes (%d%%)",
|
Strcat(src, Sprintf(" %s / %s bytes (%d%%)",
|
||||||
convert_size3(size), convert_size3(d->size),
|
convert_size3(size), convert_size3(d->size),
|
||||||
(int)(100.0 * size / d->size)));
|
(int)(100.0 * size / d->size)));
|
||||||
@@ -6446,20 +6453,28 @@ DownloadListBuffer(void)
|
|||||||
Strcat(src, Sprintf(" %02d:%02d:%02d rate %s/sec",
|
Strcat(src, Sprintf(" %02d:%02d:%02d rate %s/sec",
|
||||||
duration / (60 * 60), (duration / 60) % 60,
|
duration / (60 * 60), (duration / 60) % 60,
|
||||||
duration % 60, convert_size(rate, 1)));
|
duration % 60, convert_size(rate, 1)));
|
||||||
if (!d->ok && size < d->size && rate) {
|
if (d->running && size < d->size && rate) {
|
||||||
eta = (d->size - size) / rate;
|
eta = (d->size - size) / rate;
|
||||||
Strcat(src, Sprintf(" eta %02d:%02d:%02d", eta / (60 * 60),
|
Strcat(src, Sprintf(" eta %02d:%02d:%02d", eta / (60 * 60),
|
||||||
(eta / 60) % 60, eta % 60));
|
(eta / 60) % 60, eta % 60));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Strcat_char(src, '\n');
|
Strcat_char(src, '\n');
|
||||||
if (d->ok) {
|
if (!d->running) {
|
||||||
Strcat(src, Sprintf("<input type=submit name=ok%d value=OK>",
|
Strcat(src, Sprintf("<input type=submit name=ok%d value=OK>",
|
||||||
d->pid));
|
d->pid));
|
||||||
if (size < d->size)
|
switch (d->err) {
|
||||||
Strcat_charp(src, " Download incompleted");
|
case 0: if (size < d->size)
|
||||||
else
|
Strcat_charp(src, " Download ended but probably not complete");
|
||||||
Strcat_charp(src, " Download completed");
|
else
|
||||||
|
Strcat_charp(src, " Download complete");
|
||||||
|
break;
|
||||||
|
case 1: Strcat_charp(src, " Error: could not open destination file");
|
||||||
|
break;
|
||||||
|
case 2: Strcat_charp(src, " Error: could not write to file (disk full)");
|
||||||
|
break;
|
||||||
|
default: Strcat_charp(src, " Error: unknown reason");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Strcat(src, Sprintf("<input type=submit name=stop%d value=STOP>",
|
Strcat(src, Sprintf("<input type=submit name=stop%d value=STOP>",
|
||||||
@@ -6513,7 +6528,7 @@ stopDownload(void)
|
|||||||
if (!FirstDL)
|
if (!FirstDL)
|
||||||
return;
|
return;
|
||||||
for (d = FirstDL; d != NULL; d = d->next) {
|
for (d = FirstDL; d != NULL; d = d->next) {
|
||||||
if (d->ok)
|
if (!d->running)
|
||||||
continue;
|
continue;
|
||||||
#ifndef __MINGW32_VERSION
|
#ifndef __MINGW32_VERSION
|
||||||
kill(d->pid, SIGKILL);
|
kill(d->pid, SIGKILL);
|
||||||
|
|||||||
Reference in New Issue
Block a user