forked from rpm-software-management/rpm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rpmKeyring and rpmstrPool nrefs to atomic_int
These data structures use the content lock (aka mutex) to also protect the reference counter. This is wrong and complicates freeing interconnected data structures. This lock should only protect the content of the instance. Turn nrefs members into atomic_int so they are thread-save themselves. Make sure to only use ++ and -- operators and avoid non atomic combinations of reading and writing. As the nref can't change again after reaching zero this is thread-save even as we look at the result an instruction later. Make sure the data lock is not aquired for updating the nrefs members. Technically the *Free() functions should *Link() the instance after the ref count has reached 0 and the decision to free it has been made. Otherwise the cleanup code linking and freeing to will lead to a recusions. This is not neccessary here so it is omitted.
- Loading branch information
Showing
2 changed files
with
29 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters