version 1.25, 2007/06/25 12:02:27 |
version 1.26, 2010/09/22 22:58:51 |
|
|
* ensure all of data on socket comes through. f==read || f==vwrite |
* ensure all of data on socket comes through. f==read || f==vwrite |
*/ |
*/ |
size_t |
size_t |
atomicio(ssize_t (*f) (int, void *, size_t), int fd, void *_s, size_t n) |
atomicio6(ssize_t (*f) (int, void *, size_t), int fd, void *_s, size_t n, |
|
int (*cb)(void *, size_t), void *cb_arg) |
{ |
{ |
char *s = _s; |
char *s = _s; |
size_t pos = 0; |
size_t pos = 0; |
|
|
return pos; |
return pos; |
default: |
default: |
pos += (size_t)res; |
pos += (size_t)res; |
|
if (cb != NULL && cb(cb_arg, (size_t)res) == -1) { |
|
errno = EINTR; |
|
return pos; |
|
} |
} |
} |
} |
} |
return (pos); |
return pos; |
} |
} |
|
|
|
size_t |
|
atomicio(ssize_t (*f) (int, void *, size_t), int fd, void *_s, size_t n) |
|
{ |
|
return atomicio6(f, fd, _s, n, NULL, NULL); |
|
} |
|
|
/* |
/* |
* ensure all of data on socket comes through. f==readv || f==writev |
* ensure all of data on socket comes through. f==readv || f==writev |
*/ |
*/ |
size_t |
size_t |
atomiciov(ssize_t (*f) (int, const struct iovec *, int), int fd, |
atomiciov6(ssize_t (*f) (int, const struct iovec *, int), int fd, |
const struct iovec *_iov, int iovcnt) |
const struct iovec *_iov, int iovcnt, |
|
int (*cb)(void *, size_t), void *cb_arg) |
{ |
{ |
size_t pos = 0, rem; |
size_t pos = 0, rem; |
ssize_t res; |
ssize_t res; |
|
|
iov[0].iov_base = ((char *)iov[0].iov_base) + rem; |
iov[0].iov_base = ((char *)iov[0].iov_base) + rem; |
iov[0].iov_len -= rem; |
iov[0].iov_len -= rem; |
} |
} |
|
if (cb != NULL && cb(cb_arg, (size_t)res) == -1) { |
|
errno = EINTR; |
|
return pos; |
|
} |
} |
} |
return pos; |
return pos; |
|
} |
|
|
|
size_t |
|
atomiciov(ssize_t (*f) (int, const struct iovec *, int), int fd, |
|
const struct iovec *_iov, int iovcnt) |
|
{ |
|
return atomiciov6(f, fd, _iov, iovcnt, NULL, NULL); |
} |
} |