mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 05:33:47 +01:00
Use u32 add helper for CIRC_BW accounting.
There are quite a few other places this could be used, but keeping it simple for now.
This commit is contained in:
parent
0e06a9c3e7
commit
f921fd771a
@ -504,11 +504,8 @@ command_process_relay_cell(cell_t *cell, channel_t *chan)
|
|||||||
origin_circuit_t *ocirc = TO_ORIGIN_CIRCUIT(circ);
|
origin_circuit_t *ocirc = TO_ORIGIN_CIRCUIT(circ);
|
||||||
|
|
||||||
/* Count the payload bytes only. We don't care about cell headers */
|
/* Count the payload bytes only. We don't care about cell headers */
|
||||||
if (PREDICT_LIKELY(UINT32_MAX - ocirc->n_read_circ_bw >
|
ocirc->n_read_circ_bw = tor_add_u32_nowrap(ocirc->n_read_circ_bw,
|
||||||
CELL_PAYLOAD_SIZE))
|
CELL_PAYLOAD_SIZE);
|
||||||
ocirc->n_read_circ_bw += (int)CELL_PAYLOAD_SIZE;
|
|
||||||
else
|
|
||||||
ocirc->n_read_circ_bw = UINT32_MAX;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CIRCUIT_IS_ORIGIN(circ) &&
|
if (!CIRCUIT_IS_ORIGIN(circ) &&
|
||||||
|
@ -374,11 +374,8 @@ circuit_package_relay_cell(cell_t *cell, circuit_t *circ,
|
|||||||
|
|
||||||
/* Update circ written totals for control port */
|
/* Update circ written totals for control port */
|
||||||
origin_circuit_t *ocirc = TO_ORIGIN_CIRCUIT(circ);
|
origin_circuit_t *ocirc = TO_ORIGIN_CIRCUIT(circ);
|
||||||
if (PREDICT_LIKELY(UINT32_MAX - ocirc->n_written_circ_bw
|
ocirc->n_written_circ_bw = tor_add_u32_nowrap(ocirc->n_written_circ_bw,
|
||||||
> CELL_PAYLOAD_SIZE))
|
CELL_PAYLOAD_SIZE);
|
||||||
ocirc->n_written_circ_bw += (int)CELL_PAYLOAD_SIZE;
|
|
||||||
else
|
|
||||||
ocirc->n_written_circ_bw = UINT32_MAX;
|
|
||||||
|
|
||||||
} else { /* incoming cell */
|
} else { /* incoming cell */
|
||||||
if (CIRCUIT_IS_ORIGIN(circ)) {
|
if (CIRCUIT_IS_ORIGIN(circ)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user