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")
Cc: [email protected]

Signed-off-by: Shaowei Sun <[email protected]>
Acked-by: Bruce Richardson <[email protected]>
Acked-by: Ciara Power <[email protected]>
Acked-by: Chengwen Feng <[email protected]>
  • Loading branch information
sunaaaaaaa authored and kevintraynor committed Mar 5, 2024
1 parent 4062550 commit 840c72f
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 <[email protected]> <[email protected]>
Shannon Nelson <[email protected]>
Shannon Zhao <[email protected]>
Shaopeng He <[email protected]>
Shaowei Sun <[email protected]>
Sharmila Podury <[email protected]>
Sharon Haroni <[email protected]>
Shay Agroskin <[email protected]>
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 840c72f

Please sign in to comment.