/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Any changes to either of them should be reviewed to see whether they
* are applicable to the other file.
*/
#include "mt.h"
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <stropts.h>
#include <xti.h>
#include <syslog.h>
#include <assert.h>
#include "tx.h"
int
int api_semantics)
{
int msglen;
int sv_errno;
int didalloc;
unsigned int nbytes;
char *dataptr;
return (-1);
return (-1);
}
return (-1);
}
return (-1);
}
/*
* Check in lookbuf for stuff
*/
if (tiptr->ti_lookcnt > 0) {
/*
* Implied preference rules give priority to
* T_DISCON_IND over T_ORDREL_IND. Also certain errors like
* data received after T_ORDREL_IND or a duplicate T_ORDREL_IND
* after a T_ORDRELING have priority over TLOOK.
* This manifests in following code behavior.
*
* (1) If something in lookbuf then check
* the stream head also. This may result
* in retuning a TLOOK error but only if there are
* - message at stream head but look buffer
* has a T_DISCON_IND event.
* - no messages are on the stream head
*
* (2) If there are messages on the stream head and
* all of them are T_ORDREL_IND(i.e. no message in
* look buffer is T_DISCON_IND), there
* could be data on stream head to be picked up and
* we work on the stream head and not return TLOOK.
* We remove the event on the stream head and queue it.
*
*/
do {
if (retval < 0) {
return (-1);
}
if (retval > 0) {
/*
* If any T_DISCON_IND event in look buffer
* list then return TLOOK. Else continue
* processing as what could be on the stream
* head might be a possible T_DISCON_IND (which
* would have priority over the T_ORDREL_INDs
* on the look buffer.)
*/
do {
/* LINTED pointer cast */
== T_DISCON_IND) {
return (-1);
}
} else { /* retval == 0 */
/*
* Nothing on stream head so whatever in
* look buffer has nothing that might override
* it.
*/
return (-1);
}
}
/*
* of the message.
*/
return (-1);
}
if (didalloc)
else
return (-1);
}
*flags = 0;
/*
* This is a call that may block indefinitely so we drop the
* lock and allow signals in MT case here and reacquire it.
* Error case should roll back state changes done above
* (happens to be no state change here)
*/
else
goto err_out;
}
goto err_out;
}
/* LINTED pointer cast */
case T_EXDATA_IND:
*flags |= T_EXPEDITED;
if (retval > 0)
/* FALLTHROUGH */
case T_DATA_IND:
/*
* Uses the fact T_DATA_IND and T_EXDATA_IND
* are same in size
*/
(tiptr->ti_lookcnt > 0)) {
/*
* ti_lookcnt > 0 implies data
* received after T_DISCON_IND or
* T_ORDREL_IND hence error
*/
goto err_out;
}
/*
* No real state change on T_RCV event (noop)
*
* We invoke the macro only for error logging
* part of its capabilities when in a bad state.
*/
"t_rcvv: invalid state event T_RCV");
if (didalloc)
else
case T_ORDREL_IND:
if (tiptr->ti_lookcnt > 0) {
/*
* ti_lookcnt > 0 implies T_ORDREL_IND
* received after T_DISCON_IND or
* another T_ORDREL_IND hence error.
*/
goto err_out;
}
/* FALLTHROUGH */
case T_DISCON_IND:
/*
* Post event (T_ORDREL_IND/T_DISCON_IND) to
* the lookbuffer list.
*/
goto err_out;
}
/*
* We know that T_DISCON_IND is stored in
* last look buffer. If there is more data
* that follows, we try to append it to
* the same look buffer
*/
/*
* XXX Will break (-ve maxlen) for
* transport provider with unbounded
* T_DISCON_IND data part (-1).
*/
*flags = 0;
/*
* Since MOREDATA was set, we assume
* that this getmsg will not block
* indefinitely
*/
do {
if (retval < 0) {
goto err_out;
}
if (retval > 0) {
/* MORECTL should not be on */
/*
* XXX - Why ?
* No support for unbounded data
* on T_DISCON_IND ?
*/
goto err_out;
}
}
goto err_out;
default:
break;
}
goto err_out;
} else { /* else for "if (ctlbuf.len > 0)" */
}
/*
* If inside an ETSDU, set expedited flag and turn
* of internal version when reach end of "ETIDU".
*/
*flags |= T_EXPEDITED;
if (!retval)
}
/*
* No real state change on T_RCV events (It is a NOOP)
*
* We invoke the macro only for error logging
* part of its capabilities when in a bad state.
*/
"t_rcvv: state invalid T_RCV event");
if (didalloc)
else
}
/* NOTREACHED */
if (didalloc)
else
return (-1);
}