if (debug) log_d("add_fd: open(\"%s\") = %d", filename, fd);
static int add_fd(struct request *r, const char *filename){	int fd, rv;	struct stat s;	if (filename == 0)		return -1;	if (get_mime(r, filename) == -1)		return -1;	fd = open(filename, O_RDONLY);	if (debug)		log_d("add_fd: open(\"%s\") = %d", filename, fd);	if (fd == -1)		return -1;	rv = fstat(fd, &s);	if (debug) {		if (rv == -1)			log_d("add_fd: fstat(%d) = %d", fd, rv);		else			log_d("add_fd: fstat(%d) = %d; st_mode = %#o", fd, rv, s.st_mode);	}	if (!S_ISREG(s.st_mode)) {		log_d("non-plain file %s", filename);		rv = close(fd);		if (debug)			log_d("add_fd: close(%d) = rv", fd);		return -1;	}	rv = fcntl(fd, F_SETFD, FD_CLOEXEC);	if (debug)		log_d("add_fd: fcntl(%d, F_SETFD, FD_CLOEXEC) = %d", fd, rv);	r->cn->rfd = fd;	r->content_length = s.st_size;	return 0;}