bug in HTEvtLst.c

Hi,

there is a bug in the procedure EventListTimerHandler() in HTEvtLst.c.
There is missing a handler for the connect timeout. I guess the connenct
timeout is only of use under windows. Without that additional handler code,
the windows event based system stucks from time to time. Thus, we should add
it. Please check the code below. I added the code that is labeled /* Check
for connect timeout */.

Regards,

Jens


/*
**  Event timeout handler
**  If an event didn't occur before the timeout then call it explicitly
**  indicating that it timed out.
*/
PRIVATE int EventListTimerHandler (HTTimer * timer, void * param,
HTEventType type)
{
    SockEvents * sockp = (SockEvents *) param;
    HTEvent * event = NULL;
	int code;

    /* Check for read timeout */
    if (sockp->timeouts[HTEvent_INDEX(HTEvent_READ)] == timer) {
	event = sockp->events[HTEvent_INDEX(HTEvent_READ)];
	HTTRACE(THD_TRACE, "Event....... READ timed out on %d.\n" _
sockp->s);
	return (*event->cbf) (sockp->s, event->param, HTEvent_TIMEOUT);
    }

    /* Check for write timeout */
    if (sockp->timeouts[HTEvent_INDEX(HTEvent_WRITE)] == timer) {
	event = sockp->events[HTEvent_INDEX(HTEvent_WRITE)];
	HTTRACE(THD_TRACE, "Event....... WRITE timed out on %d.\n" _
sockp->s);
	return (*event->cbf) (sockp->s, event->param, HTEvent_TIMEOUT);
    }

    /* Check for connect timeout */
    if (sockp->timeouts[HTEvent_INDEX(HTEvent_CONNECT)] == timer) {
	event = sockp->events[HTEvent_INDEX(HTEvent_CONNECT)];
	HTTRACE(THD_TRACE, "Event....... CONNECT timed out on %d.\n" _
sockp->s);
	printf("Connect timed out!\n");
	code = (*event->cbf) (sockp->s, event->param, HTEvent_TIMEOUT);

	// delete event
	HTEventList_unregister (sockp->s, HTEvent_CONNECT);

	return code;
    }

    /* Check for out-of-band data timeout */
    if (sockp->timeouts[HTEvent_INDEX(HTEvent_OOB)] == timer) {
	event = sockp->events[HTEvent_INDEX(HTEvent_OOB)];
	HTTRACE(THD_TRACE, "Event....... OOB timed out on %d.\n" _
sockp->s);
	return (*event->cbf) (sockp->s, event->param, HTEvent_TIMEOUT);
    }
    HTTRACE(THD_TRACE, "Event....... No event for timer %p with context
%p\n" _ timer _ param);
    return HT_ERROR;
}


;---------------------------------------------------------------------
Jens Meggers
Director of Engineering

Firepad, Inc.
The Firepad Building
625 Ellis Street
Mountain View, California 94043-2225
Telephone (650) 237-3265
Facsimile (650) 237-3299
;---------------------------------------------------------------------

Received on Sunday, 25 March 2001 16:32:54 UTC