-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Drop unused atomic operations #11888
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
Conversation
This is mostly cosmetic. It makes those test binaries support SYSTEMD_LOG_* environment variables.
We had atomic counters, but all other operations were non-serialized. This means that concurrent access to the bus object was only safe if _all_ threads were doing read-only access. Even sending of messages from threads would not be possible, because after sending of the message we usually want to remove it from the send queue in the bus object, which would race. Let's just kill this.
The sd-hwdb objects cannot be used concurrently from two threads in any meaningful way, because query and iteration operations modify the object. Thus atomic reference counts are pointless.
Same as with the other users, any non-trivial use of the objects requires use from a single thread only or external locking. Using atomic operations just for reference counts is not useful.
src/libsystemd/sd-hwdb/sd-hwdb.c
Outdated
| return log_debug_errno(errno, "Failed to read %s: %m", hwdb_bin_path); | ||
| if (fstat(fileno(hwdb->f), &hwdb->st) < 0) | ||
| return log_debug_errno(errno, "Failed to stat %s: %m", hwdb_bin_path); | ||
| if ((size_t) hwdb->st.st_size < offsetof(struct trie_header_f, strings_len) + 8) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this size check is weird btw, and I think should be fixed too
on 32bit, size_t is 32bit, but .st_size is off_t hence 64bit. Now you can this larger type to the smaller one, before comparing. This should be done the other way, i.e. the result of offsetof() should be cast to off_t before comparing.
(not an issue introduced by your PR, but if you touch this, please fix)
|
looks good, except for the type thing, see above. (which isn#t the fault of this PR, but should be fixed if the line is touched already) |
> on 32bit, size_t is 32bit, but .st_size is off_t hence 64bit
|
Updated. The only change is last patch to move the cast. |
No description provided.