Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
David Goulet
Tor
Commits
0792cc10
Commit
0792cc10
authored
Nov 21, 2017
by
Nick Mathewson
🐻
Browse files
Convert connection_free to a nulling macro.
parent
a48ba072
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/or/circuitlist.c
View file @
0792cc10
...
...
@@ -1087,7 +1087,7 @@ circuit_free_all(void)
while
(
or_circ
->
resolving_streams
)
{
edge_connection_t
*
next_conn
;
next_conn
=
or_circ
->
resolving_streams
->
next_stream
;
connection_free
(
TO_CONN
(
or_circ
->
resolving_streams
));
connection_free
_
(
TO_CONN
(
or_circ
->
resolving_streams
));
or_circ
->
resolving_streams
=
next_conn
;
}
}
...
...
src/or/connection.c
View file @
0792cc10
/* Copyright (c) 2001 Matej Pfajfar.
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
* Copyright (c) 2007-2017, The Tor Project, Inc. */
...
...
@@ -675,7 +675,7 @@ connection_free_minimal(connection_t *conn)
/** Make sure <b>conn</b> isn't in any of the global conn lists; then free it.
*/
MOCK_IMPL
(
void
,
connection_free
,(
connection_t
*
conn
))
connection_free
_
,(
connection_t
*
conn
))
{
if
(
!
conn
)
return
;
...
...
src/or/connection.h
View file @
0792cc10
...
...
@@ -29,7 +29,8 @@ connection_t *connection_new(int type, int socket_family);
int
connection_init_accepted_conn
(
connection_t
*
conn
,
const
listener_connection_t
*
listener
);
void
connection_link_connections
(
connection_t
*
conn_a
,
connection_t
*
conn_b
);
MOCK_DECL
(
void
,
connection_free
,(
connection_t
*
conn
));
MOCK_DECL
(
void
,
connection_free_
,(
connection_t
*
conn
));
#define connection_free(conn) FREE_AND_NULL(connection, (conn))
void
connection_free_all
(
void
);
void
connection_about_to_close_connection
(
connection_t
*
conn
);
void
connection_close_immediate
(
connection_t
*
conn
);
...
...
src/or/connection_edge.c
View file @
0792cc10
...
...
@@ -3327,7 +3327,7 @@ handle_hs_exit_conn(circuit_t *circ, edge_connection_t *conn)
relay_send_end_cell_from_edge
(
conn
->
stream_id
,
circ
,
END_STREAM_REASON_DONE
,
origin_circ
->
cpath
->
prev
);
connection_free
(
TO_CONN
(
conn
));
connection_free
_
(
TO_CONN
(
conn
));
/* Drop the circuit here since it might be someone deliberately
* scanning the hidden service ports. Note that this mitigates port
...
...
@@ -3524,7 +3524,7 @@ connection_exit_begin_conn(cell_t *cell, circuit_t *circ)
if
(
we_are_hibernating
())
{
relay_send_end_cell_from_edge
(
rh
.
stream_id
,
circ
,
END_STREAM_REASON_HIBERNATING
,
NULL
);
connection_free
(
TO_CONN
(
n_stream
));
connection_free
_
(
TO_CONN
(
n_stream
));
return
0
;
}
...
...
@@ -3602,7 +3602,7 @@ connection_exit_begin_resolve(cell_t *cell, or_circuit_t *circ)
return
0
;
case
1
:
/* The result was cached; a resolved cell was sent. */
if
(
!
dummy_conn
->
base_
.
marked_for_close
)
connection_free
(
TO_CONN
(
dummy_conn
));
connection_free
_
(
TO_CONN
(
dummy_conn
));
return
0
;
case
0
:
/* resolve added to pending list */
assert_circuit_ok
(
TO_CIRCUIT
(
circ
));
...
...
@@ -3775,8 +3775,8 @@ connection_exit_connect_dir(edge_connection_t *exitconn)
if
(
connection_add
(
TO_CONN
(
exitconn
))
<
0
)
{
connection_edge_end
(
exitconn
,
END_STREAM_REASON_RESOURCELIMIT
);
connection_free
(
TO_CONN
(
exitconn
));
connection_free
(
TO_CONN
(
dirconn
));
connection_free
_
(
TO_CONN
(
exitconn
));
connection_free
_
(
TO_CONN
(
dirconn
));
return
0
;
}
...
...
@@ -3788,7 +3788,7 @@ connection_exit_connect_dir(edge_connection_t *exitconn)
connection_edge_end
(
exitconn
,
END_STREAM_REASON_RESOURCELIMIT
);
connection_close_immediate
(
TO_CONN
(
exitconn
));
connection_mark_for_close
(
TO_CONN
(
exitconn
));
connection_free
(
TO_CONN
(
dirconn
));
connection_free
_
(
TO_CONN
(
dirconn
));
return
0
;
}
...
...
src/or/connection_or.c
View file @
0792cc10
...
...
@@ -1247,7 +1247,7 @@ connection_or_connect, (const tor_addr_t *_addr, uint16_t port,
fmt_addrport
(
&
TO_CONN
(
conn
)
->
addr
,
TO_CONN
(
conn
)
->
port
));
}
connection_free
(
TO_CONN
(
conn
));
connection_free
_
(
TO_CONN
(
conn
));
return
NULL
;
}
...
...
@@ -1260,7 +1260,7 @@ connection_or_connect, (const tor_addr_t *_addr, uint16_t port,
connection_or_connect_failed
(
conn
,
errno_to_orconn_end_reason
(
socket_error
),
tor_socket_strerror
(
socket_error
));
connection_free
(
TO_CONN
(
conn
));
connection_free
_
(
TO_CONN
(
conn
));
return
NULL
;
case
0
:
connection_watch_events
(
TO_CONN
(
conn
),
READ_EVENT
|
WRITE_EVENT
);
...
...
src/or/dns.c
View file @
0792cc10
...
...
@@ -457,7 +457,7 @@ purge_expired_resolves(time_t now)
if
(
!
pendconn
->
base_
.
marked_for_close
)
{
connection_edge_end
(
pendconn
,
END_STREAM_REASON_TIMEOUT
);
circuit_detach_stream
(
circuit_get_by_edge_conn
(
pendconn
),
pendconn
);
connection_free
(
TO_CONN
(
pendconn
));
connection_free
_
(
TO_CONN
(
pendconn
));
}
tor_free
(
pend
);
}
...
...
@@ -670,7 +670,7 @@ dns_resolve(edge_connection_t *exitconn)
/* If we made the connection pending, then we freed it already in
* dns_cancel_pending_resolve(). If we marked it for close, it'll
* get freed from the main loop. Otherwise, can free it now. */
connection_free
(
TO_CONN
(
exitconn
));
connection_free
_
(
TO_CONN
(
exitconn
));
}
break
;
default:
...
...
@@ -1101,7 +1101,7 @@ dns_cancel_pending_resolve,(const char *address))
if
(
circ
)
circuit_detach_stream
(
circ
,
pendconn
);
if
(
!
pendconn
->
base_
.
marked_for_close
)
connection_free
(
TO_CONN
(
pendconn
));
connection_free
_
(
TO_CONN
(
pendconn
));
resolve
->
pending_connections
=
pend
->
next
;
tor_free
(
pend
);
}
...
...
@@ -1230,7 +1230,7 @@ inform_pending_connections(cached_resolve_t *resolve)
/* This detach must happen after we send the resolved cell. */
circuit_detach_stream
(
circuit_get_by_edge_conn
(
pendconn
),
pendconn
);
}
connection_free
(
TO_CONN
(
pendconn
));
connection_free
_
(
TO_CONN
(
pendconn
));
}
else
{
circuit_t
*
circ
;
if
(
pendconn
->
base_
.
purpose
==
EXIT_PURPOSE_CONNECT
)
{
...
...
@@ -1259,7 +1259,7 @@ inform_pending_connections(cached_resolve_t *resolve)
circ
=
circuit_get_by_edge_conn
(
pendconn
);
tor_assert
(
circ
);
circuit_detach_stream
(
circ
,
pendconn
);
connection_free
(
TO_CONN
(
pendconn
));
connection_free
_
(
TO_CONN
(
pendconn
));
}
}
resolve
->
pending_connections
=
pend
->
next
;
...
...
src/or/dnsserv.c
View file @
0792cc10
...
...
@@ -172,7 +172,7 @@ evdns_server_callback(struct evdns_server_request *req, void *data_)
if
(
connection_add
(
ENTRY_TO_CONN
(
entry_conn
))
<
0
)
{
log_warn
(
LD_APP
,
"Couldn't register dummy connection for DNS request"
);
evdns_server_request_respond
(
req
,
DNS_ERR_SERVERFAILED
);
connection_free
(
ENTRY_TO_CONN
(
entry_conn
));
connection_free
_
(
ENTRY_TO_CONN
(
entry_conn
));
return
;
}
...
...
@@ -249,7 +249,7 @@ dnsserv_launch_request(const char *name, int reverse,
if
(
connection_add
(
TO_CONN
(
conn
))
<
0
)
{
log_warn
(
LD_APP
,
"Couldn't register dummy connection for RESOLVE request"
);
connection_free
(
TO_CONN
(
conn
));
connection_free
_
(
TO_CONN
(
conn
));
return
-
1
;
}
...
...
src/test/test_dns.c
View file @
0792cc10
...
...
@@ -124,7 +124,7 @@ static int n_connection_free = 0;
static
connection_t
*
last_freed_conn
=
NULL
;
static
void
NS
(
connection_free
)(
connection_t
*
conn
)
NS
(
connection_free
_
)(
connection_t
*
conn
)
{
n_connection_free
++
;
...
...
@@ -267,7 +267,7 @@ NS(test_main)(void *arg)
*/
NS_MOCK
(
dns_cancel_pending_resolve
);
NS_MOCK
(
connection_free
);
NS_MOCK
(
connection_free
_
);
exitconn
->
on_circuit
=
&
(
on_circuit
->
base_
);
exitconn
->
base_
.
purpose
=
EXIT_PURPOSE_RESOLVE
;
...
...
@@ -294,7 +294,7 @@ NS(test_main)(void *arg)
NS_UNMOCK
(
send_resolved_cell
);
NS_UNMOCK
(
send_resolved_hostname_cell
);
NS_UNMOCK
(
dns_cancel_pending_resolve
);
NS_UNMOCK
(
connection_free
);
NS_UNMOCK
(
connection_free
_
);
tor_free
(
on_circuit
);
tor_free
(
exitconn
);
tor_free
(
nextconn
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment