anchor.diff:      %% 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};
  -        NewTimerState ->
  -            {next_state, ready_to_send, NewTimerState}
  -    end;
  +    close_if_idle(S);
   ready_to_send({post, Msg}, State = #state{sock = Sock})
     when is_port(Sock) ->
       send(buffer(Msg, State));
  
positive.code:           log_info(S, [sending, Reason, Sock, duration(S)])),
      reconnect(tcp_bad(S));
  sending({timeout, _, ?IDLE_TIMEOUT_MSG}, State) ->
      case close_if_idle(State) of
          closed ->
              {next_state, disconnecting, State#state{sock = undefined}};
          NewTimerState ->
              {next_state, sending, NewTimerState}
      end;
  sending(timeout, S = #state{}) ->
      %% Sleep when inactive, trigger fullsweep GC & Compact
      {next_state, sending, S, hibernate};
  
negative.code: 
  close_if_idle(State = #state{sock = Sock, last_good_time = LastGood}) ->
      MaxIdle = logplex_app:config(tcp_syslog_idle_timeout, timer:minutes(5)),
      SinceLastGoodMicros = timer:now_diff(os:timestamp(), LastGood),
      case SinceLastGoodMicros > (MaxIdle * 1000) of
          true ->
              ?INFO("drain_id=~p channel_id=~p dest=~s at=idle_timeout",
                    log_info(State, [])),
              gen_tcp:close(Sock),
              {next_state, disconnecting, State#state{sock=undefined}, hibernate};
          _ ->
              {next_state, sending, start_idle_timer(State)}
      end.
  
  buffer_to_pkts(Buf, BytesRemaining, DrainTok) ->
  