fix client table
This commit is contained in:
parent
869a2ae61c
commit
c70289c6dc
@ -66,7 +66,7 @@ disable_client(NetworkId, ClientId) when is_integer(NetworkId), is_binary(Client
|
||||
[] ->
|
||||
ok;
|
||||
[Client] ->
|
||||
mnesia:write(client, Client#client{status = disabled}, write)
|
||||
mnesia:write(Tab, Client#client{status = disabled}, write)
|
||||
end
|
||||
end,
|
||||
|
||||
@ -92,7 +92,7 @@ alloc_ip0(NetworkId, Ips, ClientId, Mac, NetAddr0) ->
|
||||
|
||||
case mnesia:read(Tab, ClientId) of
|
||||
[Client=#client{ip = Ip, status = normal}] ->
|
||||
ok = mnesia:write(client, Client#client{mac = Mac}, write),
|
||||
ok = mnesia:write(Tab, Client#client{mac = Mac}, write),
|
||||
Ip;
|
||||
[#client{status = disabled}] ->
|
||||
mnesia:abort(client_disabled);
|
||||
@ -102,7 +102,7 @@ alloc_ip0(NetworkId, Ips, ClientId, Mac, NetAddr0) ->
|
||||
true ->
|
||||
%% 如果ip没有被占用,则分配給当前请求
|
||||
Client = #client{client_id = ClientId, mac = Mac, ip = NetAddr0},
|
||||
ok = mnesia:write(client, Client, write),
|
||||
ok = mnesia:write(Tab, Client, write),
|
||||
NetAddr0;
|
||||
false ->
|
||||
case Ips -- UsedIps of
|
||||
@ -110,7 +110,7 @@ alloc_ip0(NetworkId, Ips, ClientId, Mac, NetAddr0) ->
|
||||
mnesia:abort(no_ip);
|
||||
[Ip|_] ->
|
||||
Client = #client{client_id = ClientId, mac = Mac, ip = Ip, status = normal},
|
||||
ok = mnesia:write(client, Client, write),
|
||||
ok = mnesia:write(Tab, Client, write),
|
||||
Ip
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user