From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 84CBFA0C3F; Thu, 15 Apr 2021 18:11:11 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5DC301623C7; Thu, 15 Apr 2021 18:11:11 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id 238A61623BF for ; Thu, 15 Apr 2021 18:11:08 +0200 (CEST) IronPort-SDR: UUNtytzOgCeTiUxgtBLTwRQpwLmlnA2Unpu7GpqCllCvFme3C3UkbUpkCsLuxVvR/Vklt7kZKX hghyc3Uajyrw== X-IronPort-AV: E=McAfee;i="6200,9189,9955"; a="194994444" X-IronPort-AV: E=Sophos;i="5.82,225,1613462400"; d="scan'208";a="194994444" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2021 09:11:07 -0700 IronPort-SDR: zZJGjLDzezi7MHz5R41piMmoPlHGElXA46j+rRyTZC3+U8li0Oge112iMy7tJ9IuAmXAJC662r RPP+8z5u7VUw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,225,1613462400"; d="scan'208";a="612493296" Received: from orsmsx605.amr.corp.intel.com ([10.22.229.18]) by fmsmga006.fm.intel.com with ESMTP; 15 Apr 2021 09:11:07 -0700 Received: from orsmsx609.amr.corp.intel.com (10.22.229.22) by ORSMSX605.amr.corp.intel.com (10.22.229.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Thu, 15 Apr 2021 09:11:07 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX609.amr.corp.intel.com (10.22.229.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Thu, 15 Apr 2021 09:11:06 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2 via Frontend Transport; Thu, 15 Apr 2021 09:11:06 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.173) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2106.2; Thu, 15 Apr 2021 09:11:06 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ci96wYPCCiQC4NsoYIfMLzL9wiy7mTqqoqiMocf/EMsvkb+gMIUKZXmbEWHjM0SX/ZVekF2Zwinfj9ym3xyihniA1R3tj4aNEET4SPQ5GevW2OGOx3SOMK2FX3L9iqaHgU/lbDSp7CVwmCQWH7WPbR5VP49/bejdAfWkef/+Xt1+fN+8QjS4Dr6wOgZRWO6569tRrjsP9BgXrptORd8ZxcDzR4HN+qLjQvfngLt/LRo1mdzHkC0CmA6vFdKf1HO22wp/OMY7034o156Z6Vs+0BrW6NIl+RfKNux2NsYSE0aV8haHO28rOKfcwZxk74y/fVUbw5vzWnk4xKXdNf7Yyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9pe9BmhNLgxY1kpPCdvJnbkx/7nnKb1XkHMh77AAmHU=; b=Oj8wadNzAW7t9rRtdq2ukN4gFym/Y5ZfEnVGOVlt6TTEYvd4aV4NImOSsOshNQcpYgVCh3BpjcMcnxpMV6pxRfALc5uKgO1dLI2OK2XUyox2PxmMe/0xQcDBMQpZcd/5bDilq5Mua1RAyGj49gk1i7hk/0GFVQ9WlAMR2kGODfIcniofOR3BVb+jQRQyH16dCTuJS2skbxjmVQaLdkdNASpA8skqqY1hL5Us3pVGOfwRVfBkoaCSCHkRYDS0hRFzbl08ZJw028kqOGXmRv8PzjpqFVTjaGQYnAosHXkDGYb7uWLvL6SBWtY38I1Rdz5bF6h47zuHpDMhZrT6a9VFXw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9pe9BmhNLgxY1kpPCdvJnbkx/7nnKb1XkHMh77AAmHU=; b=usZ14XW1vdqvXYktgg5F5225CqOSB4B01oZp6yMP6lSthR0qxrAQO2/2NFQSbiLP8Z3mzpVwfGVKnstCDQ8l/bBr/gEEIgcK83cwPVsHG5ncR/PgvEVVKDY4zTxlwmXiWj1BEIplM5o2RuYByO5GbcPVkeoEDuERKO4YQbxPdJw= Received: from MN2PR11MB3821.namprd11.prod.outlook.com (2603:10b6:208:f7::24) by MN2PR11MB4014.namprd11.prod.outlook.com (2603:10b6:208:137::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.22; Thu, 15 Apr 2021 16:11:01 +0000 Received: from MN2PR11MB3821.namprd11.prod.outlook.com ([fe80::546c:75a5:fe9d:de32]) by MN2PR11MB3821.namprd11.prod.outlook.com ([fe80::546c:75a5:fe9d:de32%5]) with mapi id 15.20.4042.018; Thu, 15 Apr 2021 16:11:01 +0000 From: "Power, Ciara" To: "Min Hu (Connor)" , "dev@dpdk.org" CC: "Yigit, Ferruh" , "Pattan, Reshma" , "david.marchand@redhat.com" Thread-Topic: [PATCH v3 1/2] telemetry: fix missing check for thread creation Thread-Index: AQHXMe2IjYxuHaggrEywrGYfUDFfF6q1vKaA Date: Thu, 15 Apr 2021 16:11:01 +0000 Message-ID: References: <1618051453-21264-1-git-send-email-humin29@huawei.com> <1618487412-26678-1-git-send-email-humin29@huawei.com> <1618487412-26678-2-git-send-email-humin29@huawei.com> In-Reply-To: <1618487412-26678-2-git-send-email-humin29@huawei.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.5.1.3 dlp-product: dlpe-windows dlp-reaction: no-action authentication-results: huawei.com; dkim=none (message not signed) header.d=none;huawei.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [78.17.80.160] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 02ea0b37-eb7d-4347-6293-08d90029104a x-ms-traffictypediagnostic: MN2PR11MB4014: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3513; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 2+dvEzaLEh1kKX8LrhR12fMc/ZQQAQas0yqw+TvRvN9PuQkhXQHoOhDMvBH9amZIT4Gmi/IwGCMZ1WE9EGp6QvGzr2t1962nodRBNRIvQR9a6m2MBKl6f/P8hSxFyd6QQkjAad/HCKgpAZaXXZI4Z0dQVrSorceKDh0iGV3IAeHs9Obt8Qb5g2zVwd0m+/C7NoTa6OHCxSNtBD5fXzmBQJxEHwk3FqDIflE0Vp3QrhWnr1pP+yP5MATQhxtBd2tjbar3OjU2oIqeX72SyEHygpPnnpOcz0BNQPLwPK9KrLLdDLFmrxMPOhCLmp+Te0+osqhckbvGylC3M5RaBdulixYwHfYDLR7BtmVQk98v5W0w02ZZWk9w8tebgaYz0FAhtAWJQ2dVuUH8Ah3GcZYUT5R2YKWeR/pdylYNL40A9VXDlsTVXofNbefRJGjSKUHwxwDnmgr0G9bp7bw7fnpIMSihEgFLu4zzcvH/B+M60MMkXdm8lUxUqQpqpE/SMa5sm169V2n7bmYW8YBuiqMG9veUZoN/QwWtJaCYInprClwFXenScOHiWPW15dd1L+rUv7TqaqdFwpPOWfOyFpBklnDVKroq372Z6eo0+z4XgOU= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MN2PR11MB3821.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(376002)(396003)(39860400002)(136003)(366004)(346002)(33656002)(52536014)(110136005)(55016002)(316002)(38100700002)(5660300002)(122000001)(71200400001)(6506007)(54906003)(9686003)(2906002)(4326008)(26005)(186003)(478600001)(66476007)(8676002)(8936002)(76116006)(66946007)(86362001)(7696005)(66556008)(64756008)(83380400001)(66446008); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?kYQtwXNWXXiOhGkd4j/3UdC3u7128SpAOsvw5fsHqtL0BSga3g/izEjE+drK?= =?us-ascii?Q?lGtLcshRBTf4RpQx2ko2dqyLFIIMo6UO65zvxSEHZileNN9Qe744OgrESar5?= =?us-ascii?Q?KjoCGijuliW8jyvjHIxTHqPCkY0uyiK+Gd9fxPe6qbntSIzwcRbFtdAAlKWa?= =?us-ascii?Q?4Na3ztWO/8xxZMbJ21VuCgDWl/yhJqkuVgHfJbQoPQJdhaNj2akpTux1iBfK?= =?us-ascii?Q?m0wGDF+y1c6AkkYeLkjO64Hd3vxTDfzZGiQDpOLot0LSwUGY/1u2S3w9M1QK?= =?us-ascii?Q?E9oShmPc8h5O0YePHI8RyjERXq7pYQqO9eSfPSo2DYe9HH8TleT1pF7Z+NYe?= =?us-ascii?Q?SJvLLnIRKlUI/dW/ExkbdA8twqwZJfy7Vt7CQVtGNOMuBUaqX9V6UM6Z7CxP?= =?us-ascii?Q?su4JbwIxIL+j3DkDKTOEmrWtGx7yJpV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ascii?Q?L1o=3D?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN2PR11MB3821.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 02ea0b37-eb7d-4347-6293-08d90029104a X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Apr 2021 16:11:01.1358 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: h6tqoaDJy+kECoOCsE+Rs8Zu7wGXW0XSaWI8bqRyIrvyTf/tSjTgtyz0mxjD1BNkx0+VF9wpLtjvOyFVyoXW8g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4014 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v3 1/2] telemetry: fix missing check for thread creation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Connor,=20 Thanks for looking at this. Left some comments inline. Ciara >-----Original Message----- >From: Min Hu (Connor) >Sent: Thursday 15 April 2021 12:50 >To: dev@dpdk.org >Cc: Yigit, Ferruh ; Power, Ciara >; Pattan, Reshma ; >david.marchand@redhat.com >Subject: [PATCH v3 1/2] telemetry: fix missing check for thread creation > >From: Chengwen Feng > >Add result check and message print out for thread creation after failure. > >Fixes: b80fe1805eee ("telemetry: introduce backward compatibility") >Cc: stable@dpdk.org > >Signed-off-by: Chengwen Feng >Signed-off-by: Min Hu (Connor) >--- > lib/librte_telemetry/telemetry.c | 30 +++++++++++++++++++++++++++- >-- > lib/librte_telemetry/telemetry_legacy.c | 10 ++++++++-- > 2 files changed, 35 insertions(+), 5 deletions(-) > >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 =3D (struct socket *)socket; > int s_accepted =3D 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 =3D pthread_create(&th, NULL, s->fn, (void >*)(uintptr_t)s_accepted); >+ if (rc !=3D 0) { >+ TMTY_LOG(ERR, "Error with create client thread\n"); >+ close(s_accepted); >+ return NULL; I think this should be "continue" instead of "return NULL" - if one client = connection thread fails, we probably want to keep listening for more clients rather than stop comple= tely. The "s->num_clients" counter should be decremented here too, it gets incremented above when the connection is accepted, but if we are cl= osing the connection, the counter should reflect that. >+ } > pthread_detach(th); > } > return NULL; >@@ -425,6 +431,7 @@ static int > telemetry_legacy_init(void) > { > pthread_t t_old; >+ int rc; > > if (num_legacy_callbacks =3D=3D 1) { > TMTY_LOG(WARNING, "No legacy callbacks, legacy socket not >created\n"); @@ -440,7 +447,15 @@ telemetry_legacy_init(void) > v1_socket.sock =3D create_socket(v1_socket.path); > if (v1_socket.sock < 0) > return -1; >- pthread_create(&t_old, NULL, socket_listener, &v1_socket); >+ rc =3D pthread_create(&t_old, NULL, socket_listener, &v1_socket); >+ if (rc !=3D 0) { >+ TMTY_LOG(ERR, "Error with create thread for legacy >socket\n"); >+ close(v1_socket.sock); >+ v1_socket.sock =3D -1; >+ unlink(v1_socket.path); >+ v1_socket.path[0] =3D '\0'; >+ return -1; >+ } > pthread_setaffinity_np(t_old, sizeof(*thread_cpuset), >thread_cpuset); > > TMTY_LOG(DEBUG, "Legacy telemetry socket initialized ok\n"); @@ - >451,6 +466,7 @@ static int > telemetry_v2_init(void) > { > pthread_t t_new; >+ int rc; > > v2_socket.num_clients =3D &v2_clients; > rte_telemetry_register_cmd("/", list_commands, @@ -469,7 +485,15 >@@ telemetry_v2_init(void) > v2_socket.sock =3D create_socket(v2_socket.path); > if (v2_socket.sock < 0) > return -1; >- pthread_create(&t_new, NULL, socket_listener, &v2_socket); >+ rc =3D pthread_create(&t_new, NULL, socket_listener, &v2_socket); >+ if (rc !=3D 0) { >+ TMTY_LOG(ERR, "Error with create thread for socket"); >+ close(v2_socket.sock); >+ v2_socket.sock =3D -1; >+ unlink(v2_socket.path); >+ v2_socket.path[0] =3D '\0'; >+ return -1; >+ } > pthread_setaffinity_np(t_new, sizeof(*thread_cpuset), >thread_cpuset); > atexit(unlink_sockets); > >diff --git a/lib/librte_telemetry/telemetry_legacy.c >b/lib/librte_telemetry/telemetry_legacy.c >index 5e9af37..fd242bf 100644 >--- a/lib/librte_telemetry/telemetry_legacy.c >+++ b/lib/librte_telemetry/telemetry_legacy.c >@@ -83,6 +83,7 @@ register_client(const char *cmd __rte_unused, const >char *params, > pthread_t th; > char data[BUF_SIZE]; > int fd; >+ int rc; > struct sockaddr_un addrs; > #endif /* !RTE_EXEC_ENV_WINDOWS */ > >@@ -112,8 +113,13 @@ register_client(const char *cmd __rte_unused, const >char *params, > close(fd); > return -1; > } >- pthread_create(&th, NULL, &legacy_client_handler, >- (void *)(uintptr_t)fd); >+ rc =3D pthread_create(&th, NULL, &legacy_client_handler, >+ (void *)(uintptr_t)fd); >+ if (rc !=3D 0) { >+ perror("Failed to create legacy client thread\n"); >+ close(fd); >+ return -1; >+ } > #endif /* !RTE_EXEC_ENV_WINDOWS */ > return 0; > } >-- >2.7.4