From mboxrd@z Thu Jan 1 00:00:00 1970 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) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=cUQ7II//gIU93oNL4EfZppmD0+enXOkFg4Q37jtuyKU=; b=bvYt4bqbKeLAWPK/abxmPseOyiQ9xKrFU5ZuLKZxUZtovDzxGJQY7qPrcYkfZdk/mO KbDwIUSCWep3YiCKKKug4PHXJnXc0bdg5B0vpIIB3zvtYUnFLoaip6i6eeSbJiVaZEZJ db1fNj83xKP0tNby5KAcJ/mZG3eRIBSaVbjIVUXiv7/Bez4X/CGSlXg/UdYoH2Orn5NB /1aeIJTxThfNCyM2wBuzFZC5ASMQoqe16BpgS0WUpoHgVFYrk+Mbu28RTvLaYLfjOk7t D1ATg2xOXdqna6UW3+dIuNYz34uOwUdpeyBghhluG2W5zPwYMQjEKeLC4LHxi9oUG8Jp e/JQ== X-Gm-Message-State: ALoCoQm/bwMF8LHs1Ase4RsoXFojicnooKRB4FHAvuHo+ZvTH84XFJwh+G/DvXWQ5xyLzc2UuXIs X-Received: by 10.68.167.131 with SMTP id zo3mr15966587pbb.123.1434589238280; Wed, 17 Jun 2015 18:00:38 -0700 (PDT) Received: from [10.16.129.101] (napt.igel.co.jp. [219.106.231.132]) by mx.google.com with ESMTPSA id ko1sm6003971pdb.58.2015.06.17.18.00.36 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jun 2015 18:00:37 -0700 (PDT) Message-ID: <55821834.3010500@igel.co.jp> Date: Thu, 18 Jun 2015 10:00:36 +0900 From: Tetsuya Mukawa User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: "Xie, Huawei" References: <1433209800-29091-1-git-send-email-huawei.xie@intel.com> <5580F4C7.30604@igel.co.jp> In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit 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: Thu, 18 Jun 2015 01:00:39 -0000 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