advice on leaking HTStreamStacks ?

I've found a leak of HTStream's as allocated from HTTPStatus_new() which
I'd like to solicit advice about the correct manner to address.  I expect
I might be doing something wrong in my use of libw3 so I'd appreciate
any help along these lines.

I'm writing a driver that will, for purposes of this mail, rerequest 
the same document some parameterized number of times.  To do this,
I use the HTNet_addAfter callback and call HTLoadAnchor() when
a request is finished.  I use the standard HTEventList_loop dispatch 
loop from my main() routine.

What I've found is that for noninitial requests, the HTNet->readStream
stream gets clobbered by the HTTPEvent state machine (state 
HTTP_NEED_STREAM, event HTEvent_WRITE).  There isn't a test in the
state machine or in the routine being called (HTNet_setReadStream)
to see if the read stream is already set prior to overwriting it's 
pointer with a newly created read stream.  [please see the dbx 
traceback at the end of this email for a stacktrace at the point 
where the stream pointer is about to be clobbered].

Is this a bug, or should my application be managing the read streams 
itself somehow before re-requesting the same URL?

Thanks for any advice or [heh] pointers!
  -mike bennett (mbennett@netcom.com)

========================================================
This is HTNet.c, CVS version 2.95 and HTTP.c, version 1.166.
Also, this is from a Solaris 2.6 SPARC system.
===
(dbx) where
=>[1] HTNet_setReadStream(net = 0x36180, stream = 0x38e90), line 1174 in "HTNet.c"
  [2] HTTPEvent(soc = 4, pVoid = 0x38e18, type = HTEvent_WRITE), line 1050 in "HTTP.c"
  [3] HostEvent(soc = 4, pVoid = 0x37b38, type = HTEvent_WRITE), line 251 in "HTHost.c"
  [4] EventOrder_executeAndDelete(0x0, 0x10008, 0x7ad61c2d, 0xefffebc4, 0xefffec44, 0x5), at 0xed9b356c
  [5] HTEventList_loop(0x2f5e8, 0x17658, 0x2ead8, 0x7530, 0x1, 0x1), at 0xed9b4f38
  [6] W3Lib::run(this = 0x2ead8), line 751 in "w3lib.cc"
  [7] main(argc = 4, argv = 0xefffeeb4), line 415 in "blaster.cc"
(dbx) list HTNet_setReadStream
 1168       return net->readStream;
 1169   }
 1170   
 1171   PUBLIC BOOL HTNet_setReadStream (HTNet * net, HTStream * stream)
 1172   {
 1173       if (net) {
 1174           net->readStream = stream;
 1175           return YES;
 1176       }
 1177       return NO;
 1178   }
(dbx) print *net
*net = {
    hash               = 1
    request            = 0x450c0
    host               = 0x37b38
    protocol           = 0x2fed8
    transport          = 0x2eda0
    session            = 0
    bytesRead          = 0
    headerBytesRead    = 0
    bytesWritten       = 147
    headerBytesWritten = 0
    connecttime        = 0
    preemptive         = '\0'
    event              = {
        priority = HT_PRIORITY_MAX
        millis   = 0
        cbf      = 0xed9a3020 = &`libwww.so.0`HTTP.c`HTTPEvent(int soc, void *pVoid, HTEventType type)
        param    = 0x38e18
        request  = (nil)
    }
    readStream         = 0x39008
    context            = 0x38e18
    registeredFor      = 0
}
(dbx) print stream
stream = 0x38e90
(dbx) up
Current function is HTTPEvent
 1050                   HTNet_setReadStream(net, me);
(dbx) print *http
*http = {
    state     = HTTP_NEED_STREAM
    next      = HTTP_ERROR
    result    = -1
    lock      = '\0'
    net       = 0x36180
    request   = 0x450c0
    timer     = (nil)
    usedTimer = '\0'
}
----------------------------

Received on Tuesday, 13 October 1998 14:19:25 UTC