Update vlog_is_on.cc
SetVLOGLevel locks vmodule_lock however RAW_VLOG at the end also implicitly locks it via InitVLOG3__. This causes deadlock/segfault.
This commit is contained in:
parent
2a02db7aa5
commit
2c5038470b
@ -162,29 +162,31 @@ int SetVLOGLevel(const char* module_pattern, int log_level) {
|
|||||||
int result = FLAGS_v;
|
int result = FLAGS_v;
|
||||||
int const pattern_len = strlen(module_pattern);
|
int const pattern_len = strlen(module_pattern);
|
||||||
bool found = false;
|
bool found = false;
|
||||||
MutexLock l(&vmodule_lock); // protect whole read-modify-write
|
{
|
||||||
for (const VModuleInfo* info = vmodule_list;
|
MutexLock l(&vmodule_lock); // protect whole read-modify-write
|
||||||
info != NULL; info = info->next) {
|
for (const VModuleInfo* info = vmodule_list;
|
||||||
if (info->module_pattern == module_pattern) {
|
info != NULL; info = info->next) {
|
||||||
if (!found) {
|
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;
|
result = info->vlog_level;
|
||||||
found = true;
|
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) {
|
||||||
if (!found) {
|
VModuleInfo* info = new VModuleInfo;
|
||||||
VModuleInfo* info = new VModuleInfo;
|
info->module_pattern = module_pattern;
|
||||||
info->module_pattern = module_pattern;
|
info->vlog_level = log_level;
|
||||||
info->vlog_level = log_level;
|
info->next = vmodule_list;
|
||||||
info->next = vmodule_list;
|
vmodule_list = info;
|
||||||
vmodule_list = info;
|
}
|
||||||
}
|
}
|
||||||
RAW_VLOG(1, "Set VLOG level for \"%s\" to %d", module_pattern, log_level);
|
RAW_VLOG(1, "Set VLOG level for \"%s\" to %d", module_pattern, log_level);
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user