mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
slowdown the cpu usage for srs to calc connections when too many connections. 0.9.180
This commit is contained in:
parent
6539ce69f4
commit
15d4993cc3
4 changed files with 12 additions and 4 deletions
|
@ -833,10 +833,18 @@ void srs_update_rtmp_server(int nb_conn, SrsKbps* kbps)
|
|||
int nb_conn_sys_other = 0;
|
||||
|
||||
// @see: http://tester-higkoo.googlecode.com/svn-history/r14/trunk/Tools/iostat/iostat.c
|
||||
while (fgets(buf, sizeof(buf), f)) {
|
||||
for (int i = 0; fgets(buf, sizeof(buf), f); i++) {
|
||||
int st = 0;
|
||||
int ret = sscanf(buf, "%*s %*s %*s %2x\n", &st);
|
||||
|
||||
// there are maybe many many connections,
|
||||
// for example, when srs used for monitor other process,
|
||||
// like nginx, there are maybe many TIME_WAIT conections.
|
||||
// we sleep 1ms when read 1000 records, so 100ms for 10w connections.
|
||||
if ((i % 1000) == 0) {
|
||||
st_usleep(1000);
|
||||
}
|
||||
|
||||
if (ret == 1) {
|
||||
if (st == SYS_TCP_ESTABLISHED) {
|
||||
nb_conn_sys_established++;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue