Fix misreporting of stream bandwidths.

This commit is contained in:
potentiate 2009-05-14 05:20:27 -07:00 committed by Nick Mathewson
parent 479d21254a
commit 1b61c8bf37
4 changed files with 25 additions and 0 deletions

View File

@ -611,6 +611,7 @@ connection_about_to_close_connection(connection_t *conn)
conn->marked_for_close_file, conn->marked_for_close);
dnsserv_reject_request(edge_conn);
}
control_event_stream_bandwidth(edge_conn);
control_event_stream_status(edge_conn, STREAM_EVENT_CLOSED,
edge_conn->end_reason);
circ = circuit_get_by_edge_conn(edge_conn);

View File

@ -160,6 +160,7 @@ connection_edge_destroy(circid_t circ_id, edge_connection_t *conn)
"CircID %d: At an edge. Marking connection for close.", circ_id);
if (conn->_base.type == CONN_TYPE_AP) {
connection_mark_unattached_ap(conn, END_STREAM_REASON_DESTROY);
control_event_stream_bandwidth(conn);
control_event_stream_status(conn, STREAM_EVENT_CLOSED,
END_STREAM_REASON_DESTROY);
conn->end_reason |= END_STREAM_REASON_FLAG_ALREADY_SENT_CLOSED;

View File

@ -3258,6 +3258,28 @@ control_event_or_conn_status(or_connection_t *conn, or_conn_status_event_t tp,
return 0;
}
/**
* Print out STREAM_BW event for a single conn
*/
int
control_event_stream_bandwidth(edge_connection_t *edge_conn)
{
if (EVENT_IS_INTERESTING(EVENT_STREAM_BANDWIDTH_USED)) {
if (!edge_conn->n_read && !edge_conn->n_written)
return 0;
send_control_event(EVENT_STREAM_BANDWIDTH_USED, ALL_NAMES,
"650 STREAM_BW "U64_FORMAT" %lu %lu\r\n",
U64_PRINTF_ARG(edge_conn->_base.global_identifier),
(unsigned long)edge_conn->n_read,
(unsigned long)edge_conn->n_written);
edge_conn->n_written = edge_conn->n_read = 0;
}
return 0;
}
/** A second or more has elapsed: tell any interested control
* connections how much bandwidth streams have used. */
int

View File

@ -3220,6 +3220,7 @@ int control_event_stream_status(edge_connection_t *conn,
int control_event_or_conn_status(or_connection_t *conn,
or_conn_status_event_t e, int reason);
int control_event_bandwidth_used(uint32_t n_read, uint32_t n_written);
int control_event_stream_bandwidth(edge_connection_t *edge_conn);
int control_event_stream_bandwidth_used(void);
void control_event_logmsg(int severity, unsigned int domain, const char *msg);
int control_event_descriptors_changed(smartlist_t *routers);