Commit 688cea72 authored by Andrea Shepard's avatar Andrea Shepard
Browse files

Check for closing channel in channel_send_destroy()

parent 39a0a2c3
Loading
Loading
Loading
Loading
+22 −10
Original line number Diff line number Diff line
@@ -2585,6 +2585,10 @@ channel_send_destroy(circid_t circ_id, channel_t *chan, int reason)

  tor_assert(chan);

  /* Check to make sure we can send on this channel first */
  if (!(chan->state == CHANNEL_STATE_CLOSING ||
        chan->state == CHANNEL_STATE_CLOSED ||
        chan->state == CHANNEL_STATE_ERROR)) {
    memset(&cell, 0, sizeof(cell_t));
    cell.circ_id = circ_id;
    cell.command = CELL_DESTROY;
@@ -2596,6 +2600,14 @@ channel_send_destroy(circid_t circ_id, channel_t *chan, int reason)
              U64_PRINTF_ARG(chan->global_identifier));

    channel_write_cell(chan, &cell);
  } else {
    log_warn(LD_BUG,
             "Someone called channel_send_destroy() for circID %d "
             "on a channel " U64_FORMAT " at %p in state %s (%d)",
             circ_id, U64_PRINTF_ARG(chan->global_identifier),
             chan, channel_state_to_string(chan->state),
             chan->state);
  }

  return 0;
}