Skip to content

Commit

Permalink
telemetry: fix connected clients count
Browse files Browse the repository at this point in the history
[ upstream commit e14bb5f1050924de1602033596d5b417bfbeee52 ]

Telemetry can only create 10 conns by default, each of which is processed
by a thread.

When a thread fails to write using socket, the thread will end directly
without reducing the total number of conns.

This will result in the machine running for a long time, and if there are
10 failures, the telemetry will be unavailable

Fixes: 2a7d0b8 ("telemetry: add upper limit on connections")

Signed-off-by: Shaowei Sun <1819846787@qq.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Ciara Power <ciara.power@intel.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
  • Loading branch information
sunaaaaaaa authored and kevintraynor committed Mar 5, 2024
1 parent 4062550 commit 1af693e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,7 @@ Shally Verma <shallyv@marvell.com> <shally.verma@caviumnetworks.com>
Shannon Nelson <snelson@pensando.io>
Shannon Zhao <zhaoshenglong@huawei.com>
Shaopeng He <shaopeng.he@intel.com>
Shaowei Sun <1819846787@qq.com>
Sharmila Podury <sharmila.podury@att.com>
Sharon Haroni <sharon.haroni@intel.com>
Shay Agroskin <shayagr@amazon.com>
Expand Down
5 changes: 3 additions & 2 deletions lib/telemetry/telemetry.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,8 @@ client_handler(void *sock_id)
"{\"version\":\"%s\",\"pid\":%d,\"max_output_len\":%d}",
telemetry_version, getpid(), MAX_OUTPUT_LEN);
if (write(s, info_str, strlen(info_str)) < 0) {
close(s);
return NULL;
TMTY_LOG(ERR, "Socket write base info to client failed\n");
goto exit;
}

/* receive data is not null terminated */
Expand All @@ -400,6 +400,7 @@ client_handler(void *sock_id)

bytes = read(s, buffer, sizeof(buffer) - 1);
}
exit:
close(s);
__atomic_sub_fetch(&v2_clients, 1, __ATOMIC_RELAXED);
return NULL;
Expand Down

0 comments on commit 1af693e

Please sign in to comment.