aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/compat.c15
-rw-r--r--src/common/compat.h2
-rw-r--r--src/or/config.c10
-rw-r--r--src/or/directory.c8
-rw-r--r--src/or/main.c1
5 files changed, 22 insertions, 14 deletions
diff --git a/src/common/compat.c b/src/common/compat.c
index c3c3ca2a0a..66e55f9bea 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -362,7 +362,8 @@ tor_socketpair(int family, int type, int protocol, int fd[2])
/** Get the maximum allowed number of file descriptors. (Some systems
* have a low soft limit.) Make sure we set it to at least
* <b>*limit</b>. Return a new limit if we can, or -1 if we fail. */
-int set_max_file_descriptors(int limit, int cap) {
+int
+set_max_file_descriptors(unsigned long limit, unsigned long cap) {
#ifndef HAVE_GETRLIMIT
log_fn(LOG_INFO,"This platform is missing getrlimit(). Proceeding.");
if (limit > cap) {
@@ -371,7 +372,9 @@ int set_max_file_descriptors(int limit, int cap) {
}
#else
struct rlimit rlim;
- int most;
+ unsigned long most;
+ tor_assert(limit > 0);
+ tor_assert(cap > 0);
if (getrlimit(RLIMIT_NOFILE, &rlim) != 0) {
log_fn(LOG_WARN, "Could not get maximum number of file descriptors: %s",
@@ -379,13 +382,13 @@ int set_max_file_descriptors(int limit, int cap) {
return -1;
}
if (rlim.rlim_max < limit) {
- log_fn(LOG_WARN,"We need %d file descriptors available, and we're limited to %lu. Please change your ulimit -n.", limit, (unsigned long int)rlim.rlim_max);
+ log_fn(LOG_WARN,"We need %lu file descriptors available, and we're limited to %lu. Please change your ulimit -n.", limit, (unsigned long)rlim.rlim_max);
return -1;
}
- most = ((rlim.rlim_max > cap) ? cap : rlim.rlim_max);
+ most = (rlim.rlim_max > cap) ? cap : (unsigned) rlim.rlim_max;
if (most > rlim.rlim_cur) {
- log_fn(LOG_INFO,"Raising max file descriptors from %lu to %d.",
- (unsigned long int)rlim.rlim_cur, most);
+ log_fn(LOG_INFO,"Raising max file descriptors from %lu to %lu.",
+ (unsigned long)rlim.rlim_cur, most);
}
rlim.rlim_cur = most;
if (setrlimit(RLIMIT_NOFILE, &rlim) != 0) {
diff --git a/src/common/compat.h b/src/common/compat.h
index fbb44d0fa4..04ca605df0 100644
--- a/src/common/compat.h
+++ b/src/common/compat.h
@@ -197,7 +197,7 @@ void set_uint16(char *cp, uint16_t v);
void set_uint32(char *cp, uint32_t v);
#endif
-int set_max_file_descriptors(int limit, int cap);
+int set_max_file_descriptors(unsigned long limit, unsigned long cap);
int switch_id(char *user, char *group);
#ifdef HAVE_PWD_H
char *get_user_homedir(const char *username);
diff --git a/src/or/config.c b/src/or/config.c
index 5787b5dc04..d822f39141 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -317,7 +317,7 @@ options_act(void) {
add_callback_log(LOG_NOTICE, LOG_ERR, control_event_logmsg);
options->_ConnLimit =
- set_max_file_descriptors(options->ConnLimit, MAXCONNECTIONS);
+ set_max_file_descriptors((unsigned)options->ConnLimit, MAXCONNECTIONS);
if (options->_ConnLimit < 0)
return -1;
@@ -1183,7 +1183,7 @@ config_dump_options(or_options_t *options, int minimal)
}
static int
-validate_ports_csv(smartlist_t *sl, char *name) {
+validate_ports_csv(smartlist_t *sl, const char *name) {
int i;
int result = 0;
tor_assert(name);
@@ -1319,6 +1319,12 @@ options_validate(or_options_t *options)
result = -1;
}
+ if (options->ConnLimit <= 0) {
+ log(LOG_WARN, "ConnLimit must be greater than 0, but was set to %d",
+ options->ConnLimit);
+ result = -1;
+ }
+
if (options->_AccountingMaxKB) {
log(LOG_WARN, "AccountingMaxKB is deprecated. Say 'AccountingMax %d KB' instead.", options->_AccountingMaxKB);
options->AccountingMax = U64_LITERAL(1024)*options->_AccountingMaxKB;
diff --git a/src/or/directory.c b/src/or/directory.c
index 7ac34deceb..fd9fc6371d 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -28,10 +28,6 @@ const char directory_c_id[] = "$Id$";
* connection_finished_connecting() in connection.c
*/
-void
-directory_initiate_command_router(routerinfo_t *router, uint8_t purpose,
- int private_connection, const char *resource,
- const char *payload, size_t payload_len);
static void
directory_initiate_command_trusted_dir(trusted_dir_server_t *dirserv,
uint8_t purpose, int private_connection,
@@ -50,6 +46,7 @@ directory_send_command(connection_t *conn, const char *platform,
const char *payload, size_t payload_len);
static int directory_handle_command(connection_t *conn);
static int body_is_plausible(const char *body, size_t body_len, int purpose);
+static int purpose_is_private(uint8_t purpose);
/********* START VARIABLES **********/
@@ -112,7 +109,8 @@ int dir_policy_permits_address(uint32_t addr)
return 0;
}
-int purpose_is_private(uint8_t purpose) {
+static int
+purpose_is_private(uint8_t purpose) {
if (purpose == DIR_PURPOSE_FETCH_DIR ||
purpose == DIR_PURPOSE_UPLOAD_DIR ||
purpose == DIR_PURPOSE_FETCH_RUNNING_LIST)
diff --git a/src/or/main.c b/src/or/main.c
index 226a5aa76f..e013ee225f 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -40,6 +40,7 @@ static void conn_write_callback(int fd, short event, void *_conn);
static void signal_callback(int fd, short events, void *arg);
static void second_elapsed_callback(int fd, short event, void *args);
static int conn_close_if_marked(int i);
+void tor_free_all(void);
/********* START VARIABLES **********/