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

Update type of *LogRotate variables to volatile sig_atomic_t #2045

Open
bocon13 opened this issue Nov 23, 2021 · 0 comments
Open

Update type of *LogRotate variables to volatile sig_atomic_t #2045

bocon13 opened this issue Nov 23, 2021 · 0 comments

Comments

@bocon13
Copy link
Contributor

bocon13 commented Nov 23, 2021

Currently the LogRotate variables in orchagent/main.cpp are not signal safe.

https://en.cppreference.com/w/cpp/utility/program/signal

bool should be changed to volatile sig_atomic_t or atomic_bool:
https://github.com/Azure/sonic-swss/blob/bb0733aa67ffc4e430e70bcf2db2dc6316172b32/orchagent/main.cpp#L57-L58

Then, references are safe in the signal handler:
https://github.com/Azure/sonic-swss/blob/bb0733aa67ffc4e430e70bcf2db2dc6316172b32/orchagent/main.cpp#L95-L102

References to these variables should happen atomically in the log rotation code. For example,
https://github.com/Azure/sonic-swss/blob/ceca17c9b83db4dc1df517026e2153c730b4cf9f/orchagent/response_publisher.cpp#L40-L44

Should use atomic exchange.

 if (!gResponsePublisherLogRotate.exchange(false)) 
 { 
     return; 
 } 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant