httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dean Gaudet <dgau...@arctic.org>
Subject Re: [PATCH] Big fixes to main loop, lingering_close
Date Sat, 15 Feb 1997 20:17:42 GMT
(Still reviewing the patch.)

Just a side note about this code from l_c:

#ifdef SELECT_NEEDS_CAST
        select_rv = select(lsd+1, (int*)&fds_read, NULL, (int*)&fds_err,
&tv);
#else
        select_rv = select(lsd+1, &fds_read, NULL, &fds_err, &tv);
#endif
    } while ((select_rv > 0) &&           /* Something to see on socket */
             !FD_ISSET(lsd, &fds_err) &&   /* that isn't an error condition */
             FD_ISSET(lsd, &fds_read) &&   /* and is worth trying to read */
             ((read_rv = read(lsd, dummybuf, sizeof dummybuf)) > 0));

On Linux, a select() on an fd which has "EOF in the queue" will return
the fd bit in both the read and exception sets (i.e. there's still data
to be read, but the Unix knows for certain that the other end has gone
away on pipes or sockets).  I haven't seen any other Unix do this --
but I did run into it in my mud code when using pipe()s.

At this point the code would proceed with the close().  Since the kernel
has already received the data, everything might just work "correctly"
without us having to even read() it.

But otherwise a change like the following would be required:

#ifdef SELECT_NEEDS_CAST
        select_rv = select(lsd+1, (int*)&fds_read, NULL, (int*)&fds_err,
&tv);
#else
        select_rv = select(lsd+1, &fds_read, NULL, &fds_err, &tv);
#endif
	if( select_rv <= 0 ) {
	    break;
	}
	/* is there something to read? */
        if( FD_ISSET(lsd, &fds_read) &&
             ((read_rv = read(lsd, dummybuf, sizeof dummybuf)) > 0) ) {
	    continue;
	}
	/* is there an exceptional condition? */
	if( read_rv < 0 || FD_ISSET(lsd, &fds_err) ) {
	    break;
	}
    }

I've always been confused about the except set, isn't it overloaded to mean
both error or out-of-band data?

Dean


Mime
View raw message