From 7f0b5e546c4694fdfce344f819d9c18f74e30401 Mon Sep 17 00:00:00 2001 From: anlicheng Date: Mon, 25 Sep 2023 17:37:13 +0800 Subject: [PATCH] fix buffer --- apps/iot/src/iot_database_buffer.erl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/iot/src/iot_database_buffer.erl b/apps/iot/src/iot_database_buffer.erl index fc1cdff..0c5a367 100644 --- a/apps/iot/src/iot_database_buffer.erl +++ b/apps/iot/src/iot_database_buffer.erl @@ -66,7 +66,12 @@ init([]) -> {stop, Reason :: term(), Reply :: term(), NewState :: #state{}} | {stop, Reason :: term(), NewState :: #state{}}). handle_call({find_device, DeviceUUID}, _From, State = #state{devices_map = DevicesMap}) -> - {reply, maps:find(DeviceUUID, DevicesMap), State}. + case maps:take(DeviceUUID, DevicesMap) of + error -> + {reply, error, State}; + {DeviceInfo, NDevicesMap} -> + {reply, {ok, DeviceInfo}, State#state{devices_map = NDevicesMap}} + end. %% @private %% @doc Handling cast messages