t_listen.c (7c478bd9) t_listen.c (61961e0f)
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 *

--- 5 unchanged lines hidden (view full) ---

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 */
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 *

--- 5 unchanged lines hidden (view full) ---

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
22/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
23/* All Rights Reserved */
24
23/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
24/* All Rights Reserved */
25
25
26/*
26/*
27 * Copyright 1993-2003 Sun Microsystems, Inc. All rights reserved.
27 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
28 * Use is subject to license terms.
29 */
30
28 * Use is subject to license terms.
29 */
30
31
32#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.5 */
33
34#include "mt.h"
31#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.5 */
32
33#include "mt.h"
35#include <rpc/trace.h>
36#include <errno.h>
37#include <stdlib.h>
38#include <string.h>
39#include <stropts.h>
40#include <sys/stream.h>
41#define _SUN_TPI_VERSION 2
42#include <sys/tihdr.h>
43#include <sys/timod.h>

--- 8 unchanged lines hidden (view full) ---

52 struct strbuf databuf;
53 int retval;
54 union T_primitives *pptr;
55 struct _ti_user *tiptr;
56 int sv_errno;
57 int didalloc, didralloc;
58 int flg = 0;
59
34#include <errno.h>
35#include <stdlib.h>
36#include <string.h>
37#include <stropts.h>
38#include <sys/stream.h>
39#define _SUN_TPI_VERSION 2
40#include <sys/tihdr.h>
41#include <sys/timod.h>

--- 8 unchanged lines hidden (view full) ---

50 struct strbuf databuf;
51 int retval;
52 union T_primitives *pptr;
53 struct _ti_user *tiptr;
54 int sv_errno;
55 int didalloc, didralloc;
56 int flg = 0;
57
60 trace2(TR_t_listen, 0, fd);
61 if ((tiptr = _t_checkfd(fd, 0, api_semantics)) == NULL) {
62 sv_errno = errno;
63 trace2(TR_t_listen, 1, fd);
64 errno = sv_errno;
58 if ((tiptr = _t_checkfd(fd, 0, api_semantics)) == NULL)
65 return (-1);
59 return (-1);
66 }
67
60
68
69 sig_mutex_lock(&tiptr->ti_lock);
70
71 if (tiptr->ti_servtype == T_CLTS) {
72 sv_errno = errno;
73 t_errno = TNOTSUPPORT;
74 sig_mutex_unlock(&tiptr->ti_lock);
61 sig_mutex_lock(&tiptr->ti_lock);
62
63 if (tiptr->ti_servtype == T_CLTS) {
64 sv_errno = errno;
65 t_errno = TNOTSUPPORT;
66 sig_mutex_unlock(&tiptr->ti_lock);
75 trace2(TR_t_listen, 1, fd);
76 errno = sv_errno;
77 return (-1);
78 }
79 if (_T_IS_XTI(api_semantics)) {
80 /*
81 * User level state verification only done for XTI
82 * because doing for TLI may break existing applications
83 */
67 errno = sv_errno;
68 return (-1);
69 }
70 if (_T_IS_XTI(api_semantics)) {
71 /*
72 * User level state verification only done for XTI
73 * because doing for TLI may break existing applications
74 */
84 if (! (tiptr->ti_state == T_IDLE ||
75 if (!(tiptr->ti_state == T_IDLE ||
85 tiptr->ti_state == T_INCON)) {
86 t_errno = TOUTSTATE;
87 sig_mutex_unlock(&tiptr->ti_lock);
76 tiptr->ti_state == T_INCON)) {
77 t_errno = TOUTSTATE;
78 sig_mutex_unlock(&tiptr->ti_lock);
88 trace2(TR_t_connect, 1, fd);
89 return (-1);
90 }
91
92 if (tiptr->ti_qlen == 0) {
93 t_errno = TBADQLEN;
94 sig_mutex_unlock(&tiptr->ti_lock);
79 return (-1);
80 }
81
82 if (tiptr->ti_qlen == 0) {
83 t_errno = TBADQLEN;
84 sig_mutex_unlock(&tiptr->ti_lock);
95 trace2(TR_t_connect, 1, fd);
96 return (-1);
97 }
98
99 if (tiptr->ti_ocnt == tiptr->ti_qlen) {
100 if (!(tiptr->ti_flags & TX_TQFULL_NOTIFIED)) {
101 tiptr->ti_flags |= TX_TQFULL_NOTIFIED;
102 t_errno = TQFULL;
103 sig_mutex_unlock(&tiptr->ti_lock);
85 return (-1);
86 }
87
88 if (tiptr->ti_ocnt == tiptr->ti_qlen) {
89 if (!(tiptr->ti_flags & TX_TQFULL_NOTIFIED)) {
90 tiptr->ti_flags |= TX_TQFULL_NOTIFIED;
91 t_errno = TQFULL;
92 sig_mutex_unlock(&tiptr->ti_lock);
104 trace2(TR_t_connect, 1, fd);
105 return (-1);
106 }
107 }
108
109 }
110
111 /*
112 * check if something in look buffer
113 */
114 if (tiptr->ti_lookcnt > 0) {
115 t_errno = TLOOK;
116 sig_mutex_unlock(&tiptr->ti_lock);
93 return (-1);
94 }
95 }
96
97 }
98
99 /*
100 * check if something in look buffer
101 */
102 if (tiptr->ti_lookcnt > 0) {
103 t_errno = TLOOK;
104 sig_mutex_unlock(&tiptr->ti_lock);
117 trace2(TR_t_listen, 1, fd);
118 return (-1);
119 }
120
121 /*
122 * Acquire ctlbuf for use in sending/receiving control part
123 * of the message.
124 */
125 if (_t_acquire_ctlbuf(tiptr, &ctlbuf, &didalloc) < 0) {
126 sv_errno = errno;
127 sig_mutex_unlock(&tiptr->ti_lock);
105 return (-1);
106 }
107
108 /*
109 * Acquire ctlbuf for use in sending/receiving control part
110 * of the message.
111 */
112 if (_t_acquire_ctlbuf(tiptr, &ctlbuf, &didalloc) < 0) {
113 sv_errno = errno;
114 sig_mutex_unlock(&tiptr->ti_lock);
128 trace2(TR_t_listen, 1, fd);
129 errno = sv_errno;
130 return (-1);
131 }
132 /*
133 * Acquire databuf for use in sending/receiving data part
134 */
135 if (_t_acquire_databuf(tiptr, &databuf, &didralloc) < 0) {
136 int sv_errno = errno;
137
138 if (didalloc)
139 free(ctlbuf.buf);
140 else
141 tiptr->ti_ctlbuf = ctlbuf.buf;
142 sig_mutex_unlock(&tiptr->ti_lock);
115 errno = sv_errno;
116 return (-1);
117 }
118 /*
119 * Acquire databuf for use in sending/receiving data part
120 */
121 if (_t_acquire_databuf(tiptr, &databuf, &didralloc) < 0) {
122 int sv_errno = errno;
123
124 if (didalloc)
125 free(ctlbuf.buf);
126 else
127 tiptr->ti_ctlbuf = ctlbuf.buf;
128 sig_mutex_unlock(&tiptr->ti_lock);
143 trace2(TR_t_listen, 1, fd);
144 errno = sv_errno;
145 return (-1);
146 }
147
148 /*
149 * This is a call that may block indefinitely so we drop the
150 * lock and allow signals in MT case here and reacquire it.
151 * Error case should roll back state changes done above

--- 27 unchanged lines hidden (view full) ---

179 * is ctl part large enough to determine type
180 */
181 if (ctlbuf.len < (int)sizeof (t_scalar_t)) {
182 t_errno = TSYSERR;
183 errno = EPROTO;
184 goto err_out;
185 }
186
129 errno = sv_errno;
130 return (-1);
131 }
132
133 /*
134 * This is a call that may block indefinitely so we drop the
135 * lock and allow signals in MT case here and reacquire it.
136 * Error case should roll back state changes done above

--- 27 unchanged lines hidden (view full) ---

164 * is ctl part large enough to determine type
165 */
166 if (ctlbuf.len < (int)sizeof (t_scalar_t)) {
167 t_errno = TSYSERR;
168 errno = EPROTO;
169 goto err_out;
170 }
171
172 /* LINTED pointer cast */
187 pptr = (union T_primitives *)ctlbuf.buf;
188
189 switch (pptr->type) {
190
191 case T_CONN_IND:
192 if ((ctlbuf.len < (int)sizeof (struct T_conn_ind)) ||
193 (ctlbuf.len < (int)(pptr->conn_ind.OPT_length
194 + pptr->conn_ind.OPT_offset))) {

--- 52 unchanged lines hidden (view full) ---

247 free(ctlbuf.buf);
248 else
249 tiptr->ti_ctlbuf = ctlbuf.buf;
250 if (didralloc)
251 free(databuf.buf);
252 else
253 tiptr->ti_rcvbuf = databuf.buf;
254 sig_mutex_unlock(&tiptr->ti_lock);
173 pptr = (union T_primitives *)ctlbuf.buf;
174
175 switch (pptr->type) {
176
177 case T_CONN_IND:
178 if ((ctlbuf.len < (int)sizeof (struct T_conn_ind)) ||
179 (ctlbuf.len < (int)(pptr->conn_ind.OPT_length
180 + pptr->conn_ind.OPT_offset))) {

--- 52 unchanged lines hidden (view full) ---

233 free(ctlbuf.buf);
234 else
235 tiptr->ti_ctlbuf = ctlbuf.buf;
236 if (didralloc)
237 free(databuf.buf);
238 else
239 tiptr->ti_rcvbuf = databuf.buf;
240 sig_mutex_unlock(&tiptr->ti_lock);
255 trace2(TR_t_listen, 1, fd);
256 return (0);
257
258 case T_DISCON_IND:
259 /*
260 * Append to the events in the "look buffer"
261 * list of events. This routine may defer signals.
262 */
263 if (_t_register_lookevent(tiptr, databuf.buf,

--- 19 unchanged lines hidden (view full) ---

283 free(ctlbuf.buf);
284 else
285 tiptr->ti_ctlbuf = ctlbuf.buf;
286 if (didralloc)
287 free(databuf.buf);
288 else
289 tiptr->ti_rcvbuf = databuf.buf;
290 sig_mutex_unlock(&tiptr->ti_lock);
241 return (0);
242
243 case T_DISCON_IND:
244 /*
245 * Append to the events in the "look buffer"
246 * list of events. This routine may defer signals.
247 */
248 if (_t_register_lookevent(tiptr, databuf.buf,

--- 19 unchanged lines hidden (view full) ---

268 free(ctlbuf.buf);
269 else
270 tiptr->ti_ctlbuf = ctlbuf.buf;
271 if (didralloc)
272 free(databuf.buf);
273 else
274 tiptr->ti_rcvbuf = databuf.buf;
275 sig_mutex_unlock(&tiptr->ti_lock);
291 trace2(TR_t_listen, 1, fd);
292 errno = sv_errno;
293 return (-1);
294}
276 errno = sv_errno;
277 return (-1);
278}