anchor.diff:              end;
           true ->
               State#state{sync_required = true}
  +    end.
  +
  +flush_queue(#state{queue = Q} = State, Error) ->
  +    case queue:is_empty(Q) of
  +        false ->
  +            flush_queue(reply(State, Error), Error);
  +        true -> State
       end.
   
   to_binary(B) when is_binary(B) -> B;
  
positive.code:                   queue = queue:in(Req, Q),
                    async = Async}};
  
  handle_cast(stop, #state{queue = Q} = State) ->
      %% TODO flush queue
      {stop, normal, State};
  
  handle_cast(Req = {_, {squery, Sql}}, State) ->
      #state{queue = Q} = State,
  
negative.code: 
  handle_info({Closed, Sock}, #state{sock = Sock} = State)
    when Closed == tcp_closed; Closed == ssl_closed ->
      {stop, sock_closed, flush_queue(State, {error, sock_closed})};
  
  handle_info({Error, Sock, Reason}, #state{sock = Sock} = State)
    when Error == tcp_error; Error == ssl_error ->
      Why = {sock_error, Reason},
      {stop, Why, flush_queue(State, {error, Why})};
  
  handle_info({_, Sock, Data2}, #state{data = Data, sock = Sock} = State) ->
      loop(State#state{data = <<Data/binary, Data2/binary>>}).
  