Minor specs/... fixes
This commit is contained in:
parent
911a9eab1f
commit
8dab8223d7
3 changed files with 12 additions and 13 deletions
|
@ -5,7 +5,9 @@ defmodule GenMagic.Helpers do
|
|||
|
||||
alias GenMagic.Result
|
||||
alias GenMagic.Server
|
||||
@spec perform_once(Path.t(), [Server.option()]) :: {:ok, Result.t()} | {:error, term()}
|
||||
|
||||
@spec perform_once(Path.t() | {:bytes, binary}, [Server.option()]) ::
|
||||
{:ok, Result.t()} | {:error, term()}
|
||||
|
||||
@doc """
|
||||
Runs a one-shot process without supervision.
|
||||
|
|
|
@ -81,7 +81,8 @@ defmodule GenMagic.Server do
|
|||
|
||||
@spec child_spec([option()]) :: Supervisor.child_spec()
|
||||
@spec start_link([option()]) :: :gen_statem.start_ret()
|
||||
@spec perform(t(), Path.t(), timeout()) :: {:ok, Result.t()} | {:error, term() | String.t()}
|
||||
@spec perform(t(), Path.t() | {:bytes, binary()}, timeout()) ::
|
||||
{:ok, Result.t()} | {:error, term() | String.t()}
|
||||
@spec status(t(), timeout()) :: {:ok, Status.t()} | {:error, term()}
|
||||
@spec stop(t(), term(), timeout()) :: :ok
|
||||
|
||||
|
@ -185,10 +186,9 @@ defmodule GenMagic.Server do
|
|||
end
|
||||
|
||||
@doc false
|
||||
def starting(:info, {port, {:data, binary}}, %{port: port} = data) do
|
||||
case :erlang.binary_to_term(binary) do
|
||||
:ready ->
|
||||
{:next_state, :available, data}
|
||||
def starting(:info, {port, {:data, ready}}, %{port: port} = data) do
|
||||
case :erlang.binary_to_term(ready) do
|
||||
:ready -> {:next_state, :available, data}
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -198,6 +198,7 @@ defmodule GenMagic.Server do
|
|||
1 -> :no_database
|
||||
2 -> :no_argument
|
||||
3 -> :missing_database
|
||||
code -> {:unexpected_error, code}
|
||||
end
|
||||
|
||||
{:stop, {:error, error}, data}
|
||||
|
@ -243,12 +244,10 @@ defmodule GenMagic.Server do
|
|||
end
|
||||
|
||||
@doc false
|
||||
def processing(:info, {port, {:data, response}}, %{port: port} = data) do
|
||||
{_, from, _} = data.request
|
||||
data = %{data | request: nil}
|
||||
def processing(:info, {port, {:data, response}}, %{port: port, request: {_, from, _}} = data) do
|
||||
response = {:reply, from, handle_response(response)}
|
||||
next_state = (data.cycles >= data.recycle_threshold && :recycling) || :available
|
||||
{:next_state, next_state, data, [response, :hibernate]}
|
||||
{:next_state, next_state, %{data | request: nil}, [response, :hibernate]}
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
@ -279,7 +278,6 @@ defmodule GenMagic.Server do
|
|||
@errnos %{
|
||||
2 => :enoent,
|
||||
13 => :eaccess,
|
||||
21 => :eisdir,
|
||||
20 => :enotdir,
|
||||
12 => :enomem,
|
||||
24 => :emfile,
|
||||
|
|
|
@ -192,7 +192,6 @@ int process_command(uint16_t len, byte *buf) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
// Empty the buffer.
|
||||
write_cmd(result.buff, result.index);
|
||||
|
||||
if (ei_x_free(&result) != 0) {
|
||||
|
@ -406,7 +405,7 @@ size_t read_cmd(byte *buf) {
|
|||
|
||||
// Buffer isn't large enough: just return possible len, without reading.
|
||||
// Up to the caller of verifying the size again and return an error.
|
||||
// buf left unchanged.
|
||||
// buf left unchanged, stdin emptied of X bytes.
|
||||
if (len16 > COMMAND_LEN) {
|
||||
fdseek(len16);
|
||||
return len16;
|
||||
|
|
Loading…
Reference in a new issue