mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-03 00:53:32 +01:00
Fix some XXXXs in connection_add_impl related to bufferevent error checking
This might make bufferevents more asserty for a while, but they should make other bugs less likely to go unnoticed. Noted by Sebastian.
This commit is contained in:
parent
3d10c89201
commit
3af12a5557
@ -161,7 +161,7 @@ int can_complete_circuit=0;
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef USE_BUFFEREVENTS
|
#if 0 && defined(USE_BUFFEREVENTS)
|
||||||
static void
|
static void
|
||||||
free_old_inbuf(connection_t *conn)
|
free_old_inbuf(connection_t *conn)
|
||||||
{
|
{
|
||||||
@ -211,7 +211,12 @@ connection_add_impl(connection_t *conn, int is_connecting)
|
|||||||
tor_libevent_get_base(),
|
tor_libevent_get_base(),
|
||||||
conn->s,
|
conn->s,
|
||||||
BEV_OPT_DEFER_CALLBACKS);
|
BEV_OPT_DEFER_CALLBACKS);
|
||||||
/* XXXX CHECK FOR NULL RETURN! */
|
if (!conn->bufev) {
|
||||||
|
log_warn(LD_BUG, "Unable to create socket bufferevent");
|
||||||
|
smartlist_del(connection_array, conn->conn_array_index);
|
||||||
|
conn->conn_array_index = -1;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if (is_connecting) {
|
if (is_connecting) {
|
||||||
/* Put the bufferevent into a "connecting" state so that we'll get
|
/* Put the bufferevent into a "connecting" state so that we'll get
|
||||||
* a "connected" event callback on successful write. */
|
* a "connected" event callback on successful write. */
|
||||||
@ -223,10 +228,14 @@ connection_add_impl(connection_t *conn, int is_connecting)
|
|||||||
tor_assert(conn->s < 0);
|
tor_assert(conn->s < 0);
|
||||||
if (!conn->bufev) {
|
if (!conn->bufev) {
|
||||||
struct bufferevent *pair[2] = { NULL, NULL };
|
struct bufferevent *pair[2] = { NULL, NULL };
|
||||||
/* XXXX CHECK FOR ERROR RETURN! */
|
if (bufferevent_pair_new(tor_libevent_get_base(),
|
||||||
bufferevent_pair_new(tor_libevent_get_base(),
|
|
||||||
BEV_OPT_DEFER_CALLBACKS,
|
BEV_OPT_DEFER_CALLBACKS,
|
||||||
pair);
|
pair) < 0) {
|
||||||
|
log_warn(LD_BUG, "Unable to create bufferevent pair");
|
||||||
|
smartlist_del(connection_array, conn->conn_array_index);
|
||||||
|
conn->conn_array_index = -1;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
tor_assert(pair[0]);
|
tor_assert(pair[0]);
|
||||||
conn->bufev = pair[0];
|
conn->bufev = pair[0];
|
||||||
conn->linked_conn->bufev = pair[1];
|
conn->linked_conn->bufev = pair[1];
|
||||||
@ -236,18 +245,11 @@ connection_add_impl(connection_t *conn, int is_connecting)
|
|||||||
tor_assert(!conn->linked);
|
tor_assert(!conn->linked);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conn->bufev && conn->inbuf) {
|
if (conn->bufev)
|
||||||
/* XXX Instead we should assert that there is no inbuf, once we
|
tor_assert(conn->inbuf == NULL);
|
||||||
* have linked connections using bufferevents. */
|
|
||||||
free_old_inbuf(conn);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (conn->linked_conn && conn->linked_conn->bufev &&
|
if (conn->linked_conn && conn->linked_conn->bufev)
|
||||||
conn->linked_conn->inbuf) {
|
tor_assert(conn->linked_conn->inbuf == NULL);
|
||||||
/* XXX Instead we should assert that there is no inbuf, once we
|
|
||||||
* have linked connections using bufferevents. */
|
|
||||||
free_old_inbuf(conn->linked_conn);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
(void) is_connecting;
|
(void) is_connecting;
|
||||||
|
Loading…
Reference in New Issue
Block a user