Commit 20a965d
committed
rust_binder: avoid destructors in insert_or_update_handle()
The insert_or_update_handle() function currently has two places where it
drops objects under the node_refs lock. In preparation for changing
node_refs into a spinlock, update the code to either entirely remove the
codepath or drop the node_refs lock first before running the destructor.
This also has the side-benefit that we avoid traversing the by_node
rbtree twice. Currently it's first traversed to see if the new node is
present, and then traversed again to insert it. By saving the
VacantEntry from the first lookup, we can perform the insertion without
traversing the tree again.
Reviewed-by: Matthew Maurer <mmaurer@google.com>
Signed-off-by: Alice Ryhl <aliceryhl@google.com>1 parent 03e071a commit 20a965d
1 file changed
Lines changed: 14 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
861 | 861 | | |
862 | 862 | | |
863 | 863 | | |
864 | | - | |
865 | | - | |
866 | | - | |
867 | | - | |
868 | | - | |
869 | | - | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
870 | 874 | | |
871 | | - | |
872 | 875 | | |
873 | 876 | | |
874 | 877 | | |
| |||
884 | 887 | | |
885 | 888 | | |
886 | 889 | | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
887 | 893 | | |
888 | 894 | | |
889 | 895 | | |
890 | 896 | | |
891 | 897 | | |
892 | 898 | | |
893 | 899 | | |
894 | | - | |
| 900 | + | |
895 | 901 | | |
896 | 902 | | |
897 | 903 | | |
| |||
0 commit comments