17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 2261961e0fSrobinson 237c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 247c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate /* 27*e8031f0aSraf * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 287c478bd9Sstevel@tonic-gate * Use is subject to license terms. 297c478bd9Sstevel@tonic-gate */ 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.5.2.1 */ 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #include "mt.h" 347c478bd9Sstevel@tonic-gate #include <stdlib.h> 357c478bd9Sstevel@tonic-gate #include <errno.h> 367c478bd9Sstevel@tonic-gate #include <unistd.h> 377c478bd9Sstevel@tonic-gate #include <stropts.h> 387c478bd9Sstevel@tonic-gate #include <sys/stream.h> 397c478bd9Sstevel@tonic-gate #define _SUN_TPI_VERSION 2 407c478bd9Sstevel@tonic-gate #include <sys/tihdr.h> 417c478bd9Sstevel@tonic-gate #include <sys/timod.h> 427c478bd9Sstevel@tonic-gate #include <xti.h> 437c478bd9Sstevel@tonic-gate #include <signal.h> 447c478bd9Sstevel@tonic-gate #include <syslog.h> 457c478bd9Sstevel@tonic-gate #include <assert.h> 467c478bd9Sstevel@tonic-gate #include "tx.h" 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate int 497c478bd9Sstevel@tonic-gate _tx_accept( 507c478bd9Sstevel@tonic-gate int fd, 517c478bd9Sstevel@tonic-gate int resfd, 527c478bd9Sstevel@tonic-gate const struct t_call *call, 537c478bd9Sstevel@tonic-gate int api_semantics 547c478bd9Sstevel@tonic-gate ) 557c478bd9Sstevel@tonic-gate { 567c478bd9Sstevel@tonic-gate struct T_conn_res *cres; 577c478bd9Sstevel@tonic-gate struct strfdinsert strfdinsert; 587c478bd9Sstevel@tonic-gate int size, retval, sv_errno; 597c478bd9Sstevel@tonic-gate struct _ti_user *tiptr; 607c478bd9Sstevel@tonic-gate struct _ti_user *restiptr; 617c478bd9Sstevel@tonic-gate sigset_t mask; 627c478bd9Sstevel@tonic-gate struct strbuf ctlbuf; 637c478bd9Sstevel@tonic-gate int didalloc; 647c478bd9Sstevel@tonic-gate t_scalar_t conn_res_prim; 657c478bd9Sstevel@tonic-gate 6661961e0fSrobinson if ((tiptr = _t_checkfd(fd, 0, api_semantics)) == NULL) 677c478bd9Sstevel@tonic-gate return (-1); 6861961e0fSrobinson if ((restiptr = _t_checkfd(resfd, 0, api_semantics)) == NULL) 697c478bd9Sstevel@tonic-gate return (-1); 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate /* 727c478bd9Sstevel@tonic-gate * We need to block signals to perform the I_FDINSERT operation 737c478bd9Sstevel@tonic-gate * (sending T_CONN_RES downstream) which is non-idempotent. 747c478bd9Sstevel@tonic-gate * Note that sig_mutex_lock() only defers signals, it does not 757c478bd9Sstevel@tonic-gate * block them, so interruptible syscalls could still get EINTR. 767c478bd9Sstevel@tonic-gate */ 777c478bd9Sstevel@tonic-gate (void) thr_sigsetmask(SIG_SETMASK, &fillset, &mask); 787c478bd9Sstevel@tonic-gate sig_mutex_lock(&tiptr->ti_lock); 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate if (tiptr->ti_servtype == T_CLTS) { 817c478bd9Sstevel@tonic-gate t_errno = TNOTSUPPORT; 827c478bd9Sstevel@tonic-gate sig_mutex_unlock(&tiptr->ti_lock); 837c478bd9Sstevel@tonic-gate (void) thr_sigsetmask(SIG_SETMASK, &mask, NULL); 847c478bd9Sstevel@tonic-gate return (-1); 857c478bd9Sstevel@tonic-gate } 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate if (_T_IS_XTI(api_semantics)) { 887c478bd9Sstevel@tonic-gate /* 897c478bd9Sstevel@tonic-gate * User level state verification only done for XTI 907c478bd9Sstevel@tonic-gate * because doing for TLI may break existing applications 917c478bd9Sstevel@tonic-gate * 927c478bd9Sstevel@tonic-gate * For fd == resfd, state should be T_INCON 937c478bd9Sstevel@tonic-gate * For fd != resfd, 947c478bd9Sstevel@tonic-gate * fd state should be T_INCON 957c478bd9Sstevel@tonic-gate * resfd state should be T_IDLE (bound endpoint) or 967c478bd9Sstevel@tonic-gate * it can be T_UNBND. The T_UNBND case is not (yet?) 977c478bd9Sstevel@tonic-gate * allowed in the published XTI spec but fixed by the 987c478bd9Sstevel@tonic-gate * corrigenda. 997c478bd9Sstevel@tonic-gate */ 1007c478bd9Sstevel@tonic-gate if ((fd == resfd && tiptr->ti_state != T_INCON) || 1017c478bd9Sstevel@tonic-gate (fd != resfd && 1027c478bd9Sstevel@tonic-gate ((tiptr->ti_state != T_INCON) || 1037c478bd9Sstevel@tonic-gate !(restiptr->ti_state == T_IDLE || 1047c478bd9Sstevel@tonic-gate restiptr->ti_state == T_UNBND)))) { 1057c478bd9Sstevel@tonic-gate t_errno = TOUTSTATE; 1067c478bd9Sstevel@tonic-gate sig_mutex_unlock(&tiptr->ti_lock); 1077c478bd9Sstevel@tonic-gate (void) thr_sigsetmask(SIG_SETMASK, &mask, NULL); 1087c478bd9Sstevel@tonic-gate return (-1); 1097c478bd9Sstevel@tonic-gate } 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate /* 1127c478bd9Sstevel@tonic-gate * XTI says: 1137c478bd9Sstevel@tonic-gate * If fd != resfd, and a resfd bound to a protocol address is 1147c478bd9Sstevel@tonic-gate * passed, then it better not have a qlen > 0. 1157c478bd9Sstevel@tonic-gate * That is, an endpoint bound as if it will be a listener 1167c478bd9Sstevel@tonic-gate * cannot be used as an acceptor. 1177c478bd9Sstevel@tonic-gate */ 1187c478bd9Sstevel@tonic-gate if (fd != resfd && restiptr->ti_state == T_IDLE && 1197c478bd9Sstevel@tonic-gate restiptr->ti_qlen > 0) { 1207c478bd9Sstevel@tonic-gate t_errno = TRESQLEN; 1217c478bd9Sstevel@tonic-gate sig_mutex_unlock(&tiptr->ti_lock); 1227c478bd9Sstevel@tonic-gate (void) thr_sigsetmask(SIG_SETMASK, &mask, NULL); 1237c478bd9Sstevel@tonic-gate return (-1); 1247c478bd9Sstevel@tonic-gate } 1257c478bd9Sstevel@tonic-gate 1267c478bd9Sstevel@tonic-gate if (fd == resfd && tiptr->ti_ocnt > 1) { 1277c478bd9Sstevel@tonic-gate t_errno = TINDOUT; 1287c478bd9Sstevel@tonic-gate sig_mutex_unlock(&tiptr->ti_lock); 1297c478bd9Sstevel@tonic-gate (void) thr_sigsetmask(SIG_SETMASK, &mask, NULL); 1307c478bd9Sstevel@tonic-gate return (-1); 1317c478bd9Sstevel@tonic-gate } 1327c478bd9Sstevel@tonic-gate 1337c478bd9Sstevel@tonic-gate /* 1347c478bd9Sstevel@tonic-gate * Note: TRESADDR error is specified by XTI. It happens 1357c478bd9Sstevel@tonic-gate * when resfd is bound and fd and resfd are not BOUND to 1367c478bd9Sstevel@tonic-gate * the same protocol address. TCP obviously does allow 1377c478bd9Sstevel@tonic-gate * two endpoints to bind to the same address. Why is the 1387c478bd9Sstevel@tonic-gate * need for this error considering there is an address switch 1397c478bd9Sstevel@tonic-gate * that can be done for the endpoint at accept time ? Go 1407c478bd9Sstevel@tonic-gate * figure and ask the XTI folks. 1417c478bd9Sstevel@tonic-gate * We interpret this to be a transport specific error condition 1427c478bd9Sstevel@tonic-gate * to be be coveyed by the transport provider in T_ERROR_ACK 1437c478bd9Sstevel@tonic-gate * to T_CONN_RES on transports that allow two endpoints to 1447c478bd9Sstevel@tonic-gate * be bound to the same address and have trouble with the 1457c478bd9Sstevel@tonic-gate * idea of accepting connections on a resfd that has a qlen > 0 1467c478bd9Sstevel@tonic-gate */ 1477c478bd9Sstevel@tonic-gate } 1487c478bd9Sstevel@tonic-gate 1497c478bd9Sstevel@tonic-gate if (fd != resfd) { 150*e8031f0aSraf if ((retval = ioctl(resfd, I_NREAD, &size)) < 0) { 1517c478bd9Sstevel@tonic-gate sv_errno = errno; 1527c478bd9Sstevel@tonic-gate 1537c478bd9Sstevel@tonic-gate t_errno = TSYSERR; 1547c478bd9Sstevel@tonic-gate sig_mutex_unlock(&tiptr->ti_lock); 1557c478bd9Sstevel@tonic-gate (void) thr_sigsetmask(SIG_SETMASK, &mask, NULL); 1567c478bd9Sstevel@tonic-gate errno = sv_errno; 1577c478bd9Sstevel@tonic-gate return (-1); 1587c478bd9Sstevel@tonic-gate } 1597c478bd9Sstevel@tonic-gate if (retval > 0) { 1607c478bd9Sstevel@tonic-gate t_errno = TBADF; 1617c478bd9Sstevel@tonic-gate sig_mutex_unlock(&tiptr->ti_lock); 1627c478bd9Sstevel@tonic-gate (void) thr_sigsetmask(SIG_SETMASK, &mask, NULL); 1637c478bd9Sstevel@tonic-gate return (-1); 1647c478bd9Sstevel@tonic-gate } 1657c478bd9Sstevel@tonic-gate } 1667c478bd9Sstevel@tonic-gate 1677c478bd9Sstevel@tonic-gate /* 1687c478bd9Sstevel@tonic-gate * Acquire ctlbuf for use in sending/receiving control part 1697c478bd9Sstevel@tonic-gate * of the message. 1707c478bd9Sstevel@tonic-gate */ 1717c478bd9Sstevel@tonic-gate if (_t_acquire_ctlbuf(tiptr, &ctlbuf, &didalloc) < 0) { 1727c478bd9Sstevel@tonic-gate sv_errno = errno; 1737c478bd9Sstevel@tonic-gate sig_mutex_unlock(&tiptr->ti_lock); 1747c478bd9Sstevel@tonic-gate (void) thr_sigsetmask(SIG_SETMASK, &mask, NULL); 1757c478bd9Sstevel@tonic-gate errno = sv_errno; 1767c478bd9Sstevel@tonic-gate return (-1); 1777c478bd9Sstevel@tonic-gate } 1787c478bd9Sstevel@tonic-gate 1797c478bd9Sstevel@tonic-gate /* 1807c478bd9Sstevel@tonic-gate * In Unix98 t_accept() need not return [TLOOK] if connect/disconnect 1817c478bd9Sstevel@tonic-gate * indications are present. TLI and Unix95 need to return error. 1827c478bd9Sstevel@tonic-gate */ 1837c478bd9Sstevel@tonic-gate if (_T_API_VER_LT(api_semantics, TX_XTI_XNS5_API)) { 1847c478bd9Sstevel@tonic-gate if (_t_is_event(fd, tiptr) < 0) 1857c478bd9Sstevel@tonic-gate goto err_out; 1867c478bd9Sstevel@tonic-gate } 1877c478bd9Sstevel@tonic-gate 18861961e0fSrobinson /* LINTED pointer cast */ 1897c478bd9Sstevel@tonic-gate cres = (struct T_conn_res *)ctlbuf.buf; 1907c478bd9Sstevel@tonic-gate cres->OPT_length = call->opt.len; 1917c478bd9Sstevel@tonic-gate cres->OPT_offset = 0; 1927c478bd9Sstevel@tonic-gate cres->SEQ_number = call->sequence; 1937c478bd9Sstevel@tonic-gate if ((restiptr->ti_flags & V_ACCEPTOR_ID) != 0) { 1947c478bd9Sstevel@tonic-gate cres->ACCEPTOR_id = restiptr->acceptor_id; 1957c478bd9Sstevel@tonic-gate cres->PRIM_type = conn_res_prim = T_CONN_RES; 1967c478bd9Sstevel@tonic-gate } else { 1977c478bd9Sstevel@tonic-gate /* I_FDINSERT should use O_T_CONN_RES. */ 1987c478bd9Sstevel@tonic-gate cres->ACCEPTOR_id = 0; 1997c478bd9Sstevel@tonic-gate cres->PRIM_type = conn_res_prim = O_T_CONN_RES; 2007c478bd9Sstevel@tonic-gate } 2017c478bd9Sstevel@tonic-gate 2027c478bd9Sstevel@tonic-gate size = (int)sizeof (struct T_conn_res); 2037c478bd9Sstevel@tonic-gate 2047c478bd9Sstevel@tonic-gate if (call->opt.len) { 2057c478bd9Sstevel@tonic-gate if (_t_aligned_copy(&ctlbuf, call->opt.len, size, 2067c478bd9Sstevel@tonic-gate call->opt.buf, &cres->OPT_offset) < 0) { 2077c478bd9Sstevel@tonic-gate /* 2087c478bd9Sstevel@tonic-gate * Aligned copy will overflow buffer allocated based 2097c478bd9Sstevel@tonic-gate * transport maximum options length. 2107c478bd9Sstevel@tonic-gate * return error. 2117c478bd9Sstevel@tonic-gate */ 2127c478bd9Sstevel@tonic-gate t_errno = TBADOPT; 2137c478bd9Sstevel@tonic-gate goto err_out; 2147c478bd9Sstevel@tonic-gate } 2157c478bd9Sstevel@tonic-gate size = cres->OPT_offset + cres->OPT_length; 2167c478bd9Sstevel@tonic-gate } 2177c478bd9Sstevel@tonic-gate 2187c478bd9Sstevel@tonic-gate if (call->udata.len) { 2197c478bd9Sstevel@tonic-gate if ((tiptr->ti_cdatasize == T_INVALID /* -2 */) || 2207c478bd9Sstevel@tonic-gate ((tiptr->ti_cdatasize != T_INFINITE /* -1 */) && 2217c478bd9Sstevel@tonic-gate (call->udata.len > (uint32_t)tiptr->ti_cdatasize))) { 2227c478bd9Sstevel@tonic-gate /* 2237c478bd9Sstevel@tonic-gate * user data not valid with connect or it 2247c478bd9Sstevel@tonic-gate * exceeds the limits specified by the transport 2257c478bd9Sstevel@tonic-gate * provider 2267c478bd9Sstevel@tonic-gate */ 2277c478bd9Sstevel@tonic-gate t_errno = TBADDATA; 2287c478bd9Sstevel@tonic-gate goto err_out; 2297c478bd9Sstevel@tonic-gate } 2307c478bd9Sstevel@tonic-gate } 2317c478bd9Sstevel@tonic-gate 2327c478bd9Sstevel@tonic-gate 2337c478bd9Sstevel@tonic-gate ctlbuf.len = size; 2347c478bd9Sstevel@tonic-gate 2357c478bd9Sstevel@tonic-gate /* 2367c478bd9Sstevel@tonic-gate * Assumes signals are blocked so putmsg() will not block 2377c478bd9Sstevel@tonic-gate * indefinitely 2387c478bd9Sstevel@tonic-gate */ 2397c478bd9Sstevel@tonic-gate if ((restiptr->ti_flags & V_ACCEPTOR_ID) != 0) { 2407c478bd9Sstevel@tonic-gate /* 2417c478bd9Sstevel@tonic-gate * Assumes signals are blocked so putmsg() will not block 2427c478bd9Sstevel@tonic-gate * indefinitely 2437c478bd9Sstevel@tonic-gate */ 2447c478bd9Sstevel@tonic-gate if (putmsg(fd, &ctlbuf, 2457c478bd9Sstevel@tonic-gate (struct strbuf *)(call->udata.len? &call->udata: NULL), 0) < 2467c478bd9Sstevel@tonic-gate 0) { 2477c478bd9Sstevel@tonic-gate if (errno == EAGAIN) 2487c478bd9Sstevel@tonic-gate t_errno = TFLOW; 2497c478bd9Sstevel@tonic-gate else 2507c478bd9Sstevel@tonic-gate t_errno = TSYSERR; 2517c478bd9Sstevel@tonic-gate goto err_out; 2527c478bd9Sstevel@tonic-gate } 2537c478bd9Sstevel@tonic-gate } else { 2547c478bd9Sstevel@tonic-gate strfdinsert.ctlbuf.maxlen = ctlbuf.maxlen; 2557c478bd9Sstevel@tonic-gate strfdinsert.ctlbuf.len = ctlbuf.len; 2567c478bd9Sstevel@tonic-gate strfdinsert.ctlbuf.buf = ctlbuf.buf; 2577c478bd9Sstevel@tonic-gate 2587c478bd9Sstevel@tonic-gate strfdinsert.databuf.maxlen = call->udata.maxlen; 2597c478bd9Sstevel@tonic-gate strfdinsert.databuf.len = 2607c478bd9Sstevel@tonic-gate (call->udata.len? call->udata.len: -1); 2617c478bd9Sstevel@tonic-gate strfdinsert.databuf.buf = call->udata.buf; 2627c478bd9Sstevel@tonic-gate strfdinsert.fildes = resfd; 2637c478bd9Sstevel@tonic-gate strfdinsert.offset = (int)sizeof (t_scalar_t); 2647c478bd9Sstevel@tonic-gate strfdinsert.flags = 0; /* could be EXPEDITED also */ 2657c478bd9Sstevel@tonic-gate 266*e8031f0aSraf if (ioctl(fd, I_FDINSERT, &strfdinsert) < 0) { 2677c478bd9Sstevel@tonic-gate if (errno == EAGAIN) 2687c478bd9Sstevel@tonic-gate t_errno = TFLOW; 2697c478bd9Sstevel@tonic-gate else 2707c478bd9Sstevel@tonic-gate t_errno = TSYSERR; 2717c478bd9Sstevel@tonic-gate goto err_out; 2727c478bd9Sstevel@tonic-gate } 2737c478bd9Sstevel@tonic-gate } 2747c478bd9Sstevel@tonic-gate 2757c478bd9Sstevel@tonic-gate if (_t_is_ok(fd, tiptr, conn_res_prim) < 0) { 2767c478bd9Sstevel@tonic-gate /* 2777c478bd9Sstevel@tonic-gate * At the TPI level, the error returned in a T_ERROR_ACK 2787c478bd9Sstevel@tonic-gate * received in response to a T_CONN_RES for a listener and 2797c478bd9Sstevel@tonic-gate * acceptor endpoints not being the same kind of endpoints 2807c478bd9Sstevel@tonic-gate * has changed to a new t_errno code introduced with 2817c478bd9Sstevel@tonic-gate * XTI (TPROVMISMATCH). We need to adjust TLI error code 2827c478bd9Sstevel@tonic-gate * to be same as before. 2837c478bd9Sstevel@tonic-gate */ 2847c478bd9Sstevel@tonic-gate if (_T_IS_TLI(api_semantics) && t_errno == TPROVMISMATCH) { 2857c478bd9Sstevel@tonic-gate /* TLI only */ 2867c478bd9Sstevel@tonic-gate t_errno = TBADF; 2877c478bd9Sstevel@tonic-gate } 2887c478bd9Sstevel@tonic-gate goto err_out; 2897c478bd9Sstevel@tonic-gate } 2907c478bd9Sstevel@tonic-gate 2917c478bd9Sstevel@tonic-gate if (tiptr->ti_ocnt == 1) { 2927c478bd9Sstevel@tonic-gate if (fd == resfd) { 2937c478bd9Sstevel@tonic-gate _T_TX_NEXTSTATE(T_ACCEPT1, tiptr, 2947c478bd9Sstevel@tonic-gate "t_accept: invalid state event T_ACCEPT1"); 2957c478bd9Sstevel@tonic-gate } else { 2967c478bd9Sstevel@tonic-gate _T_TX_NEXTSTATE(T_ACCEPT2, tiptr, 2977c478bd9Sstevel@tonic-gate "t_accept: invalid state event T_ACCEPT2"); 2987c478bd9Sstevel@tonic-gate /* 2997c478bd9Sstevel@tonic-gate * XXX Here we lock the resfd lock also. This 3007c478bd9Sstevel@tonic-gate * is an instance of holding two locks without 3017c478bd9Sstevel@tonic-gate * any enforcement of a locking hiararchy. 3027c478bd9Sstevel@tonic-gate * There is potential for deadlock in incorrect 3037c478bd9Sstevel@tonic-gate * or buggy programs here but this is the safer 3047c478bd9Sstevel@tonic-gate * choice in this case. Correct programs will not 3057c478bd9Sstevel@tonic-gate * deadlock. 3067c478bd9Sstevel@tonic-gate */ 3077c478bd9Sstevel@tonic-gate sig_mutex_lock(&restiptr->ti_lock); 3087c478bd9Sstevel@tonic-gate _T_TX_NEXTSTATE(T_PASSCON, restiptr, 3097c478bd9Sstevel@tonic-gate "t_accept: invalid state event T_PASSCON"); 3107c478bd9Sstevel@tonic-gate sig_mutex_unlock(&restiptr->ti_lock); 3117c478bd9Sstevel@tonic-gate } 3127c478bd9Sstevel@tonic-gate } else { 3137c478bd9Sstevel@tonic-gate _T_TX_NEXTSTATE(T_ACCEPT3, tiptr, 3147c478bd9Sstevel@tonic-gate "t_accept: invalid state event T_ACCEPT3"); 3157c478bd9Sstevel@tonic-gate if (fd != resfd) 3167c478bd9Sstevel@tonic-gate sig_mutex_lock(&restiptr->ti_lock); 3177c478bd9Sstevel@tonic-gate _T_TX_NEXTSTATE(T_PASSCON, restiptr, 3187c478bd9Sstevel@tonic-gate "t_accept: invalid state event T_PASSCON"); 3197c478bd9Sstevel@tonic-gate if (fd != resfd) 3207c478bd9Sstevel@tonic-gate sig_mutex_unlock(&restiptr->ti_lock); 3217c478bd9Sstevel@tonic-gate } 3227c478bd9Sstevel@tonic-gate 3237c478bd9Sstevel@tonic-gate tiptr->ti_ocnt--; 3247c478bd9Sstevel@tonic-gate tiptr->ti_flags &= ~TX_TQFULL_NOTIFIED; 3257c478bd9Sstevel@tonic-gate 3267c478bd9Sstevel@tonic-gate /* 3277c478bd9Sstevel@tonic-gate * Update attributes which may have been negotiated during 3287c478bd9Sstevel@tonic-gate * connection establishment for protocols where we suspect 3297c478bd9Sstevel@tonic-gate * such negotiation is likely (e.g. OSI). We do not do it for 3307c478bd9Sstevel@tonic-gate * all endpoints for performance reasons. Also, this code is 3317c478bd9Sstevel@tonic-gate * deliberately done after user level state changes so even 3327c478bd9Sstevel@tonic-gate * the (unlikely) failure case reflects a connected endpoint. 3337c478bd9Sstevel@tonic-gate */ 3347c478bd9Sstevel@tonic-gate if (restiptr->ti_tsdusize != 0) { 3357c478bd9Sstevel@tonic-gate if (_t_do_postconn_sync(resfd, restiptr) < 0) 3367c478bd9Sstevel@tonic-gate goto err_out; 3377c478bd9Sstevel@tonic-gate } 3387c478bd9Sstevel@tonic-gate 3397c478bd9Sstevel@tonic-gate if (didalloc) 3407c478bd9Sstevel@tonic-gate free(ctlbuf.buf); 3417c478bd9Sstevel@tonic-gate else 3427c478bd9Sstevel@tonic-gate tiptr->ti_ctlbuf = ctlbuf.buf; 3437c478bd9Sstevel@tonic-gate sig_mutex_unlock(&tiptr->ti_lock); 3447c478bd9Sstevel@tonic-gate (void) thr_sigsetmask(SIG_SETMASK, &mask, NULL); 3457c478bd9Sstevel@tonic-gate return (0); 3467c478bd9Sstevel@tonic-gate /* NOTREACHED */ 3477c478bd9Sstevel@tonic-gate err_out: 3487c478bd9Sstevel@tonic-gate sv_errno = errno; 3497c478bd9Sstevel@tonic-gate if (didalloc) 3507c478bd9Sstevel@tonic-gate free(ctlbuf.buf); 3517c478bd9Sstevel@tonic-gate else 3527c478bd9Sstevel@tonic-gate tiptr->ti_ctlbuf = ctlbuf.buf; 3537c478bd9Sstevel@tonic-gate sig_mutex_unlock(&tiptr->ti_lock); 3547c478bd9Sstevel@tonic-gate (void) thr_sigsetmask(SIG_SETMASK, &mask, NULL); 3557c478bd9Sstevel@tonic-gate errno = sv_errno; 3567c478bd9Sstevel@tonic-gate return (-1); 3577c478bd9Sstevel@tonic-gate } 358