do {
do {
rv = write(thefile->filedes, buf, *nbytes);
} while (rv == (apr_size_t)-1 && errno == EINTR);
if (rv == (apr_size_t)-1 &&
(errno == EAGAIN || errno == EWOULDBLOCK)) {
*nbytes /= 2;
}
else {
break;
}
} while (1);
}
}
#endif
if (rv == (apr_size_t)-1) {
(*nbytes) = 0;
return errno;
}
*nbytes = rv;
return APR_SUCCESS;
对于缓冲写入,其实现代码如下所示:
apr_size_t rv;
if (thefile->buffered) {
char *pos = (char *)buf;
int blocksize;
int size = *nbytes;
if ( thefile->direction == 0 ) {
apr_int64_t offset = thefile->filePtr - thefile->dataRead + thefile->bufpos;
if (offset != thefile->filePtr)
lseek(thefile->filedes, offset, SEEK_SET); u
thefile->bufpos = thefile->dataRead = 0;