diff --git a/VERSION b/VERSION index 4f53b327..69b98bb9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.59 +1.1.60 diff --git a/lib/supavisor/client_handler.ex b/lib/supavisor/client_handler.ex index e1076d39..e1175913 100644 --- a/lib/supavisor/client_handler.ex +++ b/lib/supavisor/client_handler.ex @@ -422,6 +422,13 @@ defmodule Supavisor.ClientHandler do {:keep_state_and_data, handle_actions(data)} end + def handle_event(:info, {proto, _, <> = msg}, _, data) + when proto in [:tcp, :ssl] do + Logger.debug("ClientHandler: Receive sync while not idle") + Db.cast(data.db_pid, self(), msg) + :keep_state_and_data + end + # incoming query with a single pool def handle_event(:info, {proto, _, bin}, :idle, %{pool: pid} = data) when is_binary(bin) and is_pid(pid) do diff --git a/lib/supavisor/db_handler.ex b/lib/supavisor/db_handler.ex index e2a751a5..dbfe2fbc 100644 --- a/lib/supavisor/db_handler.ex +++ b/lib/supavisor/db_handler.ex @@ -28,6 +28,9 @@ defmodule Supavisor.DbHandler do @spec call(pid(), pid(), binary()) :: :ok | {:error, any()} | {:buffering, non_neg_integer()} def call(pid, caller, msg), do: :partisan_gen_statem.call(pid, {:db_call, caller, msg}, 15_000) + @spec cast(pid(), pid(), binary()) :: :ok | {:error, any()} | {:buffering, non_neg_integer()} + def cast(pid, caller, msg), do: :partisan_gen_statem.cast(pid, {:db_cast, caller, msg}) + @spec get_state_and_mode(pid()) :: {:ok, {state, Supavisor.mode()}} | {:error, term()} def get_state_and_mode(pid) do try do @@ -408,6 +411,16 @@ defmodule Supavisor.DbHandler do {:keep_state, %{data | caller: caller, buffer: new_buff}, reply} end + # emulate handle_cast + def handle_event(:cast, {:db_cast, caller, bin}, state, %{sock: sock}) do + Logger.debug( + "DbHandler: state #{state} <-- <-- bin #{inspect(byte_size(bin))} bytes, cast caller: #{inspect(caller)}" + ) + + sock_send(sock, bin) + :keep_state_and_data + end + def handle_event(_, {closed, _}, :busy, data) when closed in @sock_closed do {:stop, :db_termination, data} end