summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/compat.c23
-rw-r--r--src/common/compat.h4
-rw-r--r--src/or/connection.c23
3 files changed, 6 insertions, 44 deletions
diff --git a/src/common/compat.c b/src/common/compat.c
index 354af77ea4..4a95a1ac12 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -415,17 +415,8 @@ tor_socketpair(int family, int type, int protocol, int fd[2])
}
listener = socket(AF_INET, type, 0);
- if (listener == -1)
+ if (listener < 0)
return -tor_socket_errno(-1);
- if (!SOCKET_IS_POLLABLE(listener)) {
- log_warn(LD_NET, "Too many connections; can't open socketpair");
- tor_close_socket(listener);
-#ifdef MS_WINDOWS
- return -ENFILE;
-#else
- return -ENCONN;
-#endif
- }
memset(&listen_addr, 0, sizeof(listen_addr));
listen_addr.sin_family = AF_INET;
listen_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
@@ -437,12 +428,8 @@ tor_socketpair(int family, int type, int protocol, int fd[2])
goto tidy_up_and_fail;
connector = socket(AF_INET, type, 0);
- if (connector == -1)
+ if (connector < 0)
goto tidy_up_and_fail;
- if (!SOCKET_IS_POLLABLE(connector)) {
- log_warn(LD_NET, "Too many connections; can't open socketpair");
- goto tidy_up_and_fail;
- }
/* We want to find out the port number to connect to. */
size = sizeof(connect_addr);
if (getsockname(listener, (struct sockaddr *) &connect_addr, &size) == -1)
@@ -455,12 +442,8 @@ tor_socketpair(int family, int type, int protocol, int fd[2])
size = sizeof(listen_addr);
acceptor = accept(listener, (struct sockaddr *) &listen_addr, &size);
- if (acceptor == -1)
+ if (acceptor < 0)
goto tidy_up_and_fail;
- if (!SOCKET_IS_POLLABLE(acceptor)) {
- log_warn(LD_NET, "Too many connections; can't open socketpair");
- goto tidy_up_and_fail;
- }
if (size != sizeof(listen_addr))
goto abort_tidy_up_and_fail;
tor_close_socket(listener);
diff --git a/src/common/compat.h b/src/common/compat.h
index 6116264d79..b70963b4be 100644
--- a/src/common/compat.h
+++ b/src/common/compat.h
@@ -175,10 +175,6 @@ int touch_file(const char *fname);
typedef int socklen_t;
#endif
-/* Now that we use libevent, all real sockets are safe for polling ... or
- * if they aren't, libevent will help us. */
-#define SOCKET_IS_POLLABLE(fd) ((fd)>=0)
-
struct in_addr;
int tor_inet_aton(const char *cp, struct in_addr *addr);
int tor_lookup_hostname(const char *name, uint32_t *addr);
diff --git a/src/or/connection.c b/src/or/connection.c
index a28d625673..6a89891dce 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -532,10 +532,6 @@ connection_create_listener(const char *listenaddress, uint16_t listenport,
if (s < 0) {
log_warn(LD_NET,"Socket creation failed.");
goto err;
- } else if (!SOCKET_IS_POLLABLE(s)) {
- log_warn(LD_NET,"Too many connections; can't create pollable listener.");
- tor_close_socket(s);
- goto err;
}
#ifndef MS_WINDOWS
@@ -635,16 +631,9 @@ connection_handle_listener_read(connection_t *conn, int new_type)
memset(addrbuf, 0, sizeof(addrbuf));
news = accept(conn->s,(struct sockaddr *)&addrbuf,&remotelen);
- if (!SOCKET_IS_POLLABLE(news)) {
- /* accept() error, or too many conns to poll */
- int e;
- if (news>=0) {
- /* Too many conns to poll. */
- log_warn(LD_NET,"Too many connections; couldn't accept connection.");
- tor_close_socket(news);
- return 0;
- }
- e = tor_socket_errno(conn->s);
+ if (news < 0) {
+ /* accept() error */
+ int e = tor_socket_errno(conn->s);
if (ERRNO_IS_ACCEPT_EAGAIN(e)) {
return 0; /* he hung up before we could accept(). that's fine. */
} else if (ERRNO_IS_ACCEPT_RESOURCE_LIMIT(e)) {
@@ -771,12 +760,6 @@ connection_connect(connection_t *conn, char *address,
log_warn(LD_NET,"Error creating network socket: %s",
tor_socket_strerror(tor_socket_errno(-1)));
return -1;
- } else if (!SOCKET_IS_POLLABLE(s)) {
- log_warn(LD_NET,
- "Too many connections; can't create pollable connection to %s",
- escaped_safe_str(address));
- tor_close_socket(s);
- return -1;
}
if (options->OutboundBindAddress) {