浏览代码

Always defer bufferevent_openssl callbacks to avoid reentrant invocations

Nick Mathewson 15 年之前
父节点
当前提交
b7ae108e18
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      src/common/tortls.c

+ 6 - 2
src/common/tortls.c

@@ -1710,12 +1710,16 @@ tor_tls_init_bufferevent(tor_tls_t *tls, struct bufferevent *bufev_in,
     bufferevent_free(bufev_in);
   }
   tls->state = TOR_TLS_ST_BUFFEREVENT;
+
+  /* Current versions (as of 2.0.7-rc) of Libevent need to defer
+   * bufferevent_openssl callbacks, or else our callback functions will
+   * get called reentrantly, which is bad for us.
+   */
   out = bufferevent_openssl_socket_new(tor_libevent_get_base(),
                                        socket,
                                        tls->ssl,
                                        state,
-                                       0);
-                                       //BEV_OPT_DEFER_CALLBACKS);
+                                       BEV_OPT_DEFER_CALLBACKS);
 #endif
   return out;
 }