4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
24 /* All Rights Reserved */
27 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
28 * Use is subject to license terms.
31 #pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.3.4.1 */
37 #include <sys/stropts.h>
38 #include <sys/stream.h>
39 #define _SUN_TPI_VERSION 2
40 #include <sys/tihdr.h>
41 #include <sys/timod.h>
49 _tx_unbind(int fd
, int api_semantics
)
51 struct _ti_user
*tiptr
;
53 int sv_errno
, retval
, didalloc
;
56 if ((tiptr
= _t_checkfd(fd
, 0, api_semantics
)) == NULL
)
59 if (_T_IS_XTI(api_semantics
)) {
61 * User level state verification only done for XTI
62 * because doing for TLI may break existing applications
64 if (tiptr
->ti_state
!= T_IDLE
) {
71 * Since unbind is not an idempotent operation, we
72 * block signals around the call.
73 * Note that sig_mutex_lock() only defers signals, it does not
74 * block them, so interruptible syscalls could still get EINTR.
76 (void) thr_sigsetmask(SIG_SETMASK
, &fillset
, &mask
);
77 sig_mutex_lock(&tiptr
->ti_lock
);
79 * Acquire buffer for use in sending/receiving the message.
80 * Note: assumes (correctly) that ti_ctlsize is large enough
81 * to hold sizeof (struct T_unbind_req/ack)
83 if (_t_acquire_ctlbuf(tiptr
, &ctlbuf
, &didalloc
) < 0) {
85 sig_mutex_unlock(&tiptr
->ti_lock
);
86 (void) thr_sigsetmask(SIG_SETMASK
, &mask
, NULL
);
91 retval
= _tx_unbind_locked(fd
, tiptr
, &ctlbuf
);
97 tiptr
->ti_ctlbuf
= ctlbuf
.buf
;
98 sig_mutex_unlock(&tiptr
->ti_lock
);
99 (void) thr_sigsetmask(SIG_SETMASK
, &mask
, NULL
);
105 _tx_unbind_locked(int fd
, struct _ti_user
*tiptr
, struct strbuf
*ctlbufp
)
107 struct T_unbind_req
*unbind_reqp
;
110 if (_t_is_event(fd
, tiptr
) < 0)
113 /* LINTED pointer cast */
114 unbind_reqp
= (struct T_unbind_req
*)ctlbufp
->buf
;
115 unbind_reqp
->PRIM_type
= T_UNBIND_REQ
;
117 if (_t_do_ioctl(fd
, (char *)unbind_reqp
,
118 (int)sizeof (struct T_unbind_req
), TI_UNBIND
, &retlen
) < 0) {
122 if (ioctl(fd
, I_FLUSH
, FLUSHRW
) < 0) {
128 * clear more and expedited data bits
130 tiptr
->ti_flags
&= ~(MORE
|EXPEDITED
);
132 _T_TX_NEXTSTATE(T_UNBIND
, tiptr
,
133 "t_unbind: invalid state event T_UNBIND");