fix ObRsReentrantThread::check_alert about thread_id
This commit is contained in:
@ -25,11 +25,11 @@ namespace rootserver
|
|||||||
CheckThreadSet ObRsReentrantThread::check_thread_set_;
|
CheckThreadSet ObRsReentrantThread::check_thread_set_;
|
||||||
|
|
||||||
ObRsReentrantThread::ObRsReentrantThread()
|
ObRsReentrantThread::ObRsReentrantThread()
|
||||||
:last_run_timestamp_(-1)
|
:last_run_timestamp_(-1), thread_id_(-1)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
ObRsReentrantThread::ObRsReentrantThread(bool need_check)
|
ObRsReentrantThread::ObRsReentrantThread(bool need_check)
|
||||||
:last_run_timestamp_(need_check ? 0 : -1)
|
:last_run_timestamp_(need_check ? 0 : -1), thread_id_(-1)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
ObRsReentrantThread::~ObRsReentrantThread()
|
ObRsReentrantThread::~ObRsReentrantThread()
|
||||||
@ -126,7 +126,7 @@ int64_t ObRsReentrantThread::get_last_run_timestamp() const
|
|||||||
void ObRsReentrantThread::check_alert(const ObRsReentrantThread &thread)
|
void ObRsReentrantThread::check_alert(const ObRsReentrantThread &thread)
|
||||||
{
|
{
|
||||||
if (thread.need_monitor_check()) {
|
if (thread.need_monitor_check()) {
|
||||||
const pid_t thread_id = syscall(__NR_gettid); // only called by thread self
|
const pid_t thread_id = thread.get_thread_id();
|
||||||
const char *thread_name = thread.get_thread_name();
|
const char *thread_name = thread.get_thread_name();
|
||||||
int64_t last_run_timestamp = thread.get_last_run_timestamp();
|
int64_t last_run_timestamp = thread.get_last_run_timestamp();
|
||||||
int64_t last_run_interval = ObTimeUtility::current_time() - last_run_timestamp;
|
int64_t last_run_interval = ObTimeUtility::current_time() - last_run_timestamp;
|
||||||
|
|||||||
@ -33,6 +33,7 @@ public:
|
|||||||
|
|
||||||
virtual void run2() override {
|
virtual void run2() override {
|
||||||
int ret = common::OB_SUCCESS;
|
int ret = common::OB_SUCCESS;
|
||||||
|
thread_id_ = (pid_t)syscall(__NR_gettid); // only called by thread self
|
||||||
run3();
|
run3();
|
||||||
}
|
}
|
||||||
virtual void run3() = 0;
|
virtual void run3() = 0;
|
||||||
@ -61,6 +62,7 @@ public:
|
|||||||
void stop();
|
void stop();
|
||||||
void wait();
|
void wait();
|
||||||
void reset_last_run_timestamp() { ATOMIC_STORE(&last_run_timestamp_, 0); }
|
void reset_last_run_timestamp() { ATOMIC_STORE(&last_run_timestamp_, 0); }
|
||||||
|
pid_t get_thread_id() const { return thread_id_; }
|
||||||
TO_STRING_KV("name", get_thread_name());
|
TO_STRING_KV("name", get_thread_name());
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -68,6 +70,7 @@ private:
|
|||||||
// =0 :pause check thread;
|
// =0 :pause check thread;
|
||||||
// =-1 :close check thread;
|
// =-1 :close check thread;
|
||||||
int64_t last_run_timestamp_;
|
int64_t last_run_timestamp_;
|
||||||
|
pid_t thread_id_;
|
||||||
#ifdef ERRSIM //for obtest
|
#ifdef ERRSIM //for obtest
|
||||||
static const int64_t MAX_THREAD_SCHEDULE_OVERRUN_TIME = 5LL * 1000LL * 1000LL;
|
static const int64_t MAX_THREAD_SCHEDULE_OVERRUN_TIME = 5LL * 1000LL * 1000LL;
|
||||||
#else
|
#else
|
||||||
|
|||||||
Reference in New Issue
Block a user