fix codec

This commit is contained in:
anlicheng 2025-11-27 17:13:52 +08:00
parent e1256552b9
commit 175e4b6a81
3 changed files with 6 additions and 13 deletions

View File

@ -44,12 +44,11 @@ handle_request("GET", "/host/status", #{<<"uuid">> := UUID}, _) when is_binary(U
%%
handle_request("POST", "/host/delete", _, #{<<"uuid">> := UUID}) when is_binary(UUID) ->
case iot_host_sup:delete_host(UUID) of
ok ->
lager:debug("[host_handler] will delete host uuid: ~p", [UUID]),
case iot_host:get_pid(UUID) of
Pid when is_pid(Pid) ->
ok = iot_host_sup:delete_host(UUID),
{ok, 200, iot_util:json_data(<<"success">>)};
{error, Reason} ->
lager:debug("[host_handler] delete host uuid: ~p, get error is: ~p", [UUID, Reason]),
undefined ->
{ok, 200, iot_util:json_error(404, <<"error">>)}
end;

View File

@ -37,13 +37,7 @@ ensured_host_started(UUID) when is_binary(UUID) ->
delete_host(UUID) ->
Id = iot_host:get_name(UUID),
case supervisor:terminate_child(?MODULE, Id) of
{error, running} ->
iot_host:kill(UUID),
ok;
_ ->
ok
end,
ok = supervisor:terminate_child(?MODULE, Id),
case supervisor:delete_child(?MODULE, Id) of
{error, running} ->
%% ensure killed then delete again

View File

@ -113,7 +113,7 @@ decode0(_, _) ->
%%% helper methods
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-spec marshal(Type :: integer(), Field :: any()) -> binary().
-spec marshal(Type :: ?I8 | ?I16 | ?I32 | ?Bytes, Field :: integer() | binary()) -> binary().
marshal(?I8, Field) when is_integer(Field) ->
<<?I8, Field:8>>;
marshal(?I16, Field) when is_integer(Field) ->