Browse Source

send 'cast' or 'incremental' inside request

Anton Lebedevich 13 years ago
parent
commit
91a0cd29a8
2 changed files with 5 additions and 3 deletions
  1. 1 1
      src/apgsql.erl
  2. 4 2
      src/pgsql_sock.erl

+ 1 - 1
src/apgsql.erl

@@ -65,5 +65,5 @@ cancel(C) ->
 
 cast(C, Command) ->
     Ref = make_ref(),
-    gen_server:cast(C, {{self(), Ref}, Command}),
+    gen_server:cast(C, {{cast, self(), Ref}, Command}),
     Ref.

+ 4 - 2
src/pgsql_sock.erl

@@ -66,9 +66,11 @@ handle_call(Command, From, State) ->
     Req = {{call, From}, Command},
     command(Command, State#state{queue = queue:in(Req, Q)}).
 
-handle_cast({{From, Ref}, Command}, State) ->
+handle_cast({{Method, From, Ref}, Command} = Req, State)
+  when ((Method == cast) or (Method == incremental)),
+       is_pid(From),
+       is_reference(Ref)  ->
     #state{queue = Q} = State,
-    Req = {{cast, From, Ref}, Command},
     command(Command, State#state{queue = queue:in(Req, Q)});
 
 handle_cast(stop, State) ->