Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F178098903
D61998.1795957793.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
D61998.1795957793.diff
View Options
diff --git a/usr.bin/fetch/fetch.c b/usr.bin/fetch/fetch.c
--- a/usr.bin/fetch/fetch.c
+++ b/usr.bin/fetch/fetch.c
@@ -430,7 +430,7 @@
char flags[8];
const char *slash;
char *tmppath;
- int r, tries;
+ int r, rerrno, tries;
unsigned timeout;
int timedout = 0;
char *ptr;
@@ -441,6 +441,7 @@
timeout = 0;
*flags = 0;
count = 0;
+ rerrno = 0;
/* set verbosity level */
if (v_level > 1)
@@ -737,6 +738,7 @@
/* suck in the data */
setvbuf(f, NULL, _IOFBF, B_size);
+ rerrno = 0;
signal(SIGINFO, sig_handler);
while (!sigint) {
if (us.size != -1 && us.size - count < B_size &&
@@ -753,10 +755,15 @@
break;
if ((readcnt = fread(buf, 1, size, f)) < size) {
- if (ferror(f) && errno == EINTR && !sigint)
+ if (ferror(f) && errno == EINTR && !sigint) {
clearerr(f);
- else if (readcnt == 0)
- break;
+ } else {
+ /* writing out what was read may change errno */
+ if (ferror(f) && rerrno == 0)
+ rerrno = errno;
+ if (readcnt == 0)
+ break;
+ }
}
stat_update(&xs, count += readcnt);
@@ -770,7 +777,7 @@
if (readcnt != 0)
break;
}
- timedout = ferror(f) && errno == ETIMEDOUT;
+ timedout = ferror(f) && rerrno == ETIMEDOUT;
signal(SIGINFO, SIG_DFL);
stat_end(&xs);
@@ -811,7 +818,7 @@
if (!timedout) {
/* check the status of our files */
if (ferror(f))
- warn("%s", URL);
+ warnc(rerrno, "%s", URL);
if (ferror(of))
warn("%s", path);
if (ferror(f) || ferror(of))
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 29, 1:09 PM (9 h, 33 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41996606
Default Alt Text
D61998.1795957793.diff (1 KB)
Attached To
Mode
D61998: fetch: Report a failed read's own error
Attached
Detach File
Event Timeline