This is an automated email from the ASF dual-hosted git repository. jiashunzhu pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/brpc.git
The following commit(s) were added to refs/heads/master by this push: new 67eb4efd Change the default value of the bthread_tag in class ServerOptions to BTHREAD_TAG_DEFAULT (#2824) 67eb4efd is described below commit 67eb4efd7d637802bd8bb64b77fcf0f69b57a5b0 Author: Jingyuan <52315061+mjy-h...@users.noreply.github.com> AuthorDate: Mon Nov 25 00:44:27 2024 +0800 Change the default value of the bthread_tag in class ServerOptions to BTHREAD_TAG_DEFAULT (#2824) * Change the default value of the bthread_tag in class ServerOptions to BTHREAD_TAG_DEFAULT. * update --- src/brpc/server.cpp | 6 +----- src/bthread/bthread.cpp | 9 +++------ 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/brpc/server.cpp b/src/brpc/server.cpp index 0110761a..34b3c460 100644 --- a/src/brpc/server.cpp +++ b/src/brpc/server.cpp @@ -151,7 +151,7 @@ ServerOptions::ServerOptions() , health_reporter(NULL) , rtmp_service(NULL) , redis_service(NULL) - , bthread_tag(BTHREAD_TAG_INVALID) + , bthread_tag(BTHREAD_TAG_DEFAULT) , rpc_pb_message_factory(new DefaultRpcPBMessageFactory()) , ignore_eovercrowded(false) { if (s_ncore > 0) { @@ -846,10 +846,6 @@ int Server::StartInternal(const butil::EndPoint& endpoint, #endif } - auto original_bthread_tag = _options.bthread_tag; - if (original_bthread_tag == BTHREAD_TAG_INVALID) { - _options.bthread_tag = BTHREAD_TAG_DEFAULT; - } if (_options.bthread_tag < BTHREAD_TAG_DEFAULT || _options.bthread_tag >= FLAGS_task_group_ntags) { LOG(ERROR) << "Fail to set tag " << _options.bthread_tag << ", tag range is [" diff --git a/src/bthread/bthread.cpp b/src/bthread/bthread.cpp index f963c4a6..bf2c24f8 100644 --- a/src/bthread/bthread.cpp +++ b/src/bthread/bthread.cpp @@ -400,18 +400,15 @@ int bthread_setconcurrency_by_tag(int num, bthread_tag_t tag) { auto tag_ngroup = c->concurrency(tag); auto add = num - tag_ngroup; - if (add > 0) { + if (add >= 0) { auto added = c->add_workers(add, tag); bthread::FLAGS_bthread_concurrency += added; return (add == added ? 0 : EPERM); - - } else if (add < 0){ + } else { LOG(WARNING) << "Fail to set concurrency by tag: " << tag - << ", tag concurrency must larger than old oncurrency. old concurrency: " + << ", tag concurrency should be larger than old oncurrency. old concurrency: " << tag_ngroup << ", new concurrency: " << num; return EPERM; - } else { - return 0; } } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org For additional commands, e-mail: dev-h...@brpc.apache.org