[or-cvs] Move most of *_mark_for_close out of macros.
Nick Mathewson
nickm at seul.org
Sun Apr 3 05:22:38 UTC 2005
Update of /home/or/cvsroot/tor/src/or
In directory moria.mit.edu:/tmp/cvs-serv28556/src/or
Modified Files:
circuitlist.c connection.c connection_edge.c or.h
Log Message:
Move most of *_mark_for_close out of macros.
Index: circuitlist.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/circuitlist.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- circuitlist.c 1 Apr 2005 20:15:55 -0000 1.35
+++ circuitlist.c 3 Apr 2005 05:22:33 -0000 1.36
@@ -389,12 +389,20 @@
* - If circ->rend_splice is set (we are the midpoint of a joined
* rendezvous stream), then mark the other circuit to close as well.
*/
-int _circuit_mark_for_close(circuit_t *circ) {
+void _circuit_mark_for_close(circuit_t *circ, int line, const char *file)
+{
connection_t *conn;
assert_circuit_ok(circ);
- if (circ->marked_for_close)
- return -1;
+ tor_assert(line);
+ tor_assert(file);
+
+ if (circ->marked_for_close) {
+ log(LOG_WARN,"Duplicate call to circuit_mark_for_close at %s:%d"
+ " (first at %s:%d)", line, file,
+ circ->marked_for_close_file, circ->marked_for_close);
+ return;
+ }
if (circ->state == CIRCUIT_STATE_ONIONSKIN_PENDING) {
onion_pending_remove(circ);
@@ -441,7 +449,8 @@
for (conn=circ->p_streams; conn; conn=conn->next_stream)
connection_edge_destroy(circ->p_circ_id, conn);
- circ->marked_for_close = 1;
+ circ->marked_for_close = line;
+ circ->marked_for_close_file = file;
if (circ->rend_splice && !circ->rend_splice->marked_for_close) {
/* do this after marking this circuit, to avoid infinite recursion. */
Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/connection.c,v
retrieving revision 1.351
retrieving revision 1.352
diff -u -d -r1.351 -r1.352
--- connection.c 1 Apr 2005 20:15:55 -0000 1.351
+++ connection.c 3 Apr 2005 05:22:33 -0000 1.352
@@ -336,28 +336,31 @@
/** Mark <b>conn</b> to be closed next time we loop through
* conn_close_if_marked() in main.c. */
-int
-_connection_mark_for_close(connection_t *conn)
+void
+_connection_mark_for_close(connection_t *conn, int line, const char *file)
{
assert_connection_ok(conn,0);
+ tor_assert(line);
+ tor_assert(file);
if (conn->marked_for_close) {
- log(LOG_WARN, "Bug: Double mark-for-close on connection.");
+ log(LOG_WARN, "Duplicate call to connection_mark_for_close at %s:%d"
+ " (first at %s:%d)", file, line, conn->marked_for_close_file,
+ conn->marked_for_close);
#ifdef TOR_FRAGILE
tor_assert(0);
#endif
- return -1;
+ return;
}
- conn->marked_for_close = 1;
+ conn->marked_for_close = line;
+ conn->marked_for_close_file = file;
add_connection_to_closeable_list(conn);
/* in case we're going to be held-open-til-flushed, reset
* the number of seconds since last successful write, so
* we get our whole 15 seconds */
conn->timestamp_lastwritten = time(NULL);
-
- return 0;
}
/** Find each connection that has hold_open_until_flushed set to
Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/connection_edge.c,v
retrieving revision 1.316
retrieving revision 1.317
diff -u -d -r1.316 -r1.317
--- connection_edge.c 2 Apr 2005 22:11:24 -0000 1.316
+++ connection_edge.c 3 Apr 2005 05:22:33 -0000 1.317
@@ -32,9 +32,8 @@
conn->has_sent_end = 1; /* no circ yet */
if (conn->marked_for_close) {
- log(LOG_WARN,"Duplicate call to connection_mark_unattached_ap at %s:%d (first marked at %s:%d)",
- file, line,
- conn->marked_for_close_file,conn->marked_for_close);
+ /* This call will warn as appropriate. */
+ _connection_mark_for_close(conn, line, file);
return;
}
@@ -52,9 +51,7 @@
connection_ap_handshake_socks_resolved(conn,RESOLVED_TYPE_ERROR,0,NULL);
}
- _connection_mark_for_close(conn);
- conn->marked_for_close_file = file;
- conn->marked_for_close = line;
+ _connection_mark_for_close(conn, line, file);
conn->hold_open_until_flushed = 1;
}
Index: or.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.582
retrieving revision 1.583
diff -u -d -r1.582 -r1.583
--- or.h 2 Apr 2005 22:11:24 -0000 1.582
+++ or.h 3 Apr 2005 05:22:33 -0000 1.583
@@ -1177,19 +1177,10 @@
circuit_t *circuit_get_clean_open(uint8_t purpose, int need_uptime,
int need_capacity, int internal);
void circuit_mark_all_unused_circs(void);
-int _circuit_mark_for_close(circuit_t *circ);
+void _circuit_mark_for_close(circuit_t *circ, int line, const char *file);
-#define circuit_mark_for_close(c) \
- do { \
- if (_circuit_mark_for_close(c)<0) { \
- log(LOG_WARN,"Duplicate call to circuit_mark_for_close at %s:%d (first at %s:%d)", \
- _SHORT_FILE_,__LINE__, \
- c->marked_for_close_file,c->marked_for_close); \
- } else { \
- c->marked_for_close_file = _SHORT_FILE_; \
- c->marked_for_close = __LINE__; \
- } \
- } while (0)
+#define circuit_mark_for_close(c) \
+ _circuit_mark_for_close((c), __LINE__, _SHORT_FILE_)
void assert_cpath_layer_ok(const crypt_path_t *cp);
void assert_circuit_ok(const circuit_t *c);
@@ -1267,19 +1258,10 @@
void connection_free_all(void);
void connection_about_to_close_connection(connection_t *conn);
void connection_close_immediate(connection_t *conn);
-int _connection_mark_for_close(connection_t *conn);
+void _connection_mark_for_close(connection_t *conn,int line, const char *file);
-#define connection_mark_for_close(c) \
- do { \
- if (_connection_mark_for_close(c)<0) { \
- log(LOG_WARN,"Duplicate call to connection_mark_for_close at %s:%d (first at %s:%d)", \
- _SHORT_FILE_,__LINE__, \
- c->marked_for_close_file,c->marked_for_close); \
- } else { \
- c->marked_for_close_file = _SHORT_FILE_; \
- c->marked_for_close = __LINE__; \
- } \
- } while (0)
+#define connection_mark_for_close(c) \
+ _connection_mark_for_close((c), __LINE__, _SHORT_FILE_)
void connection_expire_held_open(void);
@@ -1325,8 +1307,7 @@
/********************************* connection_edge.c ***************************/
#define connection_mark_unattached_ap(conn, endreason) \
- do { _connection_mark_unattached_ap(conn, endreason, __LINE__, _SHORT_FILE_);\
- } while (0)
+ _connection_mark_unattached_ap((conn), (endreason), __LINE__, _SHORT_FILE_)
void _connection_mark_unattached_ap(connection_t *conn, int endreason,
int line, const char *file);
More information about the tor-commits
mailing list