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, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 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. 13 * 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] 19 * 20 * CDDL HEADER END 21 */ 22 23 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 24 /* All Rights Reserved */ 25 26 /* 27 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 28 * Use is subject to license terms. 29 */ 30 31 #pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.3 */ 32 33 #include "mt.h" 34 #include <stdlib.h> 35 #include <errno.h> 36 #include <stropts.h> 37 #include <xti.h> 38 #include <sys/timod.h> 39 #include "tx.h" 40 41 42 /* 43 * t_rcvconnect() is documented to be only called with non-blocking 44 * endpoints for asynchronous connection establishment. However, the 45 * direction taken by XTI is to allow it to be called if t_connect() 46 * fails with TSYSERR/EINTR and state is T_OUTCON (i.e. T_CONN_REQ was 47 * sent down). This implies that an interrupted synchronous connection 48 * establishment which was interrupted after connection request was transmitted 49 * can now be completed by calling t_rcvconnect() 50 */ 51 int 52 _tx_rcvconnect(int fd, struct t_call *call, int api_semantics) 53 { 54 struct _ti_user *tiptr; 55 int retval, sv_errno; 56 struct strbuf ctlbuf; 57 int didalloc; 58 59 if ((tiptr = _t_checkfd(fd, 0, api_semantics)) == NULL) 60 return (-1); 61 62 sig_mutex_lock(&tiptr->ti_lock); 63 64 if (_T_IS_XTI(api_semantics)) { 65 /* 66 * User level state verification only done for XTI 67 * because doing for TLI may break existing applications 68 */ 69 if (tiptr->ti_state != T_OUTCON) { 70 t_errno = TOUTSTATE; 71 sig_mutex_unlock(&tiptr->ti_lock); 72 return (-1); 73 } 74 } 75 76 /* 77 * Acquire ctlbuf for use in sending/receiving control part 78 * of the message. 79 */ 80 if (_t_acquire_ctlbuf(tiptr, &ctlbuf, &didalloc) < 0) { 81 sv_errno = errno; 82 sig_mutex_unlock(&tiptr->ti_lock); 83 errno = sv_errno; 84 return (-1); 85 } 86 87 retval = _t_rcv_conn_con(tiptr, call, &ctlbuf, api_semantics); 88 if (retval == 0 || t_errno == TBUFOVFLW) { 89 _T_TX_NEXTSTATE(T_RCVCONNECT, tiptr, 90 "t_rcvconnect: Invalid state on event T_RCVCONNECT"); 91 /* 92 * Update attributes which may have been negotiated during 93 * connection establishment for protocols where we suspect 94 * such negotiation is likely (e.g. OSI). We do not do it for 95 * all endpoints for performance reasons. Also, this code is 96 * deliberately done after user level state changes so even 97 * the (unlikely) failure case reflects a connected endpoint. 98 */ 99 if (tiptr->ti_tsdusize != 0) 100 if (_t_do_postconn_sync(fd, tiptr) < 0) 101 retval = -1; 102 } 103 sv_errno = errno; 104 if (didalloc) 105 free(ctlbuf.buf); 106 else 107 tiptr->ti_ctlbuf = ctlbuf.buf; 108 sig_mutex_unlock(&tiptr->ti_lock); 109 errno = sv_errno; 110 return (retval); 111 } 112