[dpdk-dev] [PATCH] vhost: provide vhost API to unregister vhost unix domain socket
Tetsuya Mukawa
mukawa at igel.co.jp
Thu Jun 18 03:00:36 CEST 2015
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 <huawei.xie at intel.com>
>>> Signed-off-by: Peng Sun <peng.a.sun at intel.com>
>>> ---
>>>
>>> +/**
>>> + * 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
More information about the dev
mailing list