From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 47D04C3FA for ; Wed, 17 Jun 2015 13:05:21 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 17 Jun 2015 04:05:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,632,1427785200"; d="scan'208";a="712544328" Received: from kmsmsx153.gar.corp.intel.com ([172.21.73.88]) by orsmga001.jf.intel.com with ESMTP; 17 Jun 2015 04:05:18 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by KMSMSX153.gar.corp.intel.com (172.21.73.88) with Microsoft SMTP Server (TLS) id 14.3.224.2; Wed, 17 Jun 2015 19:05:17 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.246]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.146]) with mapi id 14.03.0224.002; Wed, 17 Jun 2015 19:05:16 +0800 From: "Xie, Huawei" To: Tetsuya Mukawa Thread-Topic: [dpdk-dev] [PATCH] vhost: provide vhost API to unregister vhost unix domain socket Thread-Index: AdCo7X0fXvhiu4FrT6WG3TChzF8pSA== Date: Wed, 17 Jun 2015 11:05:15 +0000 Message-ID: References: <1433209800-29091-1-git-send-email-huawei.xie@intel.com> <5580F4C7.30604@igel.co.jp> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH] vhost: provide vhost API to unregister vhost unix domain socket X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Jun 2015 11:05:21 -0000 On 6/17/2015 12:17 PM, Tetsuya Mukawa wrote:=0A= > On 2015/06/02 10:50, Huawei Xie wrote:=0A= >> rte_vhost_driver_unregister will remove the listenfd from event list, an= d then close it.=0A= >>=0A= >> Signed-off-by: Huawei Xie =0A= >> Signed-off-by: Peng Sun =0A= >> ---=0A= >> =0A= >> +/**=0A= >> + * Unregister the specified vhost server=0A= >> + */=0A= >> +int=0A= >> +rte_vhost_driver_unregister(const char *path)=0A= >> +{=0A= >> + int i;=0A= >> + int count;=0A= >> +=0A= >> + pthread_mutex_lock(&g_vhost_server.server_mutex);=0A= >> +=0A= >> + for (i =3D 0; i < g_vhost_server.vserver_cnt; i++) {=0A= >> + if (!strcmp(g_vhost_server.server[i]->path, path)) {=0A= >> + fdset_del(&g_vhost_server.fdset,=0A= >> + g_vhost_server.server[i]->listenfd);=0A= >> +=0A= >> + close(g_vhost_server.server[i]->listenfd);=0A= >> + free(g_vhost_server.server[i]->path);=0A= >> + free(g_vhost_server.server[i]);=0A= >> +=0A= >> + unlink(path);=0A= >> +=0A= >> + count =3D --g_vhost_server.vserver_cnt;=0A= >> + g_vhost_server.server[i] =3D=0A= >> + g_vhost_server.server[count];=0A= >> + g_vhost_server.server[count] =3D=0A= >> + NULL;=0A= >> + pthread_mutex_unlock(&g_vhost_server.server_mutex);=0A= >> +=0A= >> + return 0;=0A= >> + }=0A= >> + }=0A= >> + pthread_mutex_unlock(&g_vhost_server.server_mutex);=0A= >> +=0A= >> + return -1;=0A= >> +}=0A= >> +=0A= >>=0A= > Hi Xie,=0A= >=0A= > It seems vserver_cnt is incremented when socket is registered, and=0A= > decremented when unregistered.=0A= > And this value is used for index value of g_vhost_server.server[ ], when= =0A= > a new socket is registered.=0A= When we unregister a server at index x, we will move the server at the=0A= tail of the array to the location x.=0A= > So I have a question about below case.=0A= >=0A= > Step1. socket0 is registered.=0A= > Step2: scoekt1 is registered.=0A= > Step3. socket0 is unregistered.=0A= When socket0 is unregistered, socket1 will be moved to location at index 0= .=0A= > Step4. socket2 is registered.=0A= socket2 is registered at index 1.=0A= >=0A= > After above steps, are socket1 and socket2 still registered?=0A= >=0A= > Thanks,=0A= > Tetsuya=0A= >=0A= >=0A= What is your concern here?=0A=