Main Page | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

vipdestroycq.c

Go to the documentation of this file.
00001 /********************************************************
00002  * Myricom VI-GM  networking software and documentation *
00003  * Copyright (c) 2001 by Myricom, Inc.                  *
00004  * All rights reserved.                                 *
00005  * See the file `COPYING' for copyright notice.         *
00006  ********************************************************/
00007 
00013 #include <stdlib.h>
00014 
00015 #include "vipl_priv.h"
00016 
00017 
00038 VIP_ENTRY_POINT VIP_RETURN
00039 VipDestroyCQ (VIP_CQ_HANDLE CQHandle)
00040 {
00041   VIP_CQ *vip_cq_ptr;
00042   VIP_NIC *vip_nic_ptr;
00043   VIP_DEBUG_LABEL (("VipDestroyCQ"));
00044 
00045 
00046   /* check regmem handle */
00047   vip_cq_ptr = (VIP_CQ *) CQHandle;
00048   if (VIP_INVALID_CQ_HANDLE (vip_cq_ptr))
00049     {
00050       VIP_DEBUG (("Invalid CQ handle"));
00051       return VIP_INVALID_PARAMETER;
00052     }
00053   vip_nic_ptr = vip_cq_ptr->handle.vip_nic_ptr;
00054   VIP_MUTEX_LOCK (&(vip_nic_ptr->lock));
00055 
00056   if (vip_cq_ptr->handle.ref_count > 0)
00057     {
00058       VIP_DEBUG (("CQ still in use"));
00059       VIP_MUTEX_UNLOCK (&(vip_nic_ptr->lock));
00060       return VIP_ERROR_RESOURCE;
00061     }
00062 
00063   if (vip_cq_ptr->count > 0)
00064     {
00065       VIP_ASSERT (vip_cq_ptr->queue != NULL);
00066       free (vip_cq_ptr->queue);
00067     }
00068 
00069   vip_free_handle (&(vip_nic_ptr->vip_cq_set), (VIP_HANDLE *) vip_cq_ptr);
00070   VIP_MUTEX_UNLOCK (&(vip_nic_ptr->lock));
00071   VIP_DEBUG (("Success"));
00072   return VIP_SUCCESS;
00073 }
VI-GM-1.3 by Myricom © 1997-2006. Documentation generated on 20 May 2006 by doxygen 1.4.4.