summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFumitoshi Ukai <fumitoshi.ukai@gmail.com>2015-08-06 08:09:02 (GMT)
committerFumitoshi Ukai <fumitoshi.ukai@gmail.com>2015-08-06 08:09:02 (GMT)
commitcd37eec3024be1e24a18db0aef7b5cac0eff0230 (patch)
tree6629c1554987d28367dd1ded6ded948d52c8a48f /src
parent8db3ff0b75933dd1c64c5022a75113192e2bc1e8 (diff)
parent2c5038470b28b839792cc45b790ef6d668006f1e (diff)
downloadglog-cd37eec3024be1e24a18db0aef7b5cac0eff0230.zip
glog-cd37eec3024be1e24a18db0aef7b5cac0eff0230.tar.gz
glog-cd37eec3024be1e24a18db0aef7b5cac0eff0230.tar.bz2
Merge pull request #20 from UbimoLTD/patch-1
Don't call RAW_VLOG with locking vmodule_lock SetVLOGLevel locks vmodule_lock however RAW_VLOG at the end also implicitly locks it via InitVLOG3__. This causes deadlock/segfault. fixes #29
Diffstat (limited to 'src')
-rw-r--r--src/vlog_is_on.cc38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/vlog_is_on.cc b/src/vlog_is_on.cc
index 8a79df5..4c95583 100644
--- a/src/vlog_is_on.cc
+++ b/src/vlog_is_on.cc
@@ -162,30 +162,32 @@ int SetVLOGLevel(const char* module_pattern, int log_level) {
int result = FLAGS_v;
int const pattern_len = strlen(module_pattern);
bool found = false;
- MutexLock l(&vmodule_lock); // protect whole read-modify-write
- for (const VModuleInfo* info = vmodule_list;
- info != NULL; info = info->next) {
- if (info->module_pattern == module_pattern) {
- if (!found) {
+ {
+ MutexLock l(&vmodule_lock); // protect whole read-modify-write
+ for (const VModuleInfo* info = vmodule_list;
+ info != NULL; info = info->next) {
+ if (info->module_pattern == module_pattern) {
+ if (!found) {
+ result = info->vlog_level;
+ found = true;
+ }
+ info->vlog_level = log_level;
+ } else if (!found &&
+ SafeFNMatch_(info->module_pattern.c_str(),
+ info->module_pattern.size(),
+ module_pattern, pattern_len)) {
result = info->vlog_level;
found = true;
}
+ }
+ if (!found) {
+ VModuleInfo* info = new VModuleInfo;
+ info->module_pattern = module_pattern;
info->vlog_level = log_level;
- } else if (!found &&
- SafeFNMatch_(info->module_pattern.c_str(),
- info->module_pattern.size(),
- module_pattern, pattern_len)) {
- result = info->vlog_level;
- found = true;
+ info->next = vmodule_list;
+ vmodule_list = info;
}
}
- if (!found) {
- VModuleInfo* info = new VModuleInfo;
- info->module_pattern = module_pattern;
- info->vlog_level = log_level;
- info->next = vmodule_list;
- vmodule_list = info;
- }
RAW_VLOG(1, "Set VLOG level for \"%s\" to %d", module_pattern, log_level);
return result;
}