RE: Bug fix to HTHost.c

I've had a problem like this; in HTEvtLst.c, HTEventList_Loop(), the 
select call returned -1, specifically an WSAEINVAL error. One of the 
sockets in the FdArray was invalid.

When going throught the logs, I noticed that one of the sockets *was* 
removed from the HashTable[], but *not* from the FdArray[]. Then I 
noticed that HTEventList_unregister(), called just before, logged this:

Event....... Socket 140 unregistered for HTEvent_READ
Event....... Couldn't find socket 140. Can't unregister type 
HTEvent_WRITE

Now, I don't know why the program can't unegister HTEvent_WRITE, but I 
do know that in this call the socket gets removed from the HashTable[], 
but not from the FdArray.

Another problem surfaced, sometimes one socket arose multiple times in 
the FdArray. I guess this should not be happening. Therefore, I changed 
the FD_CLR call in HTEventList_unregister to :

while (FD_ISSET(s,FdArray+HTEvent_INDEX(type)))
	FD_CLR(s, FdArray+HTEvent_INDEX(type));

which took care of the second problem, and I added the same lines to 
the last part of HTEventList_unregister:

	if (THD_TRACE) {
		if (ret == HT_ERROR){
			HTTRACE(THD_TRACE, "Event....... Couldn't find socket %d. 
...			while (FD_ISSET(s,FdArray+HTEvent_INDEX(type)))
				FD_CLR(s, FdArray+HTEvent_INDEX(type));
		}
	}
	return ret;
}

This fixed the problem as far as I know. It is not the correct fix, 
though. This just solved the symptoms, not the actual problem.

dd,
Mrten.

Received on Thursday, 25 May 2000 09:53:17 UTC