[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
lynx-dev Silent read failures during transmission - patch
From: |
Klaus Weide |
Subject: |
lynx-dev Silent read failures during transmission - patch |
Date: |
Mon, 7 Dec 1998 23:32:26 -0600 (CST) |
Here are some changes that were triggered by reading Debian bug report
#24082, see <URL:http://www.debian.org/Bugs/db/24/24082.html>.
This may or may not resolve the actual problem, but at least Lynx
shouldn't fail quietly. I have not actually tested the changes with
any failing connections.
The significant changes are ifdef'd for Unix since I am unfamiliar with
e.g. the various VMS TCP stacks or the availability of errno. So I left
things as they were for non-Unix to play it safe.
Some other changes to make the code more understandable (including
for myself).
Klaus
Patches are against 2.8.1rel.2. Eyeball inspection shows no significant
changes in the relevant sections of the latest devel code, so they
may also apply cleanly to 2.8.2dev.8.
* Check for EINTR from read() call in HTDoRead, and retry if necessary.
This change only for Unix. Interrupted read() system calls should be
rare (or impossible, depending on the system implementation?) since
the read() is only done after a successful select(), but checking
can't hurt.
* Check for read read() errors in HTDoRead and HTCopy, and generate
alert messages for unexpected errors. HTCopy still returns HT_LOADED
to indicate success if any data have been received before an unexpected
error or disconnection. Previously this happened without any indication
to the user that something was wrong and a document or file might be
incomplete. These changes currently only for Unix.
* Added/enhanced comments in HTFormat.c to document current behavior of
HTCopy, HTFileCopy, HTGzFileCopy, HTParseSocket, HTParseFile, and
HTParseGzFile.
* Moved definition of HT_NO_DATA to HTUtils.h, changed value of some
status codes to libwww5-like values while we're at it.
*** lynx2-8-1.orig/WWW/Library/Implementation/HTAccess.h Thu Aug 6
07:28:22 1998
--- lynx2-8-1/WWW/Library/Implementation/HTAccess.h Mon Dec 7 20:37:39 1998
***************
*** 32,39 ****
** In general, positive codes are OK and negative ones are bad.
*/
- #define HT_NO_DATA -9999 /* return code: OK but no data was loaded */
- /* Typically, other app started or forked */
/*
--- 32,37 ----
*** lynx2-8-1.orig/WWW/Library/Implementation/HTFormat.c Wed Sep 30
16:06:48 1998
--- lynx2-8-1/WWW/Library/Implementation/HTFormat.c Mon Dec 7 20:37:41 1998
***************
*** 11,17 ****
*/
#include <HTUtils.h>
- #include <HTAccess.h>
/* Implements:
*/
--- 11,16 ----
***************
*** 530,535 ****
--- 529,555 ----
** CRLF at the end of lines which need to be stripped to LF for unix
** when the format is textual.
**
+ ** State of socket and target stream on entry:
+ ** socket (file_number) assumed open,
+ ** target (sink) assumed valid.
+ **
+ ** Return values:
+ ** HT_INTERRUPTED Interruption or error after some data received.
+ ** -2 Unexpected disconnect before any data received.
+ ** -1 Interruption or error before any data received, or
+ ** (UNIX) other read error before any data received, or
+ ** download cancelled.
+ ** HT_LOADED Normal close of socket (end of file indication
+ ** received), or
+ ** unexpected disconnect after some data received, or
+ ** other read error after some data received, or
+ ** (not UNIX) other read error before any data received.
+ **
+ ** State of socket and target stream on return depends on return value:
+ ** HT_INTERRUPTED socket still open, target aborted.
+ ** -2 socket still open, target stream still valid.
+ ** -1 socket still open, target aborted.
+ ** otherwise socket closed, target stream still valid.
*/
PUBLIC int HTCopy ARGS4(
HTParentAnchor *, anchor,
***************
*** 597,602 ****
--- 617,637 ----
rv = -2;
goto finished;
} else {
+ #ifdef UNIX
+ /*
+ * Treat what we've received already as the complete
+ * transmission, but not without giving the user
+ * an alert. I don't know about all the different
+ * TCP stacks for VMS etc., so this is currently
+ * only for UNIX. - kw
+ */
+ HTInetStatus("NETREAD");
+ HTAlert("Unexpected server disconnect.");
+ CTRACE(tfp,
+ "HTCopy: Unexpected server disconnect. Treating as completed.\n");
+ status = 0;
+ break;
+ #else /* !UNIX */
/*
* Treat what we've gotten already
* as the complete transmission. - FM
***************
*** 605,611 ****
--- 640,667 ----
"HTCopy: Unexpected server disconnect. Treating as completed.\n");
status = 0;
break;
+ #endif /* UNIX */
+ }
+ #ifdef UNIX
+ } else { /* status < 0 and other errno */
+ /*
+ * Treat what we've received already as the complete
+ * transmission, but not without giving the user
+ * an alert. I don't know about all the different
+ * TCP stacks for VMS etc., so this is currently
+ * only for UNIX. - kw
+ */
+ HTInetStatus("NETREAD");
+ HTAlert("Unexpected read error.");
+ if (bytes) {
+ (void)NETCLOSE(file_number);
+ rv = HT_LOADED;
+ } else {
+ (*targetClass._abort)(sink, NULL);
+ rv = -1;
}
+ goto finished;
+ #endif
}
break;
}
***************
*** 641,646 ****
--- 697,714 ----
** graphic (or other) objects described by the file.
**
**
+ ** State of file and target stream on entry:
+ ** FILE* (fp) assumed open,
+ ** target (sink) assumed valid.
+ **
+ ** Return values:
+ ** HT_INTERRUPTED Interruption after some data read.
+ ** HT_PARTIAL_CONTENT Error after some data read.
+ ** -1 Error before any data read.
+ ** HT_LOADED Normal end of file indication on reading.
+ **
+ ** State of file and target stream on return:
+ ** always fp still open, target stream still valid.
*/
PUBLIC int HTFileCopy ARGS2(
FILE *, fp,
***************
*** 701,706 ****
--- 769,786 ----
** graphic (or other) objects described by the file.
**
**
+ ** State of file and target stream on entry:
+ ** gzFile (gzfp) assumed open (should have gzipped content),
+ ** target (sink) assumed valid.
+ **
+ ** Return values:
+ ** HT_INTERRUPTED Interruption after some data read.
+ ** HT_PARTIAL_CONTENT Error after some data read.
+ ** -1 Error before any data read.
+ ** HT_LOADED Normal end of file indication on reading.
+ **
+ ** State of file and target stream on return:
+ ** always gzfp still open, target stream still valid.
*/
PRIVATE int HTGzFileCopy ARGS2(
gzFile, gzfp,
***************
*** 807,812 ****
--- 887,916 ----
** CRLF at the end of lines which need to be stripped to LF for unix
** when the format is textual.
**
+ ** State of socket and target stream on entry:
+ ** socket (file_number) assumed open,
+ ** target (sink) usually NULL (will call stream stack).
+ **
+ ** Return values:
+ ** HT_INTERRUPTED Interruption or error after some data received.
+ ** -501 Stream stack failed (cannot present or convert).
+ ** -2 Unexpected disconnect before any data received.
+ ** -1 Stream stack failed (cannot present or convert), or
+ ** Interruption or error before any data received, or
+ ** (UNIX) other read error before any data received, or
+ ** download cancelled.
+ ** HT_LOADED Normal close of socket (end of file indication
+ ** received), or
+ ** unexpected disconnect after some data received, or
+ ** other read error after some data received, or
+ ** (not UNIX) other read error before any data received.
+ **
+ ** State of socket and target stream on return depends on return value:
+ ** HT_INTERRUPTED socket still open, target aborted.
+ ** -501 socket still open, target stream NULL.
+ ** -2 socket still open, target freed.
+ ** -1 socket still open, target stream aborted or NULL.
+ ** otherwise socket closed, target stream freed.
*/
PUBLIC int HTParseSocket ARGS5(
HTFormat, rep_in,
***************
*** 841,847 ****
if (rv != -1 && rv != HT_INTERRUPTED)
(*targetClass._free)(stream);
! return rv; /* full: HT_LOADED; partial: HT_INTERRUPTED; no bytes: -1 */
}
/* Parse a file given format and file pointer
--- 945,952 ----
if (rv != -1 && rv != HT_INTERRUPTED)
(*targetClass._free)(stream);
! return rv;
! /* Originally: full: HT_LOADED; partial: HT_INTERRUPTED; no bytes: -1
*/
}
/* Parse a file given format and file pointer
***************
*** 853,858 ****
--- 958,976 ----
** CRLF at the end of lines which need to be stripped to \n for unix
** when the format is textual.
**
+ ** State of file and target stream on entry:
+ ** FILE* (fp) assumed open,
+ ** target (sink) usually NULL (will call stream stack).
+ **
+ ** Return values:
+ ** -501 Stream stack failed (cannot present or convert).
+ ** -1 Download cancelled.
+ ** HT_NO_DATA Error before any data read.
+ ** HT_PARTIAL_CONTENT Interruption or error after some data read.
+ ** HT_LOADED Normal end of file indication on reading.
+ **
+ ** State of file and target stream on return:
+ ** always fp still open; target freed, aborted, or NULL.
*/
PUBLIC int HTParseFile ARGS5(
HTFormat, rep_in,
***************
*** 921,926 ****
--- 1039,1060 ----
return(gzres);
}
+ /* HTParseGzFile
+ **
+ ** State of file and target stream on entry:
+ ** gzFile (gzfp) assumed open,
+ ** target (sink) usually NULL (will call stream stack).
+ **
+ ** Return values:
+ ** -501 Stream stack failed (cannot present or convert).
+ ** -1 Download cancelled.
+ ** HT_NO_DATA Error before any data read.
+ ** HT_PARTIAL_CONTENT Interruption or error after some data read.
+ ** HT_LOADED Normal end of file indication on reading.
+ **
+ ** State of file and target stream on return:
+ ** always gzfp closed; target freed, aborted, or NULL.
+ */
PUBLIC int HTParseGzFile ARGS5(
HTFormat, rep_in,
HTFormat, format_out,
*** lynx2-8-1.orig/WWW/Library/Implementation/HTFormat.h Thu Aug 6
07:28:22 1998
--- lynx2-8-1/WWW/Library/Implementation/HTFormat.h Mon Dec 7 21:34:07 1998
***************
*** 371,377 ****
HTParseFile: Parse a File through a file pointer
This routine is called by protocols modules to load an object. uses
HTStreamStack and
! HTFileCopy . Returns HT_LOADED if succesful, <0 if not.
*/
extern int HTParseFile PARAMS((
--- 371,378 ----
HTParseFile: Parse a File through a file pointer
This routine is called by protocols modules to load an object. uses
HTStreamStack and
! HTFileCopy . Returns HT_LOADED if successful, can also return
HT_PARTIAL_CONTENT,
! HT_NO_DATA, or other <0 for failure.
*/
extern int HTParseFile PARAMS((
***************
*** 390,396 ****
HTParseGzFile: Parse a gzipped File through a file pointer
This routine is called by protocols modules to load an object. uses
HTStreamStack and
! HTGzFileCopy . Returns HT_LOADED if succesful, <0 if not.
*/
extern int HTParseGzFile PARAMS((
HTFormat format_in,
--- 391,398 ----
HTParseGzFile: Parse a gzipped File through a file pointer
This routine is called by protocols modules to load an object. uses
HTStreamStack and
! HTGzFileCopy. Returns HT_LOADED if successful, can also return
HT_PARTIAL_CONTENT,
! HT_NO_DATA, or other <0 for failure.
*/
extern int HTParseGzFile PARAMS((
HTFormat format_in,
*** lynx2-8-1.orig/WWW/Library/Implementation/HTTCP.c Sat Oct 24 11:49:07 1998
--- lynx2-8-1/WWW/Library/Implementation/HTTCP.c Mon Dec 7 21:50:40 1998
***************
*** 17,23 ****
*/
#include <HTUtils.h>
- #include <HTAccess.h>
#include <HTParse.h>
#include <HTAlert.h>
#include <HTTCP.h>
--- 17,22 ----
***************
*** 1095,1101 ****
fd_set readfds;
struct timeval timeout;
int tries=0;
! #ifdef UCX
int nb;
#endif /* UCX, BSN */
--- 1094,1100 ----
fd_set readfds;
struct timeval timeout;
int tries=0;
! #if defined(UNIX) || defined(UCX)
int nb;
#endif /* UCX, BSN */
***************
*** 1152,1159 ****
}
#if !defined(UCX) || !defined(VAXC)
return SOCKET_READ (fildes, buf, nbyte);
! #else
/*
** VAXC and UCX problem only.
*/
--- 1151,1175 ----
}
#if !defined(UCX) || !defined(VAXC)
+ #ifdef UNIX
+ while ((nb = SOCKET_READ (fildes, buf, nbyte)) == -1) {
+ int saved_errno = errno;
+ if (errno == EINTR)
+ continue;
+ #ifdef ERESTARTSYS
+ if (errno == ERESTARTSYS)
+ continue;
+ #endif /* ERESTARTSYS */
+ HTInetStatus("read");
+ errno = saved_errno; /* our caller may check it */
+ break;
+ }
+ return nb;
+ #else /* UNIX */
return SOCKET_READ (fildes, buf, nbyte);
! #endif /* !UNIX */
!
! #else /* UCX && VAXC */
/*
** VAXC and UCX problem only.
*/
*** lynx2-8-1.orig/WWW/Library/Implementation/HTTelnet.c Thu Sep 17
05:43:48 1998
--- lynx2-8-1/WWW/Library/Implementation/HTTelnet.c Mon Dec 7 20:32:26 1998
***************
*** 35,42 ****
#include <LYStrings.h>
#include <LYLeaks.h>
- #define HT_NO_DATA -9999
-
/* Telnet or "rlogin" access
** -------------------------
--- 35,40 ----
*** lynx2-8-1.orig/WWW/Library/Implementation/HTUtils.h Wed Sep 30 16:06:48 1998
--- lynx2-8-1/WWW/Library/Implementation/HTUtils.h Mon Dec 7 20:37:35 1998
***************
*** 271,279 ****
#define FALSE (BOOLEAN)0
#endif
#endif /* CURSES */
! #endif /* _WINDOWS */
#define BOOLEAN_DEFINED
! #endif
#ifndef BOOL
#define BOOL BOOLEAN
--- 271,279 ----
#define FALSE (BOOLEAN)0
#endif
#endif /* CURSES */
! #endif /* BOOLEAN_DEFINED */
#define BOOLEAN_DEFINED
! #endif /* _WINDOWS */
#ifndef BOOL
#define BOOL BOOLEAN
***************
*** 314,320 ****
#define HT_CANNOT_TRANSLATE -4
#define HT_NO_ACCESS -10 /* Access not available */
#define HT_FORBIDDEN -11 /* Access forbidden */
! #define HT_INTERNAL -12 /* Weird -- should never happen. */
#define HT_BAD_EOF -12 /* Premature EOF */
--- 314,322 ----
#define HT_CANNOT_TRANSLATE -4
#define HT_NO_ACCESS -10 /* Access not available */
#define HT_FORBIDDEN -11 /* Access forbidden */
! #define HT_NO_DATA -204 /* OK but no data was loaded - */
! /* possibly other app started or forked
*/
! #define HT_INTERNAL -900 /* Weird -- should never happen. */
#define HT_BAD_EOF -12 /* Premature EOF */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- lynx-dev Silent read failures during transmission - patch,
Klaus Weide <=