basho/riak-erlang-client — pull request #121 by seancribbs (2013-09-30 19:14:32+00:00)
Title: Receiving {error,einval} errors in riakc_pb_socket:send_request/2

When running riak_test on OSX, I get several errors like

```
14:01:09.026 [error] gen_server <0.20679.0> terminated with reason: no case clause matching {error,einval} in riakc_pb_socket:send_request/2 line 1978
14:01:09.026 [error] CRASH REPORT Process <0.20679.0> with 1 neighbours exited with reason: no case clause matching {error,einval} in riakc_pb_socket:send_request/2 line 1978 in gen_server:terminate/6 line 744
```

Looking at the code:

```erlang
send_request(Request, State) when State#state.active =:= undefined ->
Pkt = riak_pb_codec:encode(Request#request.msg),
case gen_tcp:send(State#state.sock, Pkt) of
ok ->
maybe_reply(after_send(Request, State#state{active = Request}));
{error, closed} ->
gen_tcp:close(State#state.sock),
maybe_enqueue_and_reconnect(Request, State#state{sock=undefined})
end.
```

Does it make sense to catch

```erlang
{error, SomeOtherError}->
% Do some logging
gen_tcp:close(State#state.sock),
maybe_enqueue_and_reconnect(Request, State#state{sock=undefined})
```