[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] create a separate connection_edge_destroy() function



Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or

Modified Files:
	circuit.c connection.c connection_edge.c or.h 
Log Message:
create a separate connection_edge_destroy() function


Index: circuit.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuit.c,v
retrieving revision 1.142
retrieving revision 1.143
diff -u -d -r1.142 -r1.143
--- circuit.c	28 Feb 2004 07:01:22 -0000	1.142
+++ circuit.c	29 Feb 2004 00:11:37 -0000	1.143
@@ -661,12 +661,12 @@
   if(circ->n_conn)
     connection_send_destroy(circ->n_circ_id, circ->n_conn);
   for(conn=circ->n_streams; conn; conn=conn->next_stream) {
-    connection_send_destroy(circ->n_circ_id, conn);
+    connection_edge_destroy(circ->n_circ_id, conn);
   }
   if(circ->p_conn)
     connection_send_destroy(circ->n_circ_id, circ->p_conn);
   for(conn=circ->p_streams; conn; conn=conn->next_stream) {
-    connection_send_destroy(circ->p_circ_id, conn);
+    connection_edge_destroy(circ->p_circ_id, conn);
   }
   if (circ->state == CIRCUIT_STATE_BUILDING ||
       circ->state == CIRCUIT_STATE_OR_WAIT) {

Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection.c,v
retrieving revision 1.166
retrieving revision 1.167
diff -u -d -r1.166 -r1.167
--- connection.c	28 Feb 2004 23:52:56 -0000	1.166
+++ connection.c	29 Feb 2004 00:11:37 -0000	1.167
@@ -752,17 +752,7 @@
   cell_t cell;
 
   assert(conn);
-
-  if(!connection_speaks_cells(conn)) {
-     log_fn(LOG_INFO,"CircID %d: At an edge. Marking connection for close.",
-            circ_id);
-     conn->has_sent_end = 1; /* we're closing the circuit, nothing to send to */
-/* XXX really, we should separate this function into two functions.
- * one of them actually sends the destroy cell, as this function's name
- * implies, and another one destroys a stream. Yes/no? -RD */
-     connection_mark_for_close(conn, END_STREAM_REASON_DESTROY);
-     return 0;
-  }
+  assert(connection_speaks_cells(conn));
 
   memset(&cell, 0, sizeof(cell_t));
   cell.circ_id = circ_id;

Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_edge.c,v
retrieving revision 1.101
retrieving revision 1.102
diff -u -d -r1.101 -r1.102
--- connection_edge.c	28 Feb 2004 23:56:50 -0000	1.101
+++ connection_edge.c	29 Feb 2004 00:11:37 -0000	1.102
@@ -88,6 +88,16 @@
   return -1;
 }
 
+int connection_edge_destroy(uint16_t circ_id, connection_t *conn) {
+  assert(conn->type == CONN_TYPE_AP || conn->type == CONN_TYPE_EXIT);
+
+  log_fn(LOG_INFO,"CircID %d: At an edge. Marking connection for close.",
+         circ_id);
+  conn->has_sent_end = 1; /* we're closing the circuit, nothing to send to */
+  connection_mark_for_close(conn, END_STREAM_REASON_DESTROY);
+  return 0;
+}
+
 static char *connection_edge_end_reason(char *payload, uint16_t length) {
   if(length < 1) {
     log_fn(LOG_WARN,"End cell arrived with length 0. Should be at least 1.");

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.237
retrieving revision 1.238
diff -u -d -r1.237 -r1.238
--- or.h	28 Feb 2004 23:56:50 -0000	1.237
+++ or.h	29 Feb 2004 00:11:37 -0000	1.238
@@ -698,6 +698,7 @@
 void relay_header_pack(char *dest, const relay_header_t *src);
 void relay_header_unpack(relay_header_t *dest, const char *src);
 int connection_edge_process_inbuf(connection_t *conn);
+int connection_edge_destroy(uint16_t circ_id, connection_t *conn);
 int connection_edge_end(connection_t *conn, char reason, crypt_path_t *cpath_layer);
 
 int connection_edge_send_command(connection_t *fromconn, circuit_t *circ, int relay_command,