Skip to content
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

InitFlags concurrency fix #349

Merged
merged 2 commits into from Sep 8, 2022

Commits on Sep 7, 2022

  1. add test for the command line usage

    The flags and their defaults are part of the klog API and must not change.
    pohly committed Sep 7, 2022
    Copy the full SHA
    a952486 View commit details
    Browse the repository at this point in the history

Commits on Sep 8, 2022

  1. make InitFlags read-only

    The way it was implemented before, the current value of several flags was
    written to the global config struct each time InitFlags was called. Not all
    flags may get written concurrently, so this led to a data race when some other
    goroutine was actively using klog. InitFlags also created new flag.Flag
    instances for each call.
    
    By creating flags once during init, InitFlags becomes entirely read-only and
    thus safe to use concurrently.
    
    What remains ambiguous is which flags may get changed at runtime. That was
    underspecified before and doesn't get fixed here either, it just gets called
    out as a potential problem.
    pohly committed Sep 8, 2022
    Copy the full SHA
    28f7906 View commit details
    Browse the repository at this point in the history