From e57604183cf5a0fb9e99522cbd7f1548784d63a8 Mon Sep 17 00:00:00 2001 From: teor Date: Tue, 19 Sep 2017 14:17:35 +1000 Subject: [PATCH 1/2] When hibernating, close connections normally and allow them to flush Bugfix on 7267 in 0.2.4.7-alpha --- changes/bug23571 | 3 +++ src/or/hibernate.c | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changes/bug23571 diff --git a/changes/bug23571 b/changes/bug23571 new file mode 100644 index 0000000000..9d4c4082a4 --- /dev/null +++ b/changes/bug23571 @@ -0,0 +1,3 @@ + o Minor bugfixes (hibernation): + - When hibernating, close connections normally and allow them to flush. + Bugfix on 7267 in 0.2.4.7-alpha. diff --git a/src/or/hibernate.c b/src/or/hibernate.c index 8c48a6f47d..e60306a736 100644 --- a/src/or/hibernate.c +++ b/src/or/hibernate.c @@ -34,6 +34,7 @@ hibernating, phase 2: #include "config.h" #include "connection.h" #include "connection_edge.h" +#include "connection_or.h" #include "control.h" #include "hibernate.h" #include "main.h" @@ -914,7 +915,7 @@ hibernate_go_dormant(time_t now) END_STREAM_REASON_HIBERNATING); else if (conn->type == CONN_TYPE_OR) { if (TO_OR_CONN(conn)->chan) { - channel_mark_for_close(TLS_CHAN_TO_BASE(TO_OR_CONN(conn)->chan)); + connection_or_close_normally(TO_OR_CONN(conn), 0); } else { connection_mark_for_close(conn); } From e9f57e193d75f5c61b05dafb1c1585e5b1762866 Mon Sep 17 00:00:00 2001 From: teor Date: Tue, 19 Sep 2017 14:18:25 +1000 Subject: [PATCH 2/2] Consistently use braced blocks in hibernate_go_dormant() --- src/or/hibernate.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/or/hibernate.c b/src/or/hibernate.c index e60306a736..558180b459 100644 --- a/src/or/hibernate.c +++ b/src/or/hibernate.c @@ -907,20 +907,23 @@ hibernate_go_dormant(time_t now) while ((conn = connection_get_by_type(CONN_TYPE_OR)) || (conn = connection_get_by_type(CONN_TYPE_AP)) || (conn = connection_get_by_type(CONN_TYPE_EXIT))) { - if (CONN_IS_EDGE(conn)) + if (CONN_IS_EDGE(conn)) { connection_edge_end(TO_EDGE_CONN(conn), END_STREAM_REASON_HIBERNATING); + } log_info(LD_NET,"Closing conn type %d", conn->type); - if (conn->type == CONN_TYPE_AP) /* send socks failure if needed */ + if (conn->type == CONN_TYPE_AP) { + /* send socks failure if needed */ connection_mark_unattached_ap(TO_ENTRY_CONN(conn), END_STREAM_REASON_HIBERNATING); - else if (conn->type == CONN_TYPE_OR) { + } else if (conn->type == CONN_TYPE_OR) { if (TO_OR_CONN(conn)->chan) { connection_or_close_normally(TO_OR_CONN(conn), 0); } else { connection_mark_for_close(conn); } - } else + } else { connection_mark_for_close(conn); + } } if (now < interval_wakeup_time)