Skip to content

Conversation

keszybz
Copy link
Member

@keszybz keszybz commented Mar 4, 2019

No description provided.

keszybz added 6 commits March 4, 2019 14:15
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.
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)
Copy link
Member

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)

@poettering
Copy link
Member

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)

@poettering poettering added sd-bus reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks util-lib sd-netlink sd-hwdb Anything to do with sd-hwdb part of libsystemd labels Mar 4, 2019
> on 32bit, size_t is 32bit, but .st_size is off_t hence 64bit
@keszybz keszybz removed the reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks label Mar 4, 2019
@keszybz
Copy link
Member Author

keszybz commented Mar 4, 2019

Updated. The only change is last patch to move the cast.

@poettering poettering added the good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed label Mar 4, 2019
@poettering poettering merged commit 38ba8c8 into systemd:master Mar 4, 2019
@keszybz keszybz deleted the non-atomic branch March 14, 2019 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed sd-bus sd-hwdb Anything to do with sd-hwdb part of libsystemd sd-netlink util-lib
Development

Successfully merging this pull request may close these issues.

2 participants