diff options
author | Roger Dingledine <arma@torproject.org> | 2003-08-20 23:05:22 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2003-08-20 23:05:22 +0000 |
commit | 2dda97e8fd89875739b5f57f556c748ce7f5925f (patch) | |
tree | fbdaec39c6d49cf73f85ffff1997fd1a5ac96d1a /src/common | |
parent | d43f145ddfd48ef2ccfecabcb96d68061ba55a00 (diff) | |
download | tor-2dda97e8fd89875739b5f57f556c748ce7f5925f.tar.gz tor-2dda97e8fd89875739b5f57f556c748ce7f5925f.zip |
implemented cpuworkers
please poke at it and report bugs
still needs polishing, and only handles onions now (should handle
OR handshakes too)
svn:r402
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/util.c | 15 | ||||
-rw-r--r-- | src/common/util.h | 2 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/common/util.c b/src/common/util.c index 3a80b94da7..21584093ce 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -88,6 +88,21 @@ void tv_addms(struct timeval *a, long ms) { a->tv_usec %= 1000000; } +/* a wrapper for write(2) that makes sure to write all count bytes. + * Only use if fd is a blocking socket. */ +int write_all(int fd, const void *buf, size_t count) { + int written = 0; + int result; + + while(written != count) { + result = write(fd, buf+written, count-written); + if(result<0) + return -1; + written += result; + } + return count; +} + void set_socket_nonblocking(int socket) { #ifdef MS_WINDOWS diff --git a/src/common/util.h b/src/common/util.h index 614a5388a6..8552fb19a3 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -51,6 +51,8 @@ void tv_addms(struct timeval *a, long ms); void tv_add(struct timeval *a, struct timeval *b); int tv_cmp(struct timeval *a, struct timeval *b); +int write_all(int fd, const void *buf, size_t count); + void set_socket_nonblocking(int socket); /* Minimalist interface to run a void function in the background. On |