Solution for possible crash if using SSL

Hi,

I ran into serious trouble when using a CGI-programm that (not only)
forwards
requests via Libwww and SSL. Every 100th request I got a core dump.
Eventually I found out that there is a recursive function call. To cut a
long
story short: HTHost_forceFlush -> HTTPEvent_Flush ->
HTBufferWriter_lazyFlush
-> HTSSLWriter_write -> HTSSLReader_read -> HTHost_forceFlush
If your machine is fast enough (mine was) this can cause a stack overflow.
I stopped the recursion by changing HTHost_forceFlush to the following:

PUBLIC int HTHost_forceFlush(HTHost * host)
{
    static BOOL in_flush=NO;
    HTNet * targetNet = (HTNet *) HTList_lastObject(host->pipeline);
    int ret;
    if (in_flush || targetNet == NULL) return HT_ERROR;
    HTTRACE(CORE_TRACE, "Host Event.. FLUSH passed to `%s\'\n" _
 
HTAnchor_physical(HTRequest_anchor(HTNet_request(targetNet))));
    host->forceWriteFlush = in_flush = YES;
    while ((ret = (*targetNet->event.cbf)(HTChannel_socket(host->channel),
targetNet->event.param, Event_FLUSH))==HT_WOULD_BLOCK);
    host->forceWriteFlush = in_flush = NO;
    return ret;
}

Until now I found no side effect.

Regards, Heiner

Received on Wednesday, 26 July 2000 08:09:44 UTC