xref: /titanic_51/usr/src/lib/udapl/udapl_tavor/common/dapl_evd_free.c (revision 9e39c5ba00a55fa05777cc94b148296af305e135)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright (c) 2002-2003, Network Appliance, Inc. All rights reserved.
24  */
25 
26 /*
27  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
28  * Use is subject to license terms.
29  */
30 
31 /*
32  *
33  * MODULE: dapl_evd_free.c
34  *
35  * PURPOSE: Event management
36  * Description: Interfaces in this file are completely described in
37  *        the DAPL 1.1 API, Chapter 6, section 3
38  *
39  * $Id: dapl_evd_free.c,v 1.9 2003/07/30 18:13:38 hobie16 Exp $
40  */
41 
42 #include "dapl.h"
43 #include "dapl_evd_util.h"
44 #include "dapl_ia_util.h"
45 
46 /*
47  * dapl_evd_free
48  *
49  * DAPL Requirements Version xxx, 6.3.2.2
50  *
51  * Destroy a specific instance of the Event Dispatcher
52  *
53  * Input:
54  *     evd_handle
55  *
56  * Output:
57  *     None
58  *
59  * Returns:
60  *     DAT_SUCCESS
61  *     DAT_INVALID_HANDLE
62  *     DAT_INVALID_STATE
63  */
64 DAT_RETURN
65 dapl_evd_free(
66 	IN    DAT_EVD_HANDLE    evd_handle)
67 {
68 	DAPL_EVD    *evd_ptr;
69 	DAT_RETURN  dat_status;
70 
71 	dapl_dbg_log(DAPL_DBG_TYPE_API, "dapl_evd_free (%p)\n", evd_handle);
72 
73 	dat_status = DAT_SUCCESS;
74 	evd_ptr = (DAPL_EVD *)evd_handle;
75 
76 	if (DAPL_BAD_HANDLE(evd_handle, DAPL_MAGIC_EVD)) {
77 		dat_status = DAT_ERROR(DAT_INVALID_HANDLE, 0);
78 		goto bail;
79 	}
80 
81 	if (evd_ptr->evd_ref_count != 0) {
82 		dat_status = DAT_ERROR(DAT_INVALID_STATE,
83 		    DAT_INVALID_STATE_EVD_IN_USE);
84 		goto bail;
85 	}
86 
87 	dapl_ia_unlink_evd(evd_ptr->header.owner_ia, evd_ptr);
88 
89 	dat_status = dapls_evd_dealloc(evd_ptr);
90 	if (dat_status != DAT_SUCCESS) {
91 		dapl_ia_link_evd(evd_ptr->header.owner_ia, evd_ptr);
92 	}
93 bail:
94 	dapl_dbg_log(DAPL_DBG_TYPE_RTN,
95 	    "dapl_evd_free () returns 0x%x\n",
96 	    dat_status);
97 
98 	return (dat_status);
99 }
100