[Prev][Next][Index][Thread]

HTEvent_Loop: why stop at the first one?



I've been looking at some performance drags, and I noticed when
HTEvent_Loop finally gets around to dealing with pending sockets (in
__ProcessFds or HTEvent_Dispatch, whichever version you prefer to
use): [windows stuff omitted for clarity]

PRIVATE int __ProcessFds( fd_set * fdsp, SockOps ops, CONST char * str) 
{
    SOCKET s ;
    if (THD_TRACE)
	TTYPrint(TDEST, "Processing.. %s socket set. max_sock is %d\n",
		str, max_sock);
    
    for (s = 0 ; s <= max_sock; s++) {
        if (FD_ISSET( s, fdsp)) 
	return __DoCallback( s, ops);
    }
    return HT_OK;
}

basically, even if there are more than 1 set socket, you still quit
after having processed one. [note: this does mean that for every
EventLoop iteration, you can do one read AND one write (and one
exception!)].

I was wondering why this was chosen, vs. something like:

PRIVATE int __ProcessFds( fd_set * fdsp, SockOps ops, CONST char * str) 
{
    SOCKET s ;
    int e;
    if (THD_TRACE)
	TTYPrint(TDEST, "Processing.. %s socket set. max_sock is %d\n",
		str, max_sock);
    
    for (s = 0 ; s <= max_sock; s++) {
        if (FD_ISSET( s, fdsp)) 
	e = __DoCallback( s, ops);
        if (e != HT_OK) return e; /* error condition */
    }
    return HT_OK;
}

-Erik

-- 
				Erik Selberg
"I get by with a little help	selberg@cs.washington.edu
 from my friends."		http://www.cs.washington.edu/homes/selberg