Skip to content

Commit 364c389

Browse files
author
duke
committed
Automatic merge of jdk:master into master
2 parents 3d7c31a + e66fd6f commit 364c389

File tree

5 files changed

+46
-18
lines changed

5 files changed

+46
-18
lines changed

src/hotspot/share/logging/logConfiguration.cpp

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,7 @@ void LogConfiguration::initialize(jlong vm_start_time) {
110110
}
111111

112112
void LogConfiguration::finalize() {
113-
for (size_t i = _n_outputs; i > 0; i--) {
114-
disable_output(i - 1);
115-
}
113+
disable_outputs();
116114
FREE_C_HEAP_ARRAY(LogOutput*, _outputs);
117115
}
118116

@@ -272,28 +270,31 @@ void LogConfiguration::configure_output(size_t idx, const LogSelectionList& sele
272270
assert(strlen(output->config_string()) > 0, "should always have a config description");
273271
}
274272

275-
void LogConfiguration::disable_output(size_t idx) {
276-
assert(idx < _n_outputs, "invalid index: " SIZE_FORMAT " (_n_outputs: " SIZE_FORMAT ")", idx, _n_outputs);
277-
LogOutput* out = _outputs[idx];
273+
void LogConfiguration::disable_outputs() {
274+
size_t idx = _n_outputs;
278275

279-
// Remove the output from all tagsets.
276+
// Remove all outputs from all tagsets.
280277
for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) {
281-
ts->set_output_level(out, LogLevel::Off);
282-
ts->update_decorators();
278+
ts->disable_outputs();
283279
}
284280

285-
// Delete the output unless stdout or stderr (idx 0 or 1)
286-
if (idx > 1) {
287-
delete_output(idx);
288-
} else {
289-
out->set_config_string("all=off");
281+
while (idx > 0) {
282+
LogOutput* out = _outputs[--idx];
283+
// Delete the output unless stdout or stderr (idx 0 or 1)
284+
if (idx > 1) {
285+
delete_output(idx);
286+
} else {
287+
out->set_config_string("all=off");
288+
}
290289
}
291290
}
292291

293292
void LogConfiguration::disable_logging() {
294293
ConfigurationLock cl;
295-
for (size_t i = _n_outputs; i > 0; i--) {
296-
disable_output(i - 1);
294+
disable_outputs();
295+
// Update the decorators on all tagsets to get rid of unused decorators
296+
for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) {
297+
ts->update_decorators();
297298
}
298299
notify_update_listeners();
299300
}

src/hotspot/share/logging/logConfiguration.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ class LogConfiguration : public AllStatic {
6969
// Output should be completely disabled before it is deleted.
7070
static void delete_output(size_t idx);
7171

72-
// Disable all logging to the specified output and then delete it (unless it is stdout/stderr).
73-
static void disable_output(size_t idx);
72+
// Disable all logging to all outputs. All outputs except stdout/stderr will be deleted.
73+
static void disable_outputs();
7474

7575
// Get output index by name. Returns SIZE_MAX if output not found.
7676
static size_t find_output(const char* name);

src/hotspot/share/logging/logOutputList.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,25 @@ LogOutputList::LogOutputNode* LogOutputList::find(const LogOutput* output) const
6868
return NULL;
6969
}
7070

71+
void LogOutputList::clear() {
72+
73+
// Grab the linked list
74+
LogOutputNode* cur = _level_start[LogLevel::Last];
75+
76+
// Clear _level_start
77+
for (uint level = LogLevel::First; level < LogLevel::Count; level++) {
78+
_level_start[level] = NULL;
79+
}
80+
81+
// Delete all nodes from the linked list
82+
wait_until_no_readers();
83+
while (cur != NULL) {
84+
LogOutputNode* next = cur->_next;
85+
delete cur;
86+
cur = next;
87+
}
88+
}
89+
7190
void LogOutputList::remove_output(LogOutputList::LogOutputNode* node) {
7291
assert(node != NULL, "Node must be non-null");
7392

src/hotspot/share/logging/logOutputList.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ class LogOutputList {
8888
// Set (add/update/remove) the output to the specified level.
8989
void set_output_level(LogOutput* output, LogLevelType level);
9090

91+
// Removes all outputs. Equivalent of set_output_level(out, Off)
92+
// for all outputs.
93+
void clear();
94+
9195
class Iterator {
9296
friend class LogOutputList;
9397
private:

src/hotspot/share/logging/logTagSet.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ class LogTagSet {
9898
return _output_list.level_for(output);
9999
}
100100

101+
void disable_outputs() {
102+
_output_list.clear();
103+
}
104+
101105
void set_output_level(LogOutput* output, LogLevelType level) {
102106
_output_list.set_output_level(output, level);
103107
}

0 commit comments

Comments
 (0)