aboutsummaryrefslogtreecommitdiff
path: root/src/common/util.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2003-09-14 02:58:50 +0000
committerRoger Dingledine <arma@torproject.org>2003-09-14 02:58:50 +0000
commite585dad88776719bd72faaa7225dbdec230c929a (patch)
treea95dffcb1840c6847c76ff27496f175c1bc50ec2 /src/common/util.c
parent429fb381f89fe6991837898cb0cb2cf456137edc (diff)
downloadtor-e585dad88776719bd72faaa7225dbdec230c929a.tar
tor-e585dad88776719bd72faaa7225dbdec230c929a.tar.gz
fix the cpuworker circ-had-vanished bug (maybe)
still several (many) tls-related bugs outstanding. svn:r454
Diffstat (limited to 'src/common/util.c')
-rw-r--r--src/common/util.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/common/util.c b/src/common/util.c
index 21584093c..c942c5d73 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -103,6 +103,21 @@ int write_all(int fd, const void *buf, size_t count) {
return count;
}
+/* a wrapper for read(2) that makes sure to read all count bytes.
+ * Only use if fd is a blocking socket. */
+int read_all(int fd, void *buf, size_t count) {
+ int numread = 0;
+ int result;
+
+ while(numread != count) {
+ result = read(fd, buf+numread, count-numread);
+ if(result<=0)
+ return -1;
+ numread += result;
+ }
+ return count;
+}
+
void set_socket_nonblocking(int socket)
{
#ifdef MS_WINDOWS