case ECONNRESET: case EPIPE: close_connection(cn); return -1; case EAGAIN: return 0; }
close_connection(cn); return -1;
static int read_connection(struct connection *cn){	size_t bytestoread, bytestomove, offset;	ssize_t nr;	bytestoread = cn->header_input.ceiling - cn->header_input.end;	if (bytestoread == 0) {		offset = cn->header_input.start - cn->header_input.floor;		if (offset == 0) {			log_d("input buffer full");			close_connection(cn);			return -1;		}		bytestomove = cn->header_input.end - cn->header_input.start;		memmove(cn->header_input.floor, cn->header_input.start, bytestomove);		cn->header_input.start -= offset;		cn->header_input.middle -= offset;		cn->header_input.end -= offset;		bytestoread = cn->header_input.ceiling - cn->header_input.end;	}	nr = read(cn->fd, cn->header_input.end, bytestoread);	if (debug)		log_d("read_connection: %d %d %d %d", cn->fd, cn->header_input.end - cn->header_input.floor, bytestoread, nr);	if (nr == -1) {		switch (errno) {		default:			log_d("error reading from %s[%hu]", inet_ntoa(cn->peer.sin_addr), ntohs(cn->peer.sin_port));			lerror("read");		case ECONNRESET:		case EPIPE:			close_connection(cn);			return -1;		case EAGAIN:			return 0;		}	}	if (nr == 0) {		close_connection(cn);		return -1;	}	cn->nread += nr;	cn->header_input.end += nr;	cn->t = current_time;	return 0;}