mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-02 16:29:07 +00:00
agent: fix the issue dead lock on AGENT_CONFIG
Once parsed cmdline and set the config on AGENT_CONFIG, release the write lock as soon as possible. In case other thread would get read lock on it. Fixes:#87 Signed-off-by: lifupan <lifupan@gmail.com>
This commit is contained in:
parent
60d713e84d
commit
6b611030db
@ -104,7 +104,6 @@ fn main() -> Result<()> {
|
||||
|
||||
lazy_static::initialize(&AGENT_CONFIG);
|
||||
let agentConfig = AGENT_CONFIG.clone();
|
||||
let mut config = agentConfig.write().unwrap();
|
||||
|
||||
if unistd::getpid() == Pid::from_raw(1) {
|
||||
// Init a temporary logger used by init agent as init process
|
||||
@ -115,8 +114,15 @@ fn main() -> Result<()> {
|
||||
init_agent_as_init(&logger)?;
|
||||
}
|
||||
|
||||
config.parse_cmdline(KERNEL_CMDLINE_FILE)?;
|
||||
// once parsed cmdline and set the config, release the write lock
|
||||
// as soon as possible in case other thread would get read lock on
|
||||
// it.
|
||||
{
|
||||
let mut config = agentConfig.write().unwrap();
|
||||
config.parse_cmdline(KERNEL_CMDLINE_FILE)?;
|
||||
}
|
||||
|
||||
let config = agentConfig.read().unwrap();
|
||||
let writer = io::stdout();
|
||||
// Recreate a logger with the log level get from "/proc/cmdline".
|
||||
let logger = logging::create_logger(NAME, "agent", config.log_level, writer);
|
||||
|
Loading…
Reference in New Issue
Block a user