소스 검색

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 년 전
부모
커밋
1e3d76cfe3
1개의 변경된 파일6개의 추가작업 그리고 2개의 파일을 삭제
  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);
 }