anchor.diff:  -define(SHRINK_TRIES, 10).
   -define(SHRINK_BUF_SIZE, 10).
   -define(IDLE_TIMEOUT_MSG, idle_timeout).
  --define(IDLE_TIMEOUT, logplex_app:config(tcpsyslog_drain_idle_timeout,
  -                                         timer:minutes(5)))
   
   -include("logplex.hrl").
   -include("logplex_logging.hrl").
  
positive.code:                 log_info(S, [disconnecting, Reason, Sock, duration(S)]));
          _ -> ok
      end,
      NewState = State#state{sock = undefined,
                             send_tref = cancel_timeout(SendTRef, ?SEND_TIMEOUT_MSG)
                             idle_tref = cancel_timeout(IdleTRef, ?IDLE_TIMEOUT_MSG)}
      {next_state, disconnected, NewState, hibernate}
  disconnecting({post, Msg}, State) ->
      {next_state, sending, buffer(Msg, State), ?HIBERNATE_TIMEOUT};
  disconnecting({timeout, Ref, ?IDLE_TIMEOUT_MSG}, State=#state{idle_tref=TRef}) ->
      %% Shouldn't see this because entering this state cancels the timer.
      ?WARN("drain_id=~p channel_id=~p dest=~s err=unexpected_idle_timeout "
            "data=~p state=disconnecting", log_info(State, [Msg])),
      {next_state, disconnecting, State#state{idle_tref=undefined}};
  disconnecting(timeout, S = #state{}) ->
      %% Sleep when inactive, trigger fullsweep GC & Compact
  
negative.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};
  