diff options
author | Emile Joubert <emile@rabbitmq.com> | 2013-04-25 13:19:19 +0100 |
---|---|---|
committer | Emile Joubert <emile@rabbitmq.com> | 2013-04-25 13:19:19 +0100 |
commit | bb6fb516738dbc030afe968c62e0ed628707fc8b (patch) | |
tree | fd3a8e7c3251b3e06cbc72faf19f738b02a72536 /src/rabbit_net.erl | |
parent | 7898cd2d43154ad33ba5af29d58e9308c92c4105 (diff) | |
download | rabbitmq-server-bb6fb516738dbc030afe968c62e0ed628707fc8b.tar.gz |
Receive fixed number of bytes from socket synchronouslybug25502
Diffstat (limited to 'src/rabbit_net.erl')
-rw-r--r-- | src/rabbit_net.erl | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/rabbit_net.erl b/src/rabbit_net.erl index b8b03f56..8b6895f5 100644 --- a/src/rabbit_net.erl +++ b/src/rabbit_net.erl @@ -18,9 +18,9 @@ -include("rabbit.hrl"). -export([is_ssl/1, ssl_info/1, controlling_process/2, getstat/2, - recv/1, async_recv/3, port_command/2, getopts/2, setopts/2, send/2, - close/1, fast_close/1, sockname/1, peername/1, peercert/1, - tune_buffer_size/1, connection_string/2, socket_ends/2]). + recv/1, sync_recv/2, async_recv/3, port_command/2, getopts/2, + setopts/2, send/2, close/1, fast_close/1, sockname/1, peername/1, + peercert/1, tune_buffer_size/1, connection_string/2, socket_ends/2]). %%--------------------------------------------------------------------------- @@ -48,6 +48,8 @@ -spec(recv/1 :: (socket()) -> {'data', [char()] | binary()} | 'closed' | rabbit_types:error(any()) | {'other', any()}). +-spec(sync_recv/2 :: (socket(), integer()) -> rabbit_types:ok(binary()) | + rabbit_types:error(any())). -spec(async_recv/3 :: (socket(), integer(), timeout()) -> rabbit_types:ok(any())). -spec(port_command/2 :: (socket(), iolist()) -> 'true'). @@ -115,6 +117,11 @@ recv(S, {DataTag, ClosedTag, ErrorTag}) -> Other -> {other, Other} end. +sync_recv(Sock, Length) when ?IS_SSL(Sock) -> + ssl:recv(Sock#ssl_socket.ssl, Length); +sync_recv(Sock, Length) -> + gen_tcp:recv(Sock, Length). + async_recv(Sock, Length, Timeout) when ?IS_SSL(Sock) -> Pid = self(), Ref = make_ref(), |