@@ -511,8 +511,9 @@ defmodule Registry do
511
511
:error
512
512
end
513
513
514
- { kind , _ , _ , _ } ->
515
- raise ArgumentError , "Registry.update_value/3 is not supported for #{ kind } registries"
514
+ { kind , _ , _ } ->
515
+ raise ArgumentError ,
516
+ "Registry.update_value/3 is not supported for #{ inspect ( kind ) } registries"
516
517
end
517
518
end
518
519
@@ -843,16 +844,35 @@ defmodule Registry do
843
844
@ spec keys ( registry , pid ) :: [ key ]
844
845
def keys ( registry , pid ) when is_atom ( registry ) and is_pid ( pid ) do
845
846
{ kind , partitions , _ , pid_ets , _ } = info! ( registry )
846
- { _ , pid_ets } = pid_ets || pid_ets! ( registry , pid , partitions )
847
847
848
- keys =
849
- try do
850
- spec = [ { { pid , :"$1" , :"$2" , :_ } , [ ] , [ { { :"$1" , :"$2" } } ] } ]
851
- :ets . select ( pid_ets , spec )
852
- catch
853
- :error , :badarg -> [ ]
848
+ pid_etses =
849
+ if pid_ets do
850
+ { _ , pid_ets } = pid_ets
851
+ [ pid_ets ]
852
+ else
853
+ case kind do
854
+ { :duplicate , :key } ->
855
+ for partition <- 0 .. ( partitions - 1 ) do
856
+ { _ , pid_ets } = pid_ets! ( registry , partition )
857
+ pid_ets
858
+ end
859
+
860
+ _ ->
861
+ { _ , pid_ets } = pid_ets! ( registry , pid , partitions )
862
+ [ pid_ets ]
863
+ end
854
864
end
855
865
866
+ keys =
867
+ Enum . flat_map ( pid_etses , fn pid_ets ->
868
+ try do
869
+ spec = [ { { pid , :"$1" , :"$2" , :_ } , [ ] , [ { { :"$1" , :"$2" } } ] } ]
870
+ :ets . select ( pid_ets , spec )
871
+ catch
872
+ :error , :badarg -> [ ]
873
+ end
874
+ end )
875
+
856
876
# Handle the possibility of fake keys
857
877
keys = gather_keys ( keys , [ ] , false )
858
878
0 commit comments