[CP] limit the maxmum of net_thread_count

This commit is contained in:
liucc1997
2024-02-28 02:15:07 +00:00
committed by ob-robot
parent 6288816744
commit 32f925129f
2 changed files with 5 additions and 0 deletions

View File

@ -247,6 +247,10 @@ PN_API int pn_provision(int listen_id, int gid, int thread_count)
int count = 0; int count = 0;
pn_grp_t* pn_grp = ensure_grp(gid); pn_grp_t* pn_grp = ensure_grp(gid);
ef(pn_grp == NULL); ef(pn_grp == NULL);
if (thread_count > MAX_PN_PER_GRP) {
err = -EINVAL;
rk_error("thread count is too large, thread_count=%d, MAX_PN_PER_GRP=%d", thread_count, MAX_PN_PER_GRP);
}
count = pn_grp->count; count = pn_grp->count;
while(0 == err && count < thread_count) { while(0 == err && count < thread_count) {
pn_t* pn = pn_create(listen_id, gid, count); pn_t* pn = pn_create(listen_id, gid, count);

View File

@ -132,6 +132,7 @@ static int get_default_net_thread_count()
cnt = 7; cnt = 7;
} else { } else {
cnt = max(8, cpu_num / 6); cnt = max(8, cpu_num / 6);
cnt = min(cnt, 64);
} }
return cnt; return cnt;
} }