anchor.diff:          _ -> ok
       end,
       NewState = S#state{sock = undefined,
  -                       send_tref = cancel_timeout(SendTRef, ?SEND_TIMEOUT_MSG),
  -                       idle_tref = cancel_timeout(IdleTRef, ?IDLE_TIMEOUT_MSG)},
  +                       send_tref = cancel_timeout(SendTRef, ?SEND_TIMEOUT_MSG)},
       {next_state, disconnected, NewState, hibernate};
   disconnecting({post, Msg}, State) ->
       {next_state, sending, buffer(Msg, State), ?HIBERNATE_TIMEOUT};
  -disconnecting({timeout, _, ?IDLE_TIMEOUT_MSG}, State=#state{idle_tref=TRef}) ->
  -    %% Shouldn't see this because entering this state cancels the timer.
  +disconnecting({timeout, _, ?IDLE_TIMEOUT_MSG}, State) ->
  +    %% Shouldn't see this since entering this state means the timer wasn't reset
       ?WARN("drain_id=~p channel_id=~p dest=~s err=unexpected_idle_timeout "
             "data=~p state=disconnecting", log_info(State, [])),
  -    cancel_timeout(TRef, ?IDLE_TIMEOUT_MSG),
  -    {next_state, disconnecting, State#state{idle_tref=undefined}};
  +    {next_state, disconnecting, State};
   disconnecting(timeout, S = #state{}) ->
       %% Sleep when inactive, trigger fullsweep GC & Compact
       {next_state, disconnecting, S, hibernate};
  
positive.code:          "err=gen_tcp data=~p sock=~p duration=~s state=sending",
            log_info(S, [sending, Reason, Sock, duration(S)])),
      reconnect(tcp_bad(S));
  sending({timeout, _, ?IDLE_TIMEOUT_MSG}, State = #state{idle_tref = TRef}) ->
      cancel_timeout(TRef, ?IDLE_TIMEOUT_MSG),
      {next_state, disconnecting, State#state{idle_tref=undefined}};
  sending(timeout, S = #state{}) ->
      %% Sleep when inactive, trigger fullsweep GC & Compact
      {next_state, sending, S, hibernate};
  
negative.code:   when is_port(Sock) ->
      %% Stale message.
      send(State);
  ready_to_send({timeout, _Ref, ?IDLE_TIMEOUT_MSG}, S) ->
      case close_if_idle(S) of
          closed ->
              {next_state, disconnected, S#state{sock = undefined}, hibernate};
          ok ->
              {next_state, ready_to_send, S}
      end;
  ready_to_send({post, Msg}, State = #state{sock = Sock})
    when is_port(Sock) ->
      send(buffer(Msg, State));
  