Browse Source

Revert "Unexpected crash report when unable to connect to server or connection closed by server"

This reverts commit 27ac4ac87a932d06701bb0112b7ed95a69471b80.
Alexander Verbitsky 9 years ago
parent
commit
517dd95eef
1 changed files with 10 additions and 15 deletions
  1. 10 15
      src/epgsql_sock.erl

+ 10 - 15
src/epgsql_sock.erl

@@ -202,8 +202,8 @@ command({connect, Host, Username, Password, Opts}, State) ->
              State2#state{handler = auth,
                           async = Async}};
 
-        {error, _Reason} = Error ->
-            {stop, shutdown, finish(State, Error)}
+        {error, Reason} = Error ->
+            {stop, Reason, finish(State, Error)}
     end;
 
 command({squery, Sql}, State) ->
@@ -680,19 +680,14 @@ on_message({?READY_FOR_QUERY, <<Status:8>>}, State) ->
              end,
     {noreply, State2#state{txstatus = Status}};
 
-on_message(Error = {error, Reason}, State) ->
-    case queue:is_empty(State#state.queue) of
-        true ->
-            {stop, {shutdown, Reason}, State};
-        false ->
-            State2 = case command_tag(State) of
-                C when C == squery; C == equery; C == execute_batch ->
-                    add_result(State, Error, Error);
-                _ ->
-                    sync_required(finish(State, Error))
-            end,
-            {noreply, State2}
-    end;
+on_message(Error = {error, _}, State) ->
+    State2 = case command_tag(State) of
+                 C when C == squery; C == equery; C == execute_batch ->
+                     add_result(State, Error, Error);
+                 _ ->
+                     sync_required(finish(State, Error))
+             end,
+    {noreply, State2};
 
 %% NoticeResponse
 on_message({?NOTICE, Data}, State) ->