[ofw] [PATCH v2] libibverbs/device: destroy completion channel when closing device

Tzachi Dar tzachid at mellanox.co.il
Sun Jan 31 06:17:52 PST 2010


Hi Sean,

There is one issue that I'm afraid that this checkin is not looking into.

There is a general problem with closing a handle that one might be waiting on:
Consider a single handle g_handle.

Thread A is calling waitforsingleobject(g_handle)

Thread B that wants to free thread A is calling closehandle on g_handle.
If Thread A was indeed able to wait on the handle than it will be freed. But it is also possibale that for some reason thread a was not scheduled and never reached the wait code. Further more, it is possibale that after thread b has closed the g_handle this handle will be reused. In that case thread A might wait for ever.

Are you sure that your checkin doesn't introduce this kind of bug?

Thanks
Tzachi
 

> -----Original Message-----
> From: ofw-bounces at lists.openfabrics.org 
> [mailto:ofw-bounces at lists.openfabrics.org] On Behalf Of Sean Hefty
> Sent: Friday, January 29, 2010 2:51 AM
> To: Hefty, Sean; 'ofw_list'; Smith, Stan
> Subject: [ofw] [PATCH v2] libibverbs/device: destroy 
> completion channel when closing device
> 
> ibv_close_device should destroy the completion channel when 
> closing the device and freeing the memory.
> 
> Changes from v1:
> moved the call to CompChannelCleanup above ibv_release.  
> ibv_release has the potential to free the completion manager 
> referenced by the channel.
> 
> Signed-off-by: Sean Hefty <sean.hefty at intel.com>
> ---
> This patch should replace the v1 patch with the same subject in 2.2.
> 
> 
>  trunk/ulp/libibverbs/src/device.cpp |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/trunk/ulp/libibverbs/src/device.cpp 
> b/trunk/ulp/libibverbs/src/device.cpp
> index a515a16..1b66d3c 100644
> --- a/trunk/ulp/libibverbs/src/device.cpp
> +++ b/trunk/ulp/libibverbs/src/device.cpp
> @@ -279,6 +279,7 @@ int ibv_close_device(struct ibv_context *context)
>  	}
>  
>  	context->cmd_if->Release();
> +	CompChannelCleanup(&vcontext->context.channel);
>  	ibv_release();
>  	delete vcontext->port;
>  	delete vcontext;
> 
> 
> _______________________________________________
> ofw mailing list
> ofw at lists.openfabrics.org
> http://lists.openfabrics.org/cgi-bin/mailman/listinfo/ofw
> 


More information about the ofw mailing list