From: Donald Sharp Date: Mon, 20 Aug 2018 13:45:06 +0000 (-0400) Subject: lib: Convert thread.c to use new error-code subsystem X-Git-Tag: frr-7.1-dev~371^2~32 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=9ef9495e3a96e6d3ebcce46d716500ad396fe979;p=mirror%2Ffrr.git lib: Convert thread.c to use new error-code subsystem Signed-off-by: Donald Sharp --- diff --git a/lib/lib_errors.c b/lib/lib_errors.c index 5610a32cf1..01fa27e82c 100644 --- a/lib/lib_errors.c +++ b/lib/lib_errors.c @@ -40,6 +40,12 @@ static struct log_ref ferr_lib_warn[] = { .description = "During system startup an invalid parameter for the namesapce was give to FRR", .suggestion = "Gather log data and open an Issue. restart FRR", }, + { + .code = LIB_WARN_SLOW_THREAD, + .title = "The Event subsystem has detected a slow process", + .description = "The Event subsystem has detected a slow process, this typically indicates that FRR is having trouble completing work in a timely manner. This can be either a misconfiguration, bug, or some combination therof.", + .suggestion = "Gather log data and open an Issue", + }, { .code = END_FERR, }, diff --git a/lib/lib_errors.h b/lib/lib_errors.h index 23f5468c77..d4581918c7 100644 --- a/lib/lib_errors.h +++ b/lib/lib_errors.h @@ -41,6 +41,7 @@ enum lib_log_refs { LIB_WARN_SNMP, LIB_WARN_STREAM, LIB_WARN_LINUX_NS, + LIB_WARN_SLOW_THREAD, }; extern void lib_error_init(void); diff --git a/lib/thread.c b/lib/thread.c index 52bc79ffe6..b2740baf5d 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -33,6 +33,7 @@ #include "network.h" #include "jhash.h" #include "frratomic.h" +#include "lib_errors.h" DEFINE_MTYPE_STATIC(LIB, THREAD, "Thread") DEFINE_MTYPE_STATIC(LIB, THREAD_MASTER, "Thread master") @@ -1480,7 +1481,8 @@ struct thread *thread_fetch(struct thread_master *m, struct thread *fetch) } /* else die */ - zlog_warn("poll() error: %s", safe_strerror(errno)); + flog_err(LIB_ERR_SYSTEM_CALL, "poll() error: %s", + safe_strerror(errno)); pthread_mutex_unlock(&m->mtx); fetch = NULL; break; @@ -1617,7 +1619,8 @@ void thread_call(struct thread *thread) * Whinge about it now, so we're aware this is yet another task * to fix. */ - zlog_warn( + flog_warn( + LIB_WARN_SLOW_THREAD, "SLOW THREAD: task %s (%lx) ran for %lums (cpu time %lums)", thread->funcname, (unsigned long)thread->func, realtime / 1000, cputime / 1000);