New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sss_ptr_hash: internal refactoring #977
Conversation
Remark: scratch build was verified with both https://bugzilla.redhat.com/show_bug.cgi?id=1783190 and https://bugzilla.redhat.com/show_bug.cgi?id=1792331 |
Also verified with https://bugzilla.redhat.com/show_bug.cgi?id=1796044 and https://bugzilla.redhat.com/show_bug.cgi?id=1793303 |
Thank you. It looks good to me. I have just some suggestions about deleting items that might simplify the code more... The basic idea is to move Then you could do the following changes:
|
a9f5cd3
to
dfc5ae9
Compare
Thank you for the feedback.
Do I understand correctly that idea is to assure that the only possible execution chain to get into |
Yes. |
Renamed sbus_server_name_remove_from_table() to sbus_server_name_remove_from_table_cb() to keep naming consistent with other functions used as `hash_delete_callback` argument of sss_ptr_hash_create()
There is no need to allocate memory for `sss_ptr_hash_delete_data` if table user doesn't provide custom delete callback.
- no reason to skip hash_delete() just because sss_ptr_hash_lookup_internal() failed - avoid excessive lookup if it is not required to free payload
`sss_ptr_hash_check_type()` call would take care of this case.
In case `override` check was failed in _sss_ptr_hash_add() `value` was leaking. Fixed to do `override` check before value allocation.
dfc5ae9
to
6d924bc
Compare
Well, this is not that straightforward. We still could get to |
Downstream tests passed. |
Thank you. I have few nitpicks, but otherwise I am ready to accept these changes. |
sss_ptr_hash code was refactored: - got rid of a "spy" to make logic cleaner - table got destructor to wipe its content - described some usage limitation in the documentation And resolves: https://pagure.io/SSSD/sssd/issue/4135
6d924bc
to
2ee3943
Compare
I fixed two nitpicks and commented another. Please let me know if you still (after reading my comment) think destructor should return -1 in case of hash_delete() fail. I actually do not have very strong preference here. Failure of hash_delete() means memory is already corrupted/inconsistent and recovery is hardly possible anyway. |
Ok, so looking at hash_delete definition it is safe to assume that the entry is either deleted or not found. |
Ack. Thank you. |
Failure is not related. |
|
sss_ptr_hash code was refactored:
- got rid of a "spy" to make logic cleaner
- table got destructor to wipe its content
- described some usage limitation in the documentation
Plus couple of minor issues were fixed and unit test added.
Resolves: https://pagure.io/SSSD/sssd/issue/4135