aboutsummaryrefslogtreecommitdiff
path: root/src/or/connection.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/or/connection.c')
-rw-r--r--src/or/connection.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/or/connection.c b/src/or/connection.c
index e0455ef95..7cbdff955 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -13,6 +13,7 @@
/********* START VARIABLES **********/
extern or_options_t options; /* command-line and config-file options */
+extern int shutting_down; /* whether we should refuse new connections */
/** Array of strings to make conn-\>type human-readable. */
char *conn_type_to_string[] = {
@@ -402,6 +403,13 @@ static int connection_handle_listener_read(connection_t *conn, int new_type) {
}
log(LOG_INFO,"Connection accepted on socket %d (child of fd %d).",news, conn->s);
+ if(shutting_down && new_type != CONN_TYPE_DIR) {
+ /* allow directory connections even while we're shutting down */
+ log(LOG_INFO,"But we're shutting down, so closing (type %d).", new_type);
+ tor_close_socket(news);
+ return 0;
+ }
+
set_socket_nonblocking(news);
newconn = connection_new(new_type);