~ubuntu-branches/ubuntu/saucy/rabbitmq-server/saucy-proposed

« back to all changes in this revision

Viewing changes to plugins-src/rabbitmq-erlang-client/src/amqp_main_reader.erl

  • Committer: Package Import Robot
  • Author(s): Emile Joubert
  • Date: 2013-05-02 11:19:31 UTC
  • mfrom: (0.5.2) (0.1.37 sid)
  • Revision ID: package-import@ubuntu.com-20130502111931-xnoj0sejto2tewcj
Tags: 3.1.0-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
handle_cast(Cast, State) ->
63
63
    {stop, {unexpected_cast, Cast}, State}.
64
64
 
 
65
handle_info({inet_async, Sock, _, {ok, <<"AMQP", A, B, C>>}},
 
66
            State = #state{sock = Sock, message = none}) ->
 
67
    {ok, <<D>>} = rabbit_net:sync_recv(Sock, 1),
 
68
    handle_error({refused, {A, B, C, D}}, State);
65
69
handle_info({inet_async, Sock, _, {ok, <<Type:8, Channel:16, Length:32>>}},
66
 
            State = #state{sock = Sock, message = none}) ->
 
70
            State = #state{sock = Sock, message = none}) when
 
71
      Type =:= ?FRAME_METHOD; Type =:= ?FRAME_HEADER;
 
72
      Type =:= ?FRAME_BODY;   Type =:= ?FRAME_HEARTBEAT ->
67
73
    next(Length + 1, State#state{message = {Type, Channel, Length}});
 
74
handle_info({inet_async, Sock, _, {ok, All}},
 
75
            State = #state{sock = Sock, message = none}) ->
 
76
    handle_error({malformed_header, All}, State);
68
77
handle_info({inet_async, Sock, _, {ok, Data}},
69
78
            State = #state{sock = Sock, message = {Type, Channel, L}}) ->
70
79
    <<Payload:L/binary, ?FRAME_END>> = Data,
108
117
handle_error(closed, State = #state{connection = Conn}) ->
109
118
    Conn ! socket_closed,
110
119
    {noreply, State};
 
120
handle_error({refused, Version},  State = #state{connection = Conn}) ->
 
121
    Conn ! {refused, Version},
 
122
    {noreply, State};
 
123
handle_error({malformed_header, Version},  State = #state{connection = Conn}) ->
 
124
    Conn ! {malformed_header, Version},
 
125
    {noreply, State};
111
126
handle_error(Reason, State = #state{connection = Conn}) ->
112
127
    Conn ! {socket_error, Reason},
113
128
    {stop, {socket_error, Reason}, State}.