mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-24 20:33:31 +01:00
holding until flush was borked
we were never writing anything when hold_open_until_flushed was set, since conn_write returns early if marked_for_conn is set. seems a bit better now. svn:r1214
This commit is contained in:
parent
6022bfea11
commit
419a672222
@ -226,6 +226,7 @@ void connection_expire_held_open(void)
|
|||||||
if (conn->hold_open_until_flushed) {
|
if (conn->hold_open_until_flushed) {
|
||||||
assert(conn->marked_for_close);
|
assert(conn->marked_for_close);
|
||||||
if (now - conn->timestamp_lastwritten >= 15) {
|
if (now - conn->timestamp_lastwritten >= 15) {
|
||||||
|
log_fn(LOG_WARN,"Giving up on marked_for_close conn that's been flushing for 15s (fd %d, type %d, state %d).", conn->s, conn->type, conn->state);
|
||||||
conn->hold_open_until_flushed = 0;
|
conn->hold_open_until_flushed = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,8 @@ int connection_edge_process_inbuf(connection_t *conn) {
|
|||||||
/* eof reached, kill it. */
|
/* eof reached, kill it. */
|
||||||
log_fn(LOG_INFO,"conn (fd %d) reached eof. Closing.", conn->s);
|
log_fn(LOG_INFO,"conn (fd %d) reached eof. Closing.", conn->s);
|
||||||
connection_mark_for_close(conn, END_STREAM_REASON_DONE);
|
connection_mark_for_close(conn, END_STREAM_REASON_DONE);
|
||||||
|
conn->hold_open_until_flushed = 1; /* just because we shouldn't read
|
||||||
|
doesn't mean we shouldn't write */
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -205,9 +205,9 @@ static void conn_write(int i) {
|
|||||||
return; /* this conn doesn't want to write */
|
return; /* this conn doesn't want to write */
|
||||||
|
|
||||||
conn = connection_array[i];
|
conn = connection_array[i];
|
||||||
|
log_fn(LOG_DEBUG,"socket %d wants to write.",conn->s);
|
||||||
if (conn->marked_for_close)
|
if (conn->marked_for_close)
|
||||||
return;
|
return;
|
||||||
log_fn(LOG_DEBUG,"socket %d wants to write.",conn->s);
|
|
||||||
|
|
||||||
assert_connection_ok(conn, time(NULL));
|
assert_connection_ok(conn, time(NULL));
|
||||||
|
|
||||||
@ -225,33 +225,39 @@ static void conn_write(int i) {
|
|||||||
|
|
||||||
static void conn_close_if_marked(int i) {
|
static void conn_close_if_marked(int i) {
|
||||||
connection_t *conn;
|
connection_t *conn;
|
||||||
|
int retval;
|
||||||
|
|
||||||
conn = connection_array[i];
|
conn = connection_array[i];
|
||||||
assert_connection_ok(conn, time(NULL));
|
assert_connection_ok(conn, time(NULL));
|
||||||
if(conn->marked_for_close) {
|
if(!conn->marked_for_close)
|
||||||
if (conn->hold_open_until_flushed && conn->s >= 0 &&
|
return; /* nothing to see here, move along */
|
||||||
connection_wants_to_flush(conn))
|
|
||||||
return;
|
|
||||||
|
|
||||||
log_fn(LOG_INFO,"Cleaning up connection (fd %d).",conn->s);
|
log_fn(LOG_INFO,"Cleaning up connection (fd %d).",conn->s);
|
||||||
if(conn->s >= 0 && connection_wants_to_flush(conn)) {
|
if(conn->s >= 0 && connection_wants_to_flush(conn)) {
|
||||||
/* -1 means it's an incomplete edge connection, or that the socket
|
/* -1 means it's an incomplete edge connection, or that the socket
|
||||||
* has already been closed as unflushable. */
|
* has already been closed as unflushable. */
|
||||||
/* FIXME there's got to be a better way to check for this -- and make other checks? */
|
if(!conn->hold_open_until_flushed)
|
||||||
log_fn(LOG_WARN,
|
log_fn(LOG_WARN,
|
||||||
"Conn (fd %d, type %d, state %d) marked for close, but wants to flush %d bytes. "
|
"Conn (fd %d, type %d, state %d) marked, but wants to flush %d bytes. "
|
||||||
"Marked at %s:%d",
|
"(Marked at %s:%d)",
|
||||||
conn->s, conn->type, conn->state,
|
conn->s, conn->type, conn->state,
|
||||||
conn->outbuf_flushlen, conn->marked_for_close_file, conn->marked_for_close);
|
conn->outbuf_flushlen, conn->marked_for_close_file, conn->marked_for_close);
|
||||||
/* XXX change the above to 'warn', and go through and fix all the complaints */
|
|
||||||
if(connection_speaks_cells(conn)) {
|
if(connection_speaks_cells(conn)) {
|
||||||
if(conn->state == OR_CONN_STATE_OPEN) {
|
if(conn->state == OR_CONN_STATE_OPEN) {
|
||||||
flush_buf_tls(conn->tls, conn->outbuf, &conn->outbuf_flushlen);
|
retval = flush_buf_tls(conn->tls, conn->outbuf, &conn->outbuf_flushlen);
|
||||||
}
|
/* XXX actually, some non-zero results are maybe ok. which ones? */
|
||||||
|
} else
|
||||||
|
retval = -1;
|
||||||
} else {
|
} else {
|
||||||
flush_buf(conn->s, conn->outbuf, &conn->outbuf_flushlen);
|
retval = flush_buf(conn->s, conn->outbuf, &conn->outbuf_flushlen);
|
||||||
}
|
}
|
||||||
if(connection_wants_to_flush(conn) && buf_datalen(conn->outbuf)) {
|
if(retval == 0 &&
|
||||||
|
conn->hold_open_until_flushed && connection_wants_to_flush(conn)) {
|
||||||
|
log_fn(LOG_INFO,"Holding conn (fd %d) open for more flushing.",conn->s);
|
||||||
|
/* XXX should we reset timestamp_lastwritten here? */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(connection_wants_to_flush(conn)) {
|
||||||
log_fn(LOG_WARN,"Conn (fd %d) still wants to flush. Losing %d bytes!",
|
log_fn(LOG_WARN,"Conn (fd %d) still wants to flush. Losing %d bytes!",
|
||||||
conn->s, (int)buf_datalen(conn->outbuf));
|
conn->s, (int)buf_datalen(conn->outbuf));
|
||||||
}
|
}
|
||||||
@ -262,7 +268,6 @@ static void conn_close_if_marked(int i) {
|
|||||||
process it too. */
|
process it too. */
|
||||||
conn_close_if_marked(i);
|
conn_close_if_marked(i);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Perform regular maintenance tasks for a single connection. This
|
/* Perform regular maintenance tasks for a single connection. This
|
||||||
|
Loading…
Reference in New Issue
Block a user