Skip to content

ibv_close_device()

Contents

5.00 avg. rating (97% score) - 1 vote
int ibv_close_device(struct ibv_context *context);

Description

ibv_close_device() closes an RDMA device context.

ibv_close_device() won't release the resources that are associated with this context. It is up to the user to release them before calling to this verb, in order to prevent resource (such as memory, file descriptors, RDMA object numbers) leak. Using those orphan resources may result a Segmentation Fault.

However, when the process ends, those resources will be automatically cleaned by the Operating System.

Parameters

Name Direction Description
context in RDMA device context that was returned from ibv_open_device()

Return Values

ibv_close_device() returns 0 on success, -1 on failure.

Examples

Open a device context and close it:

/* In this example, we assume that this variable already holds the list of available devices */
struct ibv_device **device_list;
struct ibv_context *ctx;
 
ctx = ibv_open_device(device_list[0]);
if (!ctx) {
        fprintf(stderr, "Error, failed to open the device '%s'\n",
                ibv_get_device_name(device_list[i]));
        return -1;
}
 
printf("The device '%s' was opened\n", ibv_get_device_name(ctx->device));
 
rc = ibv_close_device(ctx);
if (rc) {
        fprintf(stderr, "Error, failed to close the device '%s'\n",
                ibv_get_device_name(ctx->device));
        return -1;
}

open_devices.c

Share Our Posts

Share this post through social bookmarks.

  • Delicious
  • Digg
  • Newsvine
  • RSS
  • StumbleUpon
  • Technorati

Comments

Tell us what do you think.

There are no comments on this entry.

Add a Comment

This comment will be moderated; answer may be provided within 14 days.

Time limit is exhausted. Please reload CAPTCHA.