chenBright commented on code in PR #3039:
URL: https://github.com/apache/brpc/pull/3039#discussion_r2232858185


##########
src/bthread/task_group.h:
##########
@@ -378,7 +378,7 @@ friend class TaskControl;
     bthread_tag_t _tag{BTHREAD_TAG_DEFAULT};
 
     // Worker thread id.
-    pid_t _tid{-1};
+    pthread_t _tid{0};

Review Comment:
   On other platforms, pthread_t is not an integer. And on linux, 0 does not 
seem to be an illegal pthread_t.



##########
src/bthread/task_tracer.cpp:
##########
@@ -403,6 +404,10 @@ TaskTracer::Result TaskTracer::SignalTrace(pid_t tid) {
     //
     // Therefore, use async-signal-safe absl::DefaultStackUnwinder instead of 
libunwind.
 
+    if (worker_tid == pthread_self()) {
+        return Result::MakeErrorResult("Forbid to trace self=%d", worker_tid);

Review Comment:
   On other platforms, pthread_t is not an integer, but a pointer.



##########
src/bthread/task_group.cpp:
##########
@@ -1107,7 +1107,7 @@ void print_task(std::ostream& os, bthread_t tid) {
     TaskStatistics stat = {0, 0, 0};
     TaskStatus status = TASK_STATUS_UNKNOWN;
     bool traced = false;
-    pid_t worker_tid = 0;
+    pthread_t worker_tid = 0;

Review Comment:
   On other platforms, pthread_t is not an integer.



##########
src/bthread/task_tracer.cpp:
##########
@@ -424,11 +429,11 @@ TaskTracer::Result TaskTracer::SignalTrace(pid_t tid) {
     sigval value{};
     value.sival_ptr = signal_sync.get();
     size_t sigqueue_try = 0;
-    while (sigqueue(tid, SIGURG, value) != 0) {
+    while (pthread_sigqueue(worker_tid, SIGURG, value) != 0) {
         if (errno != EAGAIN || sigqueue_try++ >= 3) {
             // Remove reference for SignalHandler.
             signal_sync->RemoveRefManually();
-            return Result::MakeErrorResult("Fail to sigqueue: %s, tid: %d", 
berror(), tid);
+            return Result::MakeErrorResult("Fail to pthread_sigqueue: %s, tid: 
%d", berror(), worker_tid);

Review Comment:
   On other platforms, pthread_t is not an integer, but a pointer.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org

Reply via email to