mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-10-21 20:08:54 +00:00
logging: Use guard to make threaded logging safe
Return a guard variable from `create_logger()` which the caller can implicitly drop to guarantee that all threads started by the async log drain are stopped. This fixes a long-standing bug [1] whereby the agent could panic with the following error, generated by the `slog` logging crate: ``` slog::Fuse Drain: Custom { kind: Other, error: "serde serialization error: Bad file descriptor (os error 9)" } ``` [1] - See https://github.com/kata-containers/kata-containers/issues/171. Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
This commit is contained in:
@@ -142,7 +142,7 @@ fn connect(name: &str, global_args: clap::ArgMatches) -> Result<()> {
|
||||
let log_level = logging::level_name_to_slog_level(log_level_name).map_err(|e| anyhow!(e))?;
|
||||
|
||||
let writer = io::stdout();
|
||||
let logger = logging::create_logger(name, crate_name!(), log_level, writer);
|
||||
let (logger, _guard) = logging::create_logger(name, crate_name!(), log_level, writer);
|
||||
|
||||
let timeout_nano: i64 = match args.value_of("timeout") {
|
||||
Some(t) => utils::human_time_to_ns(t).map_err(|e| e)?,
|
||||
|
Reference in New Issue
Block a user