/** 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) {
}
#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",
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) {
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);
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;
}
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);
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;
* 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,
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 **********/
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)
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 **********/