--- a/src/torrent/utils/log.cc +++ b/src/torrent/utils/log.cc @@ -296,8 +296,11 @@ log_open_output(const char* name, log_slot slot) { - if (log_find_output_name(name) != log_outputs.end()) { - pthread_mutex_unlock(&log_mutex); - throw input_error("Log name already used."); + log_output_list::iterator itr = log_find_output_name(name); + if (itr == log_outputs.end()) { + log_outputs.push_back(std::make_pair(name, slot)); + } else { + // by replacing the "write" slot binding, the old file gets closed + // (handles are shared pointers) + itr->second = slot; } - log_outputs.push_back(std::make_pair(name, slot)); log_rebuild_cache();