aboutsummaryrefslogtreecommitdiff
path: root/src/or/connection.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2003-10-04 02:38:18 +0000
committerRoger Dingledine <arma@torproject.org>2003-10-04 02:38:18 +0000
commitf563bbd2f988cd1f6ca292f89a47a86f98fe0e8d (patch)
tree08b3ea32a4ce45bc729225bd1beeed555fd0dd52 /src/or/connection.c
parenta6bab569abd3ac8f16a3603813fa03e4585a3bd3 (diff)
downloadtor-f563bbd2f988cd1f6ca292f89a47a86f98fe0e8d.tar
tor-f563bbd2f988cd1f6ca292f89a47a86f98fe0e8d.tar.gz
refactor so connection_write_to_buf() never fails
svn:r537
Diffstat (limited to 'src/or/connection.c')
-rw-r--r--src/or/connection.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/or/connection.c b/src/or/connection.c
index ab401771b..918aa6654 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -489,13 +489,10 @@ int connection_handle_write(connection_t *conn) {
return 0;
}
-int connection_write_to_buf(const char *string, int len, connection_t *conn) {
+void connection_write_to_buf(const char *string, int len, connection_t *conn) {
- if(!len)
- return 0;
-
- if(conn->marked_for_close)
- return 0;
+ if(!len || conn->marked_for_close)
+ return;
if( (!connection_speaks_cells(conn)) ||
(!connection_state_is_open(conn)) ||
@@ -506,7 +503,10 @@ int connection_write_to_buf(const char *string, int len, connection_t *conn) {
conn->outbuf_flushlen += len;
}
- return write_to_buf(string, len, conn->outbuf);
+ if(write_to_buf(string, len, conn->outbuf) < 0) {
+ log_fn(LOG_WARNING,"write_to_buf failed. Closing connection (fd %d).", conn->s);
+ conn->marked_for_close = 1;
+ }
}
connection_t *connection_exact_get_by_addr_port(uint32_t addr, uint16_t port) {
@@ -653,7 +653,8 @@ int connection_send_destroy(aci_t aci, connection_t *conn) {
cell.aci = aci;
cell.command = CELL_DESTROY;
log_fn(LOG_INFO,"Sending destroy (aci %d).",aci);
- return connection_write_cell_to_buf(&cell, conn);
+ connection_write_cell_to_buf(&cell, conn);
+ return 0;
}
int connection_process_inbuf(connection_t *conn) {