From 5e40d92400200d0f8cb656ca9b10495c6bdb648a Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Mon, 25 Oct 2021 12:56:06 +0300 Subject: [PATCH] trx_rate_ctr: use thread safe strerror() in device_sig_cb() Change-Id: Ibd52af22bbe99652f402ada87410de167a124b73 --- CommonLibs/trx_rate_ctr.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CommonLibs/trx_rate_ctr.cpp b/CommonLibs/trx_rate_ctr.cpp index ba4fcc0c..a7467c15 100644 --- a/CommonLibs/trx_rate_ctr.cpp +++ b/CommonLibs/trx_rate_ctr.cpp @@ -214,6 +214,7 @@ static int device_sig_cb(unsigned int subsys, unsigned int signal, struct timespec next_sched = {.tv_sec = 0, .tv_nsec = 20*1000*1000}; /* no automatic re-trigger */ struct timespec intv_sched = {.tv_sec = 0, .tv_nsec = 0}; + char err_buf[256]; switch (signal) { case S_DEVICE_COUNTER_CHANGE: @@ -222,7 +223,8 @@ static int device_sig_cb(unsigned int subsys, unsigned int signal, dev_rate_ctr_mutex.lock(); dev_ctrs_pending[dev_ctr->chan] = *dev_ctr; if (osmo_timerfd_schedule(&dev_rate_ctr_timerfd, &next_sched, &intv_sched) < 0) { - LOGC(DCTR, ERROR) << "Failed to schedule timerfd: " << errno << " = "<< strerror(errno); + LOGC(DCTR, ERROR) << "Failed to schedule timerfd: " << errno + << " = "<< strerror_r(errno, err_buf, sizeof(err_buf)); } dev_rate_ctr_mutex.unlock(); break; @@ -232,7 +234,8 @@ static int device_sig_cb(unsigned int subsys, unsigned int signal, trx_rate_ctr_mutex.lock(); trx_ctrs_pending[trx_ctr->chan] = *trx_ctr; if (osmo_timerfd_schedule(&trx_rate_ctr_timerfd, &next_sched, &intv_sched) < 0) { - LOGC(DCTR, ERROR) << "Failed to schedule timerfd: " << errno << " = "<< strerror(errno); + LOGC(DCTR, ERROR) << "Failed to schedule timerfd: " << errno + << " = "<< strerror_r(errno, err_buf, sizeof(err_buf)); } trx_rate_ctr_mutex.unlock(); break;