From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tetsuya Mukawa Subject: Re: [PATCH] vhost: provide vhost API to unregister vhost unix domain socket Date: Thu, 18 Jun 2015 10:00:36 +0900 Message-ID: <55821834.3010500@igel.co.jp> References: <1433209800-29091-1-git-send-email-huawei.xie@intel.com> <5580F4C7.30604@igel.co.jp> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Cc: "dev@dpdk.org" To: "Xie, Huawei" Return-path: Received: from mail-pa0-f48.google.com (mail-pa0-f48.google.com [209.85.220.48]) by dpdk.org (Postfix) with ESMTP id 24F76C4E8 for ; Thu, 18 Jun 2015 03:00:39 +0200 (CEST) Received: by pabvl15 with SMTP id vl15so2358644pab.1 for ; Wed, 17 Jun 2015 18:00:38 -0700 (PDT) In-Reply-To: List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 2015/06/17 20:05, Xie, Huawei wrote: > On 6/17/2015 12:17 PM, Tetsuya Mukawa wrote: >> On 2015/06/02 10:50, Huawei Xie wrote: >>> rte_vhost_driver_unregister will remove the listenfd from event list, and then close it. >>> >>> Signed-off-by: Huawei Xie >>> Signed-off-by: Peng Sun >>> --- >>> >>> +/** >>> + * Unregister the specified vhost server >>> + */ >>> +int >>> +rte_vhost_driver_unregister(const char *path) >>> +{ >>> + int i; >>> + int count; >>> + >>> + pthread_mutex_lock(&g_vhost_server.server_mutex); >>> + >>> + for (i = 0; i < g_vhost_server.vserver_cnt; i++) { >>> + if (!strcmp(g_vhost_server.server[i]->path, path)) { >>> + fdset_del(&g_vhost_server.fdset, >>> + g_vhost_server.server[i]->listenfd); >>> + >>> + close(g_vhost_server.server[i]->listenfd); >>> + free(g_vhost_server.server[i]->path); >>> + free(g_vhost_server.server[i]); >>> + >>> + unlink(path); >>> + >>> + count = --g_vhost_server.vserver_cnt; >>> + g_vhost_server.server[i] = >>> + g_vhost_server.server[count]; >>> + g_vhost_server.server[count] = >>> + NULL; >>> + pthread_mutex_unlock(&g_vhost_server.server_mutex); >>> + >>> + return 0; >>> + } >>> + } >>> + pthread_mutex_unlock(&g_vhost_server.server_mutex); >>> + >>> + return -1; >>> +} >>> + >>> >> Hi Xie, >> >> It seems vserver_cnt is incremented when socket is registered, and >> decremented when unregistered. >> And this value is used for index value of g_vhost_server.server[ ], when >> a new socket is registered. > When we unregister a server at index x, we will move the server at the > tail of the array to the location x. >> So I have a question about below case. >> >> Step1. socket0 is registered. >> Step2: scoekt1 is registered. >> Step3. socket0 is unregistered. > When socket0 is unregistered, socket1 will be moved to location at index 0. Thanks for explanation, I overlooked this behavior. Now I don't have any concerns. Thanks, Tetsuya