[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] don"t flush the buf from inside connection_write_to_buf
- To: or-cvs@freehaven.net
- Subject: [or-cvs] don"t flush the buf from inside connection_write_to_buf
- From: arma@seul.org (Roger Dingledine)
- Date: Wed, 12 May 2004 18:56:28 -0400 (EDT)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Wed, 12 May 2004 18:56:49 -0400
- Reply-to: or-dev@freehaven.net
- Sender: owner-or-cvs@freehaven.net
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or
Modified Files:
connection.c connection_or.c
Log Message:
don't flush the buf from inside connection_write_to_buf
Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection.c,v
retrieving revision 1.223
retrieving revision 1.224
diff -u -d -r1.223 -r1.224
--- connection.c 12 May 2004 21:12:33 -0000 1.223
+++ connection.c 12 May 2004 22:56:26 -0000 1.224
@@ -875,8 +875,7 @@
}
/** Append <b>len</b> bytes of <b>string</b> onto <b>conn</b>'s
- * outbuf, and ask it to start writing. If it's an OR conn, and an
- * entire TLS record is ready, then try to flush it now.
+ * outbuf, and ask it to start writing.
*/
void connection_write_to_buf(const char *string, int len, connection_t *conn) {
@@ -884,33 +883,20 @@
return;
if(write_to_buf(string, len, conn->outbuf) < 0) {
- log_fn(LOG_WARN,"write_to_buf failed. Closing connection (fd %d).", conn->s);
- /* XXX should call connection_edge_end() ? */
- connection_mark_for_close(conn);
+ if(conn->type == CONN_TYPE_AP || conn->type == CONN_TYPE_EXIT) {
+ /* if it failed, it means we have our package/delivery windows set
+ wrong compared to our max outbuf size. close the whole circuit. */
+ log_fn(LOG_WARN,"write_to_buf failed. Closing circuit (fd %d).", conn->s);
+ circuit_mark_for_close(circuit_get_by_conn(conn));
+ } else {
+ log_fn(LOG_WARN,"write_to_buf failed. Closing connection (fd %d).", conn->s);
+ connection_mark_for_close(conn);
+ }
return;
}
connection_start_writing(conn);
-#define MIN_TLS_FLUSHLEN 15872
-/* openssl tls record size is 16383, this is close. The goal here is to
- * push data out as soon as we know there's enough for a tls record, so
- * during periods of high load we won't read the entire megabyte from
- * input before pushing any data out. */
- if(connection_speaks_cells(conn) &&
- conn->outbuf_flushlen < MIN_TLS_FLUSHLEN &&
- conn->outbuf_flushlen+len >= MIN_TLS_FLUSHLEN) {
- len -= (MIN_TLS_FLUSHLEN - conn->outbuf_flushlen);
- conn->outbuf_flushlen = MIN_TLS_FLUSHLEN;
- if(connection_handle_write(conn) < 0) {
- log_fn(LOG_WARN,"flushing failed.");
- return;
- }
- }
- if(len > 0) { /* if there's any left over */
- conn->outbuf_flushlen += len;
- connection_start_writing(conn);
- /* because connection_handle_write() above might have stopped writing */
- }
+ conn->outbuf_flushlen += len;
}
/** Return the conn to addr/port that has the most recent
Index: connection_or.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_or.c,v
retrieving revision 1.108
retrieving revision 1.109
diff -u -d -r1.108 -r1.109
--- connection_or.c 12 May 2004 21:12:33 -0000 1.108
+++ connection_or.c 12 May 2004 22:56:26 -0000 1.109
@@ -298,7 +298,12 @@
return 0;
}
-/** Pack <b>cell</b> into wire-format, and write it onto <b>conn</b>'s outbuf. */
+/** Pack <b>cell</b> into wire-format, and write it onto <b>conn</b>'s
+ * outbuf.
+ *
+ * (Commented out) If it's an OR conn, and an entire TLS record is
+ * ready, then try to flush the record now.
+ */
void connection_or_write_cell_to_buf(const cell_t *cell, connection_t *conn) {
char networkcell[CELL_NETWORK_SIZE];
char *n = networkcell;
@@ -309,6 +314,30 @@
cell_pack(n, cell);
connection_write_to_buf(n, CELL_NETWORK_SIZE, conn);
+
+#if 0 /* commented out -- can we get away with not doing this,
+ * because we're already round-robining in handle_read?
+ */
+#define MIN_TLS_FLUSHLEN 15872
+/* openssl tls record size is 16383, this is close. The goal here is to
+ * push data out as soon as we know there's enough for a tls record, so
+ * during periods of high load we won't read the entire megabyte from
+ * input before pushing any data out. */
+ if(conn->outbuf_flushlen-CELL_NETWORK_SIZE < MIN_TLS_FLUSHLEN &&
+ conn->outbuf_flushlen >= MIN_TLS_FLUSHLEN) {
+ int extra = conn->outbuf_flushlen - MIN_TLS_FLUSHLEN;
+ conn->outbuf_flushlen = MIN_TLS_FLUSHLEN;
+ if(connection_handle_write(conn) < 0) {
+ log_fn(LOG_WARN,"flushing failed.");
+ return;
+ }
+ if(extra) {
+ conn->outbuf_flushlen += extra;
+ connection_start_writing(conn);
+ }
+ }
+#endif
+
}
/** Process cells from <b>conn</b>'s inbuf.