aboutsummaryrefslogtreecommitdiff
path: root/src/or/connection.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-07-16 16:23:36 +0000
committerNick Mathewson <nickm@torproject.org>2007-07-16 16:23:36 +0000
commit483c1e9017f4ac2ef4c0652e3402887578a265d6 (patch)
treeffa37ee6712d23e8ca81fc3996127c4f5413d340 /src/or/connection.c
parentf4a6673758385b9ce27a9913060dbd864d937461 (diff)
downloadtor-483c1e9017f4ac2ef4c0652e3402887578a265d6.tar
tor-483c1e9017f4ac2ef4c0652e3402887578a265d6.tar.gz
r13774@catbus: nickm | 2007-07-16 12:23:28 -0400
Tweaks on constrained socket buffers patch from coderman: Add a changelog; rename some variables; fix some long lines and whitespace; make ConstrainedSockSize a memunit; pass setsockopt a void. svn:r10843
Diffstat (limited to 'src/or/connection.c')
-rw-r--r--src/or/connection.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/or/connection.c b/src/or/connection.c
index e66a25267..4c555fc46 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -926,9 +926,8 @@ connection_handle_listener_read(connection_t *conn, int new_type)
set_socket_nonblocking(news);
- if (options->ConstrainedSockets) {
- set_constrained_socket_buffers (news, options->ConstrainedSockSize);
- }
+ if (options->ConstrainedSockets)
+ set_constrained_socket_buffers(news, (int)options->ConstrainedSockSize);
tor_assert(((struct sockaddr*)addrbuf)->sa_family == conn->socket_family);
@@ -1103,9 +1102,8 @@ connection_connect(connection_t *conn, const char *address,
set_socket_nonblocking(s);
- if (options->ConstrainedSockets) {
- set_constrained_socket_buffers (s, options->ConstrainedSockSize);
- }
+ if (options->ConstrainedSockets)
+ set_constrained_socket_buffers(s, (int)options->ConstrainedSockSize);
memset(&dest_addr,0,sizeof(dest_addr));
dest_addr.sin_family = AF_INET;
@@ -2561,17 +2559,17 @@ client_check_address_changed(int sock)
static void
set_constrained_socket_buffers(int sock, int size)
{
- if (setsockopt(sock, SOL_SOCKET, SO_SNDBUF, (const char *)&size, sizeof(size)) < 0) {
+ void *sz = (void*)&size;
+ if (setsockopt(sock, SOL_SOCKET, SO_SNDBUF, sz, sizeof(size)) < 0) {
int e = tor_socket_errno(sock);
- log_warn(LD_NET, "setsockopt() to constrain send buffer to %d bytes failed: %s",
- size, tor_socket_strerror(e));
+ log_warn(LD_NET, "setsockopt() to constrain send "
+ "buffer to %d bytes failed: %s", size, tor_socket_strerror(e));
}
- if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (const char *)&size, sizeof(size)) < 0) {
+ if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, sz, sizeof(size)) < 0) {
int e = tor_socket_errno(sock);
- log_warn(LD_NET, "setsockopt() to constrain recv buffer to %d bytes failed: %s",
- size, tor_socket_strerror(e));
+ log_warn(LD_NET, "setsockopt() to constrain recv "
+ "buffer to %d bytes failed: %s", size, tor_socket_strerror(e));
}
- return;
}
/** Process new bytes that have arrived on conn-\>inbuf.