wwwlib cannot take broken pipe (bug in HTWriter.c?)

It seems that if the HTTPD server closes the connection while the
libwww is writing stuff (*), the libwww doesn't recover from it too
well.  It just keeps trying to send more stuff, ignoring the errors
(even if it notices them). The reason is that many of the request
generating modules just use multiple PUTS/PUTBLOCK etc to build the
request from small pieces of text, but none check the return errors.

Thus, when my application tries to retrieve the NOFRAMES section from

	http://www.vtt.fi/rte/

(the server is Netscape-Enterprise/2.01) it gets to a point.. (I am
catching SIGPIPEs and ignoring them, if you don't do this, you won't
see the problem as the first SIGPIPE would kill the process).

...
...
Reading...
Reading...
WARNING: Fatal Error: 404 Not Found (Not found) 

WARNING: Fatal Error: System replies (NETREAD: Connection reset by peer) 
Reason: System replies (NETWRITE: Broken pipe) 
Reason: System replies (NETWRITE: Broken pipe) 
Reason: System replies (NETWRITE: Broken pipe) 
Reason: System replies (NETWRITE: Broken pipe) 
Reason: System replies (NETWRITE: Broken pipe) 
Reason: System replies (NETWRITE: Broken pipe) 
...

and after a while the memory got trashed, because the error return
handling of the NETWRITE in HTWriter.c is somehow broken. In my case,
I did get the memory trashing fixed by doing the following quick hack,
which apparently cleans up something better.

	*NOTE* The diff below is only to show the potential location
	of the error, it is not intended to be a fix. I don't know
	enough of the internals of libwww. Someone at W3C should take
	a look and publish a better fix!!! Some other places may also
	need to be fixed similarly!!!



*** HTWriter.c.orig	Tue Aug 20 07:54:40 1996
--- HTWriter.c	Mon Feb 10 13:21:12 1997
***************
*** 136,141 ****
--- 136,146 ----
  	    } else {
  		HTRequest_addSystemError(net->request, ERR_FATAL, socerrno, NO,
  					 "NETWRITE");
+ #ifdef NOT_ASCII
+ 		HT_FREE(me->ascbuf);
+ #else
+ 		me->write = NULL;
+ #endif
  		return HT_ERROR;
  	    }
  	}



---------------------

(*)	a different issue is: why this happens in the first place (why
	does wwwlib think the server should still be receiving; why
	did the server drop the link? Which one, server or libwww is
	doing something illegal in HTTP...?)
--
Markku Savela (msa@hemuli.tte.vtt.fi),     Technical Research Centre of Finland
Multimedia Systems, P.O.Box 1203,FIN-02044 VTT,http://www.vtt.fi/tte/staff/msa/

Received on Monday, 10 February 1997 06:50:41 UTC