aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-06-27 10:50:24 -0400
committerNick Mathewson <nickm@torproject.org>2018-06-27 12:01:11 -0400
commit356f59b1bd66dc1db44e438846aaf431381743db (patch)
tree8ae85d4b723297b4e4897c2be3873719d3f8cf7a /src/common
parent67135ca8e041ac922d1045fe833c8052e652e5e7 (diff)
downloadtor-356f59b1bd66dc1db44e438846aaf431381743db.tar.gz
tor-356f59b1bd66dc1db44e438846aaf431381743db.zip
Move read/write_all_to_socket into lib/net.
Diffstat (limited to 'src/common')
-rw-r--r--src/common/util.c43
-rw-r--r--src/common/util.h2
2 files changed, 0 insertions, 45 deletions
diff --git a/src/common/util.c b/src/common/util.c
index 2d426bb136..940f25e275 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -1094,24 +1094,6 @@ write_all_to_fd(int fd, const char *buf, size_t count)
return (ssize_t)count;
}
-/** Write <b>count</b> bytes from <b>buf</b> to <b>sock</b>. Return the number
- * of bytes written, or -1 on error. Only use if fd is a blocking fd. */
-ssize_t
-write_all_to_socket(tor_socket_t fd, const char *buf, size_t count)
-{
- size_t written = 0;
- ssize_t result;
- raw_assert(count < SSIZE_MAX);
-
- while (written != count) {
- result = tor_socket_send(fd, buf+written, count-written, 0);
- if (result<0)
- return -1;
- written += result;
- }
- return (ssize_t)count;
-}
-
/** Read from <b>fd</b> to <b>buf</b>, until we get <b>count</b> bytes or
* reach the end of the file. Return the number of bytes read, or -1 on
* error. Only use if fd is a blocking fd. */
@@ -1137,31 +1119,6 @@ read_all_from_fd(int fd, char *buf, size_t count)
return (ssize_t)numread;
}
-/** Read from <b>sock</b> to <b>buf</b>, until we get <b>count</b> bytes or
- * reach the end of the file. Return the number of bytes read, or -1 on
- * error. Only use if fd is a blocking fd. */
-ssize_t
-read_all_from_socket(tor_socket_t sock, char *buf, size_t count)
-{
- size_t numread = 0;
- ssize_t result;
-
- if (count > SIZE_T_CEILING || count > SSIZE_MAX) {
- errno = EINVAL;
- return -1;
- }
-
- while (numread < count) {
- result = tor_socket_recv(sock, buf+numread, count-numread, 0);
- if (result<0)
- return -1;
- else if (result == 0)
- break;
- numread += result;
- }
- return (ssize_t)numread;
-}
-
/*
* Filesystem operations.
*/
diff --git a/src/common/util.h b/src/common/util.h
index 1cb3e73b32..b7ac2a1761 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -118,9 +118,7 @@ int format_time_interval(char *out, size_t out_len, long interval);
/* File helpers */
ssize_t write_all_to_fd(int fd, const char *buf, size_t count);
-ssize_t write_all_to_socket(tor_socket_t fd, const char *buf, size_t count);
ssize_t read_all_from_fd(int fd, char *buf, size_t count);
-ssize_t read_all_from_socket(tor_socket_t fd, char *buf, size_t count);
#define write_all(fd, buf, count, isSock) \
((isSock) ? write_all_to_socket((fd), (buf), (count)) \