log_d("accept_connection: fd=%d", fd);
log_d("accept_connection: %d", fd);
static int accept_connection(struct server *s){	struct sockaddr_in sa_remote, sa_local;	socklen_t l;	int fd;	struct connection *cn;	do {		if (available_connections == 0)			return 0;		l = sizeof sa_remote;		fd = accept(s->fd, (struct sockaddr *) &sa_remote, &l);		if (fd == -1) {			if (errno != EAGAIN) {				lerror("accept");				return -1;			}			return 0;		}		if (debug)			log_d("accept_connection: fd=%d", fd);		s->naccepts++;		fcntl(fd, F_SETFD, FD_CLOEXEC);		fcntl(fd, F_SETFL, O_NONBLOCK);		l = sizeof sa_local;		if (getsockname(fd, (struct sockaddr *) &sa_local, &l) == -1) {			lerror("getsockname");			close(fd);			break;		}		cn = find_connection();		if (cn == 0) {			log_d("connection to %s[%hu] dropped", inet_ntoa(sa_remote.sin_addr), ntohs(sa_remote.sin_port));			close(fd);		} else {			s->nhandled++;			cn->state = HC_ACTIVE;			cn->s = s;			cn->fd = fd;			cn->rfd = -1;			cn->peer = sa_remote;			cn->sock = sa_local;			cn->t = current_time;			++nconnections;			if (nconnections > maxconnections)				maxconnections = nconnections;			init_connection(cn);			cn->logged = 0;			cn->action = HC_WAITING;		}	} while (tuning.accept_multi);	return 0;}