Ticket #1653: diff

File diff, 1.8 KB (added by yetonetime, 10 years ago)

For compare with exists patches.

  • relay.c

    old new  
    3535                                   crypt_path_t *layer_hint);
    3636static int
    3737circuit_consider_stop_edge_reading(circuit_t *circ, crypt_path_t *layer_hint);
     38static int
     39circuit_queue_high(circuit_t *circ);
    3840
    3941/** Cache the current hi-res time; the cache gets reset when libevent
    4042 * calls us. */
     
    12171219      conn->package_window += STREAMWINDOW_INCREMENT;
    12181220      log_debug(domain,"stream-level sendme, packagewindow now %d.",
    12191221                conn->package_window);
     1222      if (circuit_queue_high(circ)) { /* Too high, don't touch conn */
     1223        return 0;
     1224      }
    12201225      connection_start_reading(TO_CONN(conn));
    12211226      /* handle whatever might still be on the inbuf */
    12221227      if (connection_edge_package_raw_inbuf(conn, 1) < 0) {
     
    14181423circuit_resume_edge_reading(circuit_t *circ, crypt_path_t *layer_hint)
    14191424{
    14201425
     1426  if (circuit_queue_high(circ)) {
     1427    log_debug(layer_hint?LD_APP:LD_EXIT,"Too big queue, no resuming");
     1428    return;
     1429  }
    14211430  log_debug(layer_hint?LD_APP:LD_EXIT,"resuming");
    14221431
    14231432  if (CIRCUIT_IS_ORIGIN(circ))
     
    23862395  tor_assert(n == smartlist_len(orconn->active_circuit_pqueue));
    23872396}
    23882397
     2398/** Return 1 if the number of cells waiting on the queue
     2399 *  more than a watermark or equal it. Else return 0.
     2400 *  XXXY: Only for edges: origin and exit. Middles out of luck for such,
     2401 *  need the proposal.
     2402*/
     2403static int
     2404circuit_queue_high(circuit_t *circ)
     2405{
     2406  cell_queue_t *queue;
     2407
     2408  if (CIRCUIT_IS_ORIGIN(circ)) {
     2409    queue = &circ->n_conn_cells;
     2410  } else {
     2411    or_circuit_t *orcirc = TO_OR_CIRCUIT(circ);
     2412    queue = &orcirc->p_conn_cells;
     2413  }
     2414
     2415  if (queue->n >= CELL_QUEUE_HIGHWATER_SIZE)
     2416    return 1;
     2417  return 0;
     2418}