Skip to content

Commit

Permalink
Change the default value of the bthread_tag in class ServerOptions to…
Browse files Browse the repository at this point in the history
… BTHREAD_TAG_DEFAULT (#2824)

* Change the default value of the bthread_tag in class ServerOptions to BTHREAD_TAG_DEFAULT.

* update
  • Loading branch information
MJY-HUST authored Nov 24, 2024
1 parent 72ce354 commit 67eb4ef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
6 changes: 1 addition & 5 deletions src/brpc/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 ["
Expand Down
9 changes: 3 additions & 6 deletions src/bthread/bthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down

0 comments on commit 67eb4ef

Please sign in to comment.