anchor.diff:      {Pid, NewState};
   get_vnode_pid(State=#state{vnode_pid=Pid}) ->
       {Pid, State}.
  +
  +-ifdef(TEST).
  +
  +fake_loop() ->
  +    receive
  +        block ->
  +            fake_loop_block();
  +        slow ->
  +            fake_loop_slow();
  +        {get_count, Pid} ->
  +            Pid ! {count, erlang:get(count)},
  +            fake_loop();
  +        _Msg ->
  +            Count = case erlang:get(count) of
  +                        undefined -> 0;
  +                        Val -> Val
  +                    end,
  +            put(count, Count+1),
  +            fake_loop()
  +    end.
  +
  +fake_loop_slow() ->
  +    timer:sleep(100),
  +    receive
  +        _Msg ->
  +            Count = case erlang:get(count) of
  +                        undefined -> 0;
  +                        Val -> Val
  +                    end,
  +            put(count, Count+1),
  +            fake_loop_slow()
  +    end.
  +
  +fake_loop_block() ->
  +    receive
  +        unblock ->
  +            fake_loop()
  +    end.
  +
  +overload_test_() ->
  +    {foreach,
  +     fun() ->
  +             VnodePid = spawn(fun fake_loop/0),
  +             meck:new(riak_core_vnode_manager, [passthrough]),
  +             meck:expect(riak_core_vnode_manager, get_vnode_pid,
  +                         fun(_Index, fakemod) -> {ok, VnodePid};
  +                            (Index, Mod) -> meck:passthrough([Index, Mod])
  +                         end),
  +             {ok, ProxyPid} = riak_core_vnode_proxy:start_link(fakemod, 0),
  +             unlink(ProxyPid),
  +             {VnodePid, ProxyPid}
  +     end,
  +     fun({VnodePid, ProxyPid}) ->
  +             meck:unload(riak_core_vnode_manager),
  +             exit(VnodePid, kill),
  +             exit(ProxyPid, kill)
  +     end,
  +     [
  +      fun({VnodePid, ProxyPid}) ->
  +              {"should not discard in normal operation",
  +               fun() ->
  +                       [ProxyPid ! hello || _ <- lists:seq(1, 50000)],
  +                       %% synchronize on the mailbox
  +                       Reply = gen:call(ProxyPid, '$vnode_proxy_call', sync),
  +                       ?assertEqual({ok, ok}, Reply),
  +                       VnodePid ! {get_count, self()},
  +                       receive
  +                           {count, Count} ->
  +                               ?assertEqual(50000, Count)
  +                       end
  +               end
  +              }
  +      end,
  +      fun({VnodePid, ProxyPid}) ->
  +              {"should discard during overflow",
  +               fun() ->
  +                       VnodePid ! block,
  +                       [ProxyPid ! hello || _ <- lists:seq(1, 50000)],
  +                       %% synchronize on the mailbox
  +                       Reply = gen:call(ProxyPid, '$vnode_proxy_call', sync),
  +                       ?assertEqual({ok, ok}, Reply),
  +                       VnodePid ! unblock,
  +                       VnodePid ! {get_count, self()},
  +                       receive
  +                           {count, Count} ->
  +                               ?assertEqual(10000, Count)
  +                       end
  +               end
  +              }
  +      end,
  +      fun({VnodePid, ProxyPid}) ->
  +              {"should tolerate slow vnodes",
  +               fun() ->
  +                       VnodePid ! slow,
  +                       [ProxyPid ! hello || _ <- lists:seq(1, 50000)],
  +                       %% synchronize on the mailbox
  +                       Reply = gen:call(ProxyPid, '$vnode_proxy_call', sync),
  +                       ?assertEqual({ok, ok}, Reply),
  +                       %% check that the outstanding message count is
  +                       %% reasonable
  +                       {message_queue_len, L} =
  +                           erlang:process_info(VnodePid, message_queue_len),
  +                       ?assert(L =< 10000)
  +               end
  +              }
  +      end
  +     ]}.
  +-endif.
  
positive.code: init([Parent, RegName, Mod, Index]) ->
      erlang:register(RegName, self()),
      proc_lib:init_ack(Parent, {ok, self()}),
      State = #state{mod=Mod, index=Index},
      loop(Parent, State).
  
  unregister_vnode(Mod, Index, Pid) ->
  
negative.code:         {system, From, Msg} ->
              sys:handle_system_msg(Msg, From, Parent, ?MODULE, [], State);
          Msg ->
              {noreply, NewState} = handle_proxy(Msg,
                                                 State#state{check_counter=State#state.check_counter+1,
                                                             check_mailbox=State#state.check_mailbox+1}),
              loop(Parent, NewState)
      end.
  
  