Browse Source

Merge pull request #219 from seriyps/send-terminate-message

Send `Terminate` mesage when performing gracefull shutdown. Fixes #215
Sergey Prokhorov 5 years ago
parent
commit
b32d2e88d0
2 changed files with 2 additions and 0 deletions
  1. 1 0
      include/protocol.hrl
  2. 1 0
      src/epgsql_sock.erl

+ 1 - 0
include/protocol.hrl

@@ -43,6 +43,7 @@
 -define(READY_FOR_QUERY, $Z).
 -define(COPY_BOTH_RESPONSE, $W).
 -define(COPY_DATA, $d).
+-define(TERMINATE, $X).
 
 % CopyData replication messages
 -define(X_LOG_DATA, $w).

+ 1 - 0
src/epgsql_sock.erl

@@ -221,6 +221,7 @@ handle_cast({{Method, From, Ref} = Transport, Command, Args}, State)
     command_new(Transport, Command, Args, State);
 
 handle_cast(stop, State) ->
+    send(State, ?TERMINATE, []),
     {stop, normal, flush_queue(State, {error, closed})};
 
 handle_cast(cancel, State = #state{backend = {Pid, Key},