| 39 | } |
| 40 | |
| 41 | void ThreadMonitor::register_thread(const pid_t thread_id, |
| 42 | const pid_t serve_thread_id, |
| 43 | const std::string& thread_name, |
| 44 | const PyModuleRef py_module_) { |
| 45 | std::lock_guard<std::mutex> lock(monitored_threads_mutex); |
| 46 | |
| 47 | if (monitored_threads.count(thread_id)) { |
| 48 | dout(20) << "Attempted to register already known thread (TID: " << thread_id << ")." << dendl; |
| 49 | return; |
| 50 | } |
| 51 | |
| 52 | MonitoredThreadInfo info; |
| 53 | info.name = thread_name; |
| 54 | info.py_module = py_module_; |
| 55 | info.serve_thread_id = serve_thread_id; |
| 56 | info.last_snapshot.timestamp = ceph::mono_clock::now(); |
| 57 | info.last_serve_snapshot.timestamp = ceph::mono_clock::now(); |
| 58 | monitored_threads[thread_id] = info; |
| 59 | dout(0) << "Registered thread: '" << thread_name << "' (TID: " << thread_id << ") module: " |
| 60 | << (py_module_ ? py_module_->get_name() : "unknown") << dendl; |
| 61 | } |
| 62 | |
| 63 | void ThreadMonitor::handle_conf_change( |
| 64 | const ConfigProxy& conf, |