Adjust broker locking order slightly #604
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I was doing an unrelated experiment with a config that generated a warning on
validation, and I ended up flooded with warnings because we now call
Open
onevery broker returned from the Client, and we were revalidating the config every
single time. One thing led to another and I made several other adjustments in
the same vein.
AlreadyConnected
check to before the config validation inBroker.Open
. Config validation is expensive and can log, no point in doingit if we don't have to.
atomic.StoreInt32
calls to after any of their related logmessages. None of these were real problems, but it removes any possibility of
out-of-order log messages due to unusual race conditions.
AlreadyConnected
after we've taken the fulllock. Initially I just removed the log message since it's not something we
need to log, but upon closer inspection I'm pretty sure this is dead code;
anything that sets
opened
to 0 also setsconn
to nil first, and does sowhile holding the lock.
@wvanbergen