From 7ab3004223bd61f8ad1c573b309c63824e038528 Mon Sep 17 00:00:00 2001 From: Andrea Shepard Date: Tue, 13 Nov 2012 13:45:00 -0800 Subject: [PATCH 1/3] Call channel_mark_for_close() properly in hibernate_go_dormant() --- src/or/hibernate.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/or/hibernate.c b/src/or/hibernate.c index b33e5e216c..9e54eb4b4c 100644 --- a/src/or/hibernate.c +++ b/src/or/hibernate.c @@ -23,6 +23,8 @@ hibernating, phase 2: #define HIBERNATE_PRIVATE #include "or.h" +#include "channel.h" +#include "channeltls.h" #include "config.h" #include "connection.h" #include "connection_edge.h" @@ -846,7 +848,13 @@ hibernate_go_dormant(time_t now) if (conn->type == CONN_TYPE_AP) /* send socks failure if needed */ connection_mark_unattached_ap(TO_ENTRY_CONN(conn), END_STREAM_REASON_HIBERNATING); - else + 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)); + } else { + connection_mark_for_close(conn); + } + } else connection_mark_for_close(conn); } From 3b517ea5f467fd941cdb0fcefb088e706d8c04d0 Mon Sep 17 00:00:00 2001 From: Andrea Shepard Date: Tue, 13 Nov 2012 13:46:36 -0800 Subject: [PATCH 2/3] Add changes file for bug 7267 --- changes/bug7267 | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 changes/bug7267 diff --git a/changes/bug7267 b/changes/bug7267 new file mode 100644 index 0000000000..7089329f4f --- /dev/null +++ b/changes/bug7267 @@ -0,0 +1,4 @@ + - Major bugfixes + o Call channel_mark_for_close() rather than connection_mark_for_close() + in hibernate_go_dormant() when closing an or_connection_t. Fixes bug + 7267. From 3db3daa663e9fe41f87993f4580cf3a8e6bab27c Mon Sep 17 00:00:00 2001 From: Andrea Shepard Date: Tue, 13 Nov 2012 18:50:37 -0800 Subject: [PATCH 3/3] Add comment explaining different channel close functions --- src/or/channel.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/or/channel.c b/src/or/channel.c index 16dd9f903a..625d957811 100644 --- a/src/or/channel.c +++ b/src/or/channel.c @@ -1057,6 +1057,19 @@ channel_set_cell_handlers(channel_t *chan, chan->var_cell_handler)) channel_process_cells(chan); } +/* + * On closing channels + * + * There are three functions that close channels, for use in + * different circumstances: + * + * - Use channel_mark_for_close() for most cases + * - Use channel_close_from_lower_layer() if you are connection_or.c + * and the other end closes the underlying connection. + * - Use channel_close_for_error() if you are connection_or.c and + * some sort of error has occurred. + */ + /** * Mark a channel for closure *