mirror of
https://github.com/darlinghq/darlingserver.git
synced 2024-11-23 04:19:44 +00:00
Add a tid_for_thread
call
This commit is contained in:
parent
a4364df97b
commit
be9afe1fa5
@ -200,6 +200,12 @@ calls = [
|
||||
('tracer', 'int32_t'),
|
||||
], []),
|
||||
|
||||
('tid_for_thread', [
|
||||
('thread', 'uint32_t'),
|
||||
], [
|
||||
('tid', 'int32_t'),
|
||||
]),
|
||||
|
||||
#
|
||||
# kqueue channels
|
||||
#
|
||||
|
14
src/call.cpp
14
src/call.cpp
@ -857,4 +857,18 @@ void DarlingServer::Call::SetTracer::processCall() {
|
||||
_sendReply(code);
|
||||
};
|
||||
|
||||
void DarlingServer::Call::TidForThread::processCall() {
|
||||
int code = 0;
|
||||
int32_t tid = 0;
|
||||
|
||||
if (auto thread = Thread::threadForPort(_body.thread)) {
|
||||
tid = thread->nsid();
|
||||
} else {
|
||||
// might be user error (e.g. invalid port number or dead thread), so don't negate it
|
||||
code = ESRCH;
|
||||
}
|
||||
|
||||
_sendReply(code, tid);
|
||||
};
|
||||
|
||||
DSERVER_CLASS_SOURCE_DEFS;
|
||||
|
Loading…
Reference in New Issue
Block a user