Print this page
3910 t_look(3NSL) should never return T_ERROR


   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 2006 Sun Microsystems, Inc.  All rights reserved.
  28  * Use is subject to license terms.

  29  */
  30 
  31 #pragma ident   "%Z%%M% %I%     %E% SMI"
  32 
  33 #include "mt.h"
  34 #include <errno.h>
  35 #include <unistd.h>
  36 #include <sys/stream.h>
  37 #include <stropts.h>
  38 #define _SUN_TPI_VERSION 2
  39 #include <sys/tihdr.h>
  40 #include <sys/timod.h>
  41 #include <xti.h>
  42 #include <assert.h>
  43 #include "tx.h"
  44 
  45 int
  46 _tx_look(int fd, int api_semantics)
  47 {
  48         int state;
  49         int sv_errno;
  50         int do_expinline_peek;   /* unusual XTI specific processing */
  51         struct _ti_user *tiptr;
  52 


 116                  * We will also need to sort out if "write side" events
 117                  * (such as T_GODATA/T_GOEXDATA) take precedence over
 118                  * all other events (all read side) or not.
 119                  */
 120         }
 121 #endif /* notyet */
 122 
 123         strpeek.ctlbuf.maxlen = (int)sizeof (ctltype);
 124         strpeek.ctlbuf.len = 0;
 125         strpeek.ctlbuf.buf = (char *)&ctltype;
 126         strpeek.databuf.maxlen = 0;
 127         strpeek.databuf.len = 0;
 128         strpeek.databuf.buf = NULL;
 129         strpeek.flags = 0;
 130 
 131         do {
 132                 retval = ioctl(fd, I_PEEK, &strpeek);
 133         } while (retval < 0 && errno == EINTR);
 134 
 135         if (retval < 0) {
 136                 if (_T_IS_TLI(api_semantics)) {
 137                         /*
 138                          * This return of T_ERROR event is ancient
 139                          * SVR3 TLI semantics and not documented for
 140                          * current SVR4 TLI interface.
 141                          * Fixing this will impact some apps
 142                          * (e.g. nfsd,lockd) in ON consolidation
 143                          * so they need to be fixed first before TLI
 144                          * can be fixed.
 145                          * XXX Should we never fix this because it might
 146                          * break apps in field ?
 147                          */
 148                         return (T_ERROR);
 149                 }
 150                 /*
 151                  * XTI semantics (also identical to documented,
 152                  * but not implemented TLI semantics).
 153                  */
 154                 t_errno = TSYSERR;
 155                 return (-1);
 156         }
 157 
 158         /*
 159          * if something there and cntl part also there
 160          */
 161         if ((tiptr->ti_lookcnt > 0) ||
 162         ((retval > 0) && (strpeek.ctlbuf.len >= (int)sizeof (t_scalar_t)))) {

 163                 /* LINTED pointer cast */
 164                 pptr = (union T_primitives *)strpeek.ctlbuf.buf;
 165                 if (tiptr->ti_lookcnt > 0) {
 166                         /* LINTED pointer cast */
 167                         type = *((t_scalar_t *)tiptr->ti_lookbufs.tl_lookcbuf);
 168                         /*
 169                          * If message on stream head is a T_DISCON_IND, that
 170                          * has priority over a T_ORDREL_IND in the look
 171                          * buffer.
 172                          * (This assumes that T_ORDREL_IND can only be in the
 173                          * first look buffer in the list)
 174                          */
 175                         if ((type == T_ORDREL_IND) && retval &&
 176                             (pptr->type == T_DISCON_IND)) {
 177                                 type = pptr->type;
 178                                 /*
 179                                  * Blow away T_ORDREL_IND
 180                                  */
 181                                 _t_free_looklist_head(tiptr);
 182                         }




   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 2006 Sun Microsystems, Inc.  All rights reserved.
  28  * Use is subject to license terms.
  29  * Copyright 2014 Gary Mills
  30  */
  31 


  32 #include "mt.h"
  33 #include <errno.h>
  34 #include <unistd.h>
  35 #include <sys/stream.h>
  36 #include <stropts.h>
  37 #define _SUN_TPI_VERSION 2
  38 #include <sys/tihdr.h>
  39 #include <sys/timod.h>
  40 #include <xti.h>
  41 #include <assert.h>
  42 #include "tx.h"
  43 
  44 int
  45 _tx_look(int fd, int api_semantics)
  46 {
  47         int state;
  48         int sv_errno;
  49         int do_expinline_peek;   /* unusual XTI specific processing */
  50         struct _ti_user *tiptr;
  51 


 115                  * We will also need to sort out if "write side" events
 116                  * (such as T_GODATA/T_GOEXDATA) take precedence over
 117                  * all other events (all read side) or not.
 118                  */
 119         }
 120 #endif /* notyet */
 121 
 122         strpeek.ctlbuf.maxlen = (int)sizeof (ctltype);
 123         strpeek.ctlbuf.len = 0;
 124         strpeek.ctlbuf.buf = (char *)&ctltype;
 125         strpeek.databuf.maxlen = 0;
 126         strpeek.databuf.len = 0;
 127         strpeek.databuf.buf = NULL;
 128         strpeek.flags = 0;
 129 
 130         do {
 131                 retval = ioctl(fd, I_PEEK, &strpeek);
 132         } while (retval < 0 && errno == EINTR);
 133 
 134         if (retval < 0) {

 135                 /*
 136                  * XTI semantics (also identical to documented
 137                  * TLI semantics).







 138                  */






 139                 t_errno = TSYSERR;
 140                 return (-1);
 141         }
 142 
 143         /*
 144          * if something there and cntl part also there
 145          */
 146         if ((tiptr->ti_lookcnt > 0) ||
 147             ((retval > 0) && (strpeek.ctlbuf.len >=
 148             (int)sizeof (t_scalar_t)))) {
 149                 /* LINTED pointer cast */
 150                 pptr = (union T_primitives *)strpeek.ctlbuf.buf;
 151                 if (tiptr->ti_lookcnt > 0) {
 152                         /* LINTED pointer cast */
 153                         type = *((t_scalar_t *)tiptr->ti_lookbufs.tl_lookcbuf);
 154                         /*
 155                          * If message on stream head is a T_DISCON_IND, that
 156                          * has priority over a T_ORDREL_IND in the look
 157                          * buffer.
 158                          * (This assumes that T_ORDREL_IND can only be in the
 159                          * first look buffer in the list)
 160                          */
 161                         if ((type == T_ORDREL_IND) && retval &&
 162                             (pptr->type == T_DISCON_IND)) {
 163                                 type = pptr->type;
 164                                 /*
 165                                  * Blow away T_ORDREL_IND
 166                                  */
 167                                 _t_free_looklist_head(tiptr);
 168                         }