summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-08-01 13:15:58 -0400
committerNick Mathewson <nickm@torproject.org>2013-08-15 12:03:37 -0400
commitd7358e8598710a4b78274bddd371d036ad0d47ea (patch)
tree986d98bcabb0456dfcc1b98ad35226dfb4a8fbd5 /src
parentfd6749203ed9ca27263e895b53a12a6d15878cdd (diff)
downloadtor-d7358e8598710a4b78274bddd371d036ad0d47ea.tar.gz
tor-d7358e8598710a4b78274bddd371d036ad0d47ea.zip
Expose/mock some functions to make ext_orport.c testing possible
Diffstat (limited to 'src')
-rw-r--r--src/or/control.c4
-rw-r--r--src/or/control.h3
-rw-r--r--src/or/main.c23
-rw-r--r--src/or/main.h5
4 files changed, 25 insertions, 10 deletions
diff --git a/src/or/control.c b/src/or/control.c
index faf794204b..3a32ea6873 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -4699,8 +4699,8 @@ control_event_bootstrap(bootstrap_status_t status, int progress)
* that indicates a problem. <b>warn</b> gives a hint as to why, and
* <b>reason</b> provides an "or_conn_end_reason" tag.
*/
-void
-control_event_bootstrap_problem(const char *warn, int reason)
+MOCK_IMPL(void,
+control_event_bootstrap_problem, (const char *warn, int reason))
{
int status = bootstrap_percent;
const char *tag, *summary;
diff --git a/src/or/control.h b/src/or/control.h
index 288c286fee..3b2004bffe 100644
--- a/src/or/control.h
+++ b/src/or/control.h
@@ -85,7 +85,8 @@ void enable_control_logging(void);
void monitor_owning_controller_process(const char *process_spec);
void control_event_bootstrap(bootstrap_status_t status, int progress);
-void control_event_bootstrap_problem(const char *warn, int reason);
+MOCK_DECL(void, control_event_bootstrap_problem,(const char *warn,
+ int reason));
void control_event_clients_seen(const char *controller_str);
diff --git a/src/or/main.c b/src/or/main.c
index d1728250a4..20cc292fd5 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -10,6 +10,7 @@
* connections, implements main loop, and drives scheduled events.
**/
+#define MAIN_PRIVATE
#include "or.h"
#include "addressmap.h"
#include "buffers.h"
@@ -412,6 +413,19 @@ connection_unlink(connection_t *conn)
connection_free(conn);
}
+/** Initialize the global connection list, closeable connection list,
+ * and active connection list. */
+STATIC void
+init_connection_lists(void)
+{
+ if (!connection_array)
+ connection_array = smartlist_new();
+ if (!closeable_connection_lst)
+ closeable_connection_lst = smartlist_new();
+ if (!active_linked_connection_lst)
+ active_linked_connection_lst = smartlist_new();
+}
+
/** Schedule <b>conn</b> to be closed. **/
void
add_connection_to_closeable_list(connection_t *conn)
@@ -685,7 +699,7 @@ connection_stop_reading_from_linked_conn(connection_t *conn)
}
/** Close all connections that have been scheduled to get closed. */
-static void
+STATIC void
close_closeable_connections(void)
{
int i;
@@ -2307,12 +2321,7 @@ tor_init(int argc, char *argv[])
char buf[256];
int i, quiet = 0;
time_of_process_start = time(NULL);
- if (!connection_array)
- connection_array = smartlist_new();
- if (!closeable_connection_lst)
- closeable_connection_lst = smartlist_new();
- if (!active_linked_connection_lst)
- active_linked_connection_lst = smartlist_new();
+ init_connection_lists();
/* Have the log set up with our application name. */
tor_snprintf(buf, sizeof(buf), "Tor %s", get_version());
log_set_application_name(buf);
diff --git a/src/or/main.h b/src/or/main.h
index 85621a32bf..4aebe3eeee 100644
--- a/src/or/main.h
+++ b/src/or/main.h
@@ -69,5 +69,10 @@ int tor_main(int argc, char *argv[]);
int do_main_loop(void);
int tor_init(int argc, char **argv);
+#ifdef MAIN_PRIVATE
+STATIC void init_connection_lists(void);
+STATIC void close_closeable_connections(void);
+#endif
+
#endif