httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc Slemko <ma...@znep.com>
Subject Re: Threaded Apache and lingering_close
Date Sat, 01 Feb 1997 01:09:57 GMT
On Fri, 31 Jan 1997, Jim Jagielski wrote:

> The last version of RSTs threaded apache included some handling
> of a lingering_close... below I've condense the info:
[...]

>     
>     switch (rec->state) {
>     case fd_linger:
> 	/* Sometimes clients chase a genuine request with a few trash
> 	 * newlines... be prepared for that.  (NB we couldn't treat it
> 	 * as a request even if we wanted to --- we've already shut down
> 	 * our half of the connection as the first step in a lingering close).
> 	 */
> 
> 	if (ioctl (rec->fd, FIONREAD, (void *)&numrd) >= 0
> 	    && numrd > 0)
> 	{
> 	    /* Client sent extra junk.  Get rid of it.
> 	     * On error, lose the connection; we don't need the trouble
> 	     * (especially since the client is clearly deranged to begin with).
> 	     */
> 	    char junkbuf[256];
> 	    if (read (rec->fd, junkbuf, sizeof(junkbuf)) <= 0) {
> 		log_unixerr("read from half-closed connection",
> 			    NULL, NULL, server_conf);
> 		shutdown (rec->fd, 2);
> 		close (rec->fd);
> 		set_fd_state (fd_closed, rec->fd, NULL, NULL);
> 	    }
> 	}
> 	else {
> 	    /* Got client ack, have EOF.  Can close safely now. */
> 	    close (rec->fd);
> 	    set_fd_state (fd_closed, rec->fd, NULL, NULL);
> 	}
> 	break;

It looks like the only major thing we are doing differently (well,
aside from completely different request handling) is it does an
ioctl to check if anything is waiting for read, we loop in a select().
The reasons for using an ioctl in the above loop are fairly obvious,
although I guess a select could have done a poll.


Mime
View raw message