Browse Source

Send `Terminate` mesage when performing gracefull shutdown. Fixes #215

Sergey Prokhorov 5 years ago
parent
commit
47b194bbe5
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

@@ -219,6 +219,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},