[dpdk-dev] [PATCH v3 1/2] telemetry: fix missing check for thread creation
Min Hu (Connor)
humin29 at huawei.com
Fri Apr 16 10:21:58 CEST 2021
Hi, David, fixed in v4. Thanks.
在 2021/4/15 22:55, David Marchand 写道:
> On Thu, Apr 15, 2021 at 1:50 PM Min Hu (Connor) <humin29 at huawei.com> wrote:
>> diff --git a/lib/librte_telemetry/telemetry.c b/lib/librte_telemetry/telemetry.c
>> index 7e08afd..e6a99f3 100644
>> --- a/lib/librte_telemetry/telemetry.c
>> +++ b/lib/librte_telemetry/telemetry.c
>> @@ -350,6 +350,7 @@ socket_listener(void *socket)
>> {
>> while (1) {
>> pthread_t th;
>> + int rc;
>> struct socket *s = (struct socket *)socket;
>> int s_accepted = accept(s->sock, NULL, NULL);
>> if (s_accepted < 0) {
>> @@ -366,7 +367,12 @@ socket_listener(void *socket)
>> __atomic_add_fetch(s->num_clients, 1,
>> __ATOMIC_RELAXED);
>> }
>> - pthread_create(&th, NULL, s->fn, (void *)(uintptr_t)s_accepted);
>> + rc = pthread_create(&th, NULL, s->fn, (void *)(uintptr_t)s_accepted);
>> + if (rc != 0) {
>> + TMTY_LOG(ERR, "Error with create client thread\n");
>> + close(s_accepted);
>> + return NULL;
>> + }
>
> Repeating my comment:
>
> Either you use this rc variable (adding strerror(rc) in the log
> message in TMTY_LOG()) or you remove the variable and simply test if
> (pthread_create(...) != 0).
>
> This comment applies to other changes in this patch.
> And this applies to patch 2 too.
>
>> pthread_detach(th);
>> }
>> return NULL;
>
> Thanks.
>
>
> --
> David Marchand
>
> .
>
More information about the dev
mailing list