Pārlūkot izejas kodu

Fixed a bug when a safe_or_conn receives an "open" message

The safe_or_conn could receive an "open" message after it has
already closed (no longer in the link handshaking state). Instead
of crashing on an assert, we ignore the message if we're closed.
Steven Engler 5 gadi atpakaļ
vecāks
revīzija
1e3d76cfe3
1 mainītis faili ar 6 papildinājumiem un 2 dzēšanām
  1. 6 2
      src/core/or/safe_connection.c

+ 6 - 2
src/core/or/safe_connection.c

@@ -674,9 +674,13 @@ safe_or_conn_open_cb(event_label_t label, event_data_t data, void *context)
   tor_assert(label == or_conn_open_ev);
   tor_assert(safe_or_conn != NULL);
   tor_mutex_acquire(&TO_SAFE_CONN(safe_or_conn)->lock);
-  tor_assert(safe_or_conn->state == SAFE_OR_CONN_STATE_LINK_HANDSHAKING);
+  tor_assert(safe_or_conn->state == SAFE_OR_CONN_STATE_LINK_HANDSHAKING ||
+             safe_or_conn->state == SAFE_OR_CONN_STATE_CLOSED);
 
-  safe_or_connection_update_state(safe_or_conn, SAFE_OR_CONN_STATE_OPEN);
+  if (safe_or_conn->state != SAFE_OR_CONN_STATE_CLOSED) {
+    // if we're already closed, then just ignore it
+    safe_or_connection_update_state(safe_or_conn, SAFE_OR_CONN_STATE_OPEN);
+  }
 
   tor_mutex_release(&TO_SAFE_CONN(safe_or_conn)->lock);
 }