Anton Lebedevich 13 years ago
parent
commit
0505a279d3
2 changed files with 6 additions and 2 deletions
  1. 1 1
      src/pgsql.erl
  2. 5 1
      src/pgsql_sock.erl

+ 1 - 1
src/pgsql.erl

@@ -24,7 +24,7 @@ connect(Host, Username, Password, Opts) ->
     gen_server:call(C, {connect, Host, Username, Password, Opts}).
 
 close(C) when is_pid(C) ->
-    catch pgsql_connection:stop(C),
+    catch gen_server:call(C, stop),
     ok.
 
 get_parameter(C, Name) ->

+ 5 - 1
src/pgsql_sock.erl

@@ -70,7 +70,11 @@ handle_call({connect, Host, Username, Password, Opts},
      State2#state{handler = auth,
                   queue = queue:in(From, Queue),
                   async = Async},
-     Timeout}.
+     Timeout};
+
+handle_call(stop, From, #state{queue = Queue} = State) ->
+    %% TODO flush queue
+    {stop, normal, ok, State}.
 
 handle_cast(cancel, State = #state{backend = {Pid, Key}}) ->
     {ok, {Addr, Port}} = inet:peername(State#state.sock),