This is an automated email from the ASF dual-hosted git repository.

serverglen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brpc.git


The following commit(s) were added to refs/heads/master by this push:
     new 965279f0 Fix random value of CachedReader at first time (#2556)
965279f0 is described below

commit 965279f07339bc3471a92fac1114172fa2abe036
Author: Bright Chen <chenguangmin...@foxmail.com>
AuthorDate: Tue Mar 12 10:24:39 2024 +0800

    Fix random value of CachedReader at first time (#2556)
---
 src/bvar/default_variables.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/bvar/default_variables.cpp b/src/bvar/default_variables.cpp
index be02c50a..011508aa 100644
--- a/src/bvar/default_variables.cpp
+++ b/src/bvar/default_variables.cpp
@@ -127,7 +127,7 @@ static bool read_proc_status(ProcStat &stat) {
 template <typename T>
 class CachedReader {
 public:
-    CachedReader() : _mtime_us(0) {
+    CachedReader() : _mtime_us(0), _cached{} {
         CHECK_EQ(0, pthread_mutex_init(&_mutex, NULL));
     }
     ~CachedReader() {
@@ -150,7 +150,7 @@ public:
                 pthread_mutex_unlock(&p->_mutex);
                 // don't run fn inside lock otherwise a slow fn may
                 // block all concurrent bvar dumppers. (e.g. /vars)
-                T result;
+                T result{};
                 if (fn(&result)) {
                     pthread_mutex_lock(&p->_mutex);
                     p->_cached = result;


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org

Reply via email to