mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 14:23:30 +01:00
Add bufferevent support for outgoing connections; exits are now supported.
This commit is contained in:
parent
ddcb59bb70
commit
b63f6518cb
@ -192,6 +192,8 @@ connection_type_uses_bufferevent(connection_t *conn)
|
|||||||
switch (conn->type) {
|
switch (conn->type) {
|
||||||
case CONN_TYPE_AP:
|
case CONN_TYPE_AP:
|
||||||
return 1;
|
return 1;
|
||||||
|
case CONN_TYPE_EXIT:
|
||||||
|
return 1;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1342,7 +1344,7 @@ connection_connect(connection_t *conn, const char *address,
|
|||||||
escaped_safe_str_client(address),
|
escaped_safe_str_client(address),
|
||||||
port, inprogress?"in progress":"established", s);
|
port, inprogress?"in progress":"established", s);
|
||||||
conn->s = s;
|
conn->s = s;
|
||||||
if (connection_add(conn) < 0) /* no space, forget it */
|
if (connection_add_connecting(conn) < 0) /* no space, forget it */
|
||||||
return -1;
|
return -1;
|
||||||
return inprogress ? 0 : 1;
|
return inprogress ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,7 @@ int can_complete_circuit=0;
|
|||||||
* non-reading and non-writing.
|
* non-reading and non-writing.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
connection_add(connection_t *conn)
|
connection_add_impl(connection_t *conn, int is_connecting)
|
||||||
{
|
{
|
||||||
tor_assert(conn);
|
tor_assert(conn);
|
||||||
tor_assert(conn->s >= 0 ||
|
tor_assert(conn->s >= 0 ||
|
||||||
@ -179,7 +179,7 @@ connection_add(connection_t *conn)
|
|||||||
tor_libevent_get_base(),
|
tor_libevent_get_base(),
|
||||||
conn->s,
|
conn->s,
|
||||||
BEV_OPT_DEFER_CALLBACKS);
|
BEV_OPT_DEFER_CALLBACKS);
|
||||||
if (conn->inbuf) {
|
if (conn->inbuf) {
|
||||||
/* XXX Instead we should assert that there is no inbuf, once we
|
/* XXX Instead we should assert that there is no inbuf, once we
|
||||||
* have linked connections using bufferevents. */
|
* have linked connections using bufferevents. */
|
||||||
tor_assert(conn->outbuf);
|
tor_assert(conn->outbuf);
|
||||||
@ -189,8 +189,15 @@ connection_add(connection_t *conn)
|
|||||||
buf_free(conn->outbuf);
|
buf_free(conn->outbuf);
|
||||||
conn->inbuf = conn->outbuf = NULL;
|
conn->inbuf = conn->outbuf = NULL;
|
||||||
}
|
}
|
||||||
|
if (is_connecting) {
|
||||||
|
/* Put the bufferevent into a "connecting" state so that we'll get
|
||||||
|
* a "connected" event callback on successful write. */
|
||||||
|
bufferevent_socket_connect(conn->bufev, NULL, 0);
|
||||||
|
}
|
||||||
connection_configure_bufferevent_callbacks(conn);
|
connection_configure_bufferevent_callbacks(conn);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
(void) is_connecting;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!HAS_BUFFEREVENT(conn) && (conn->s >= 0 || conn->linked)) {
|
if (!HAS_BUFFEREVENT(conn) && (conn->s >= 0 || conn->linked)) {
|
||||||
|
@ -14,7 +14,9 @@
|
|||||||
|
|
||||||
extern int can_complete_circuit;
|
extern int can_complete_circuit;
|
||||||
|
|
||||||
int connection_add(connection_t *conn);
|
int connection_add_impl(connection_t *conn, int is_connecting);
|
||||||
|
#define connection_add(conn) connection_add_impl((conn), 0)
|
||||||
|
#define connection_add_connecting(conn) connection_add_impl((conn), 1)
|
||||||
int connection_remove(connection_t *conn);
|
int connection_remove(connection_t *conn);
|
||||||
void connection_unregister_events(connection_t *conn);
|
void connection_unregister_events(connection_t *conn);
|
||||||
int connection_in_array(connection_t *conn);
|
int connection_in_array(connection_t *conn);
|
||||||
|
Loading…
Reference in New Issue
Block a user