summaryrefslogtreecommitdiffstats
path: root/crypto/openssh/atomicio.c
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2011-05-04 07:34:44 +0000
committerdes <des@FreeBSD.org>2011-05-04 07:34:44 +0000
commitee2afa8165baec284a83500803978f8a0e645ccd (patch)
treea745d3c673d44775cc175961e80d2246eb00e0df /crypto/openssh/atomicio.c
parentd035dd6f462a261f9b99bfa8545a924b314e1bb5 (diff)
parent1824cfda46b3f11c1c3c4071e80b73ca91553149 (diff)
downloadFreeBSD-src-ee2afa8165baec284a83500803978f8a0e645ccd.zip
FreeBSD-src-ee2afa8165baec284a83500803978f8a0e645ccd.tar.gz
Upgrade to OpenSSH 5.8p2.
Diffstat (limited to 'crypto/openssh/atomicio.c')
-rw-r--r--crypto/openssh/atomicio.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/crypto/openssh/atomicio.c b/crypto/openssh/atomicio.c
index a6b2d12..601b3c3 100644
--- a/crypto/openssh/atomicio.c
+++ b/crypto/openssh/atomicio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: atomicio.c,v 1.25 2007/06/25 12:02:27 dtucker Exp $ */
+/* $OpenBSD: atomicio.c,v 1.26 2010/09/22 22:58:51 djm Exp $ */
/*
* Copyright (c) 2006 Damien Miller. All rights reserved.
* Copyright (c) 2005 Anil Madhavapeddy. All rights reserved.
@@ -48,7 +48,8 @@
* ensure all of data on socket comes through. f==read || f==vwrite
*/
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;
size_t pos = 0;
@@ -73,17 +74,28 @@ atomicio(ssize_t (*f) (int, void *, size_t), int fd, void *_s, size_t n)
return pos;
default:
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
*/
size_t
-atomiciov(ssize_t (*f) (int, const struct iovec *, int), int fd,
- const struct iovec *_iov, int iovcnt)
+atomiciov6(ssize_t (*f) (int, const struct iovec *, int), int fd,
+ const struct iovec *_iov, int iovcnt,
+ int (*cb)(void *, size_t), void *cb_arg)
{
size_t pos = 0, rem;
ssize_t res;
@@ -137,6 +149,17 @@ atomiciov(ssize_t (*f) (int, const struct iovec *, int), int fd,
iov[0].iov_base = ((char *)iov[0].iov_base) + rem;
iov[0].iov_len -= rem;
}
+ if (cb != NULL && cb(cb_arg, (size_t)res) == -1) {
+ errno = EINTR;
+ 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);
+}
OpenPOWER on IntegriCloud