DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T d

⟦7e5fed986⟧ TextFile

    Length: 8660 (0x21d4)
    Types: TextFile
    Names: »ds_abandon.c«

Derivation

└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0
    └─⟦35176feda⟧ »EurOpenD22/isode/isode-6.tar.Z« 
        └─⟦de7628f85⟧ 
            └─⟦this⟧ »isode-6.0/dsap/net/ds_abandon.c« 

TextFile

/* ds_abandon.c - */

#ifndef	lint
static char *rcsid = "$Header: /f/osi/dsap/net/RCS/ds_abandon.c,v 7.0 89/11/23 21:48:09 mrose Rel $";
#endif

/* 
 * $Header: /f/osi/dsap/net/RCS/ds_abandon.c,v 7.0 89/11/23 21:48:09 mrose Rel $
 *
 *
 * $Log:	ds_abandon.c,v $
 * Revision 7.0  89/11/23  21:48:09  mrose
 * Release 6.0
 * 
 */

/*
 *				  NOTICE
 *
 *    Acquisition, use, and distribution of this module and related
 *    materials are subject to the restrictions of a license agreement.
 *    Consult the Preface in the User's Manual for the full terms of
 *    this agreement.
 *
 */


/* LINTLIBRARY */

#include "rosap.h"
#include "quipu/util.h"
#include "quipu/connection.h"

extern  LLog    * log_dsap;
void ros_log ();

#ifdef PDU_DUMP
#define DUMP_ARG 	"arg"
#define DUMP_RES 	"res"
#define DUMP_ERR 	"err"
#endif

dap_abandon (ad, id, arg, error)
int	  ad;
int	* id;
struct ds_abandon_arg       *arg;
struct DSError              *error;
{
    PE                  rda_pe;
    PE			resp_pe;
    int			resp_type;
    int                 inv_ret;

    if(encode_DAS_AbandonArgument(&rda_pe,1,NULLIP,NULLVP,arg) != OK)
    {
	error->dse_type = DSE_LOCALERROR;
	return(DS_ERROR_LOCAL);
    }

    switch(inv_ret = dap_invoke(ad, id, OP_ABANDON, rda_pe, &resp_type, &resp_pe))
    {
    case DS_OK:
	if(decode_DAS_AbandonResult(resp_pe,1,NULLIP,NULLCP,NULLCP) == OK) {
	    pe_free (resp_pe);
	    error->dse_type = DSE_NOERROR;
	    return(DS_OK);
	} else {
	    if(resp_pe != NULLPE)
	        pe_free (resp_pe);
	    error->dse_type = DSE_REMOTEERROR;
	    return(DS_ERROR_PROVIDER);
	}

    case DS_ERROR_REMOTE:
	if(decode_OPError(resp_pe, resp_type, error) == OK)
	{
	    if(resp_pe != NULLPE)
		pe_free(resp_pe);
	    return(DS_ERROR_REMOTE);
	}
	else
	{
	    if(resp_pe != NULLPE)
		pe_free(resp_pe);
	    error->dse_type = DSE_REMOTEERROR;
	    return(DS_ERROR_PROVIDER);
	}

    case DS_ERROR_PROVIDER:
	if (resp_type == ROS_INTERRUPTED) {
		error->dse_type = DSE_INTRERROR;
		return (inv_ret);
	}
	/* fall */

    default:
	error->dse_type = DSE_REMOTEERROR;
	return(inv_ret);
    }
}

int	  attempt_abandon(ad, id, op, resp_pe, resp_type)
int	  ad;
int	* id;
int	  op;
PE	* resp_pe;
int	* resp_type;
{
	/*
	* Abandoning. Trickier than it looks!
	* Need to RoInvoke an abandon op, which will receive
	* One of the following:
	*    Result/Error for op being abandoned sent before
	*	this abandon arrived at the DSA;
	*    Abandoned error for op being abandoned;
	*    Result for abandon op which has overtaken the
	*	abandoned error for previous op between DSA and DUA
	*    Error for abandon because DSA has screwed up.
	*
	* Basically there will be either one or two Ro events to
	* collect before returning. 1 in the case that abandon
	* receives the error "NoSuchOperation" 2 otherwise.
	*/

	/* abandon operation */
	struct ds_abandon_arg	  ab_arg;
	struct DSError		  ab_err;
	PE			  ab_req_pe;
	PE			  ab_resp_pe;
	int			  old_id;
	int			  result;
	int			  ret1;
	int			  ret2;
	struct RoSAPindication	  roi1_s;
	struct RoSAPindication	* roi1 = &(roi1_s);
	struct RoSAPpreject	* rop1 = &(roi1->roi_preject);
	struct RoSAPindication	  roi2_s;
	struct RoSAPindication	* roi2 = &(roi2_s);
	struct RoSAPpreject	* rop2 = &(roi2->roi_preject);

	ab_arg.aba_invokeid = old_id = (*id);
	++(*id);
	if(encode_DAS_AbandonArgument(&ab_req_pe,1,NULLIP,NULLVP,&ab_arg) != OK)
	{
		LLOG(log_dsap, LLOG_EXCEPTIONS, ("Failed to encode an abandon operation"));
		/* Go on listening for result or dump out ?? */
		return(DS_ERROR_PROVIDER);
	}
	else
	{
	    DLOG(log_dsap, LLOG_DEBUG, ("Abandon invoke request"));

    	    ret1 = RoInvokeRequest(ad,OP_ABANDON,ROS_SYNC,ab_req_pe,(old_id + 1),NULLIP,ROS_NOPRIO,roi1);

	    DLOG(log_dsap, LLOG_DEBUG, ("Abandon RoInvoke returns: %d", ret1));

	    pe_free(ab_req_pe);

	    switch(ret1)
	    {
	    case OK:
		/* What have we got? */
		switch(roi1->roi_type)
		{
		case ROI_RESULT:
#ifdef PDU_DUMP
	    pdu_dump (*resp_pe,DUMP_RES,op);
#endif
		    if(roi1->roi_result.ror_id == old_id)
		    {
			/* Ferret result away for later */
	    		*resp_type = op;
	    		*resp_pe = roi1->roi_result.ror_result;
			result = DS_OK;
		    }
		    else if(roi1->roi_result.ror_id == (old_id + 1))
		    {
			ab_resp_pe = roi1->roi_result.ror_result;
			/* Should check this really !! */
		    }
		    else
		    {
			LLOG(log_dsap, LLOG_EXCEPTIONS, ("ARRGH! Abandon sent: event for neither op nor abandon op returned!!"));
			return(DS_ERROR_PROVIDER);
		    }
		    break;

		case ROI_ERROR:
#ifdef PDU_DUMP
	    pdu_dump (*resp_pe,DUMP_ERR,op);
#endif
		    if(roi1->roi_error.roe_id == old_id)
		    {
			/* Ferret error away for later */
			*resp_type = roi1->roi_error.roe_error;
			*resp_pe = roi1->roi_error.roe_param;
			result = DS_ERROR_REMOTE;
		    }
		    else if(roi1->roi_error.roe_id == (old_id + 1))
		    {
			ab_resp_pe = roi1->roi_error.roe_param;
			if(decode_OPError(ab_resp_pe, roi1->roi_error.roe_error, &(ab_err)) != OK)
			{
				LLOG(log_dsap, LLOG_EXCEPTIONS, ("Failed to decode abandonFailed"));
				return(DS_ERROR_PROVIDER);
			}
			else
			{
				if(ab_err.dse_type != DSE_ABANDON_FAILED)
				{
					LLOG(log_dsap, LLOG_EXCEPTIONS, ("Failed to abandon correctly"));
					return(DS_ERROR_PROVIDER);
				}
				else
				{
					LLOG(log_dsap, LLOG_NOTICE, ("Abandon failed error!!!"));
					log_ds_error(&ab_err);
					ds_error_free(&ab_err);
				}
			}
		    }
		    else
		    {
			LLOG(log_dsap, LLOG_EXCEPTIONS, ("Abandon sent : event for neither op nor abandon op returned!!"));
			return(DS_ERROR_PROVIDER);
		    }
		    break;

		default:
		    LLOG(log_dsap, LLOG_FATAL, ("Unknown roi_type : %d", roi1->roi_type));
		    return(DS_ERROR_PROVIDER);
		}
	        break;

	    case NOTOK:
		ros_log(rop1, "RO-INVOKE.REQUEST");
		return(DS_ERROR_PROVIDER);

	    case DONE:
		/*
		* Assume A-RELEASE.INDICATION since RO-END.INDICATION is obsolete.
		*/
		LLOG(log_dsap, LLOG_EXCEPTIONS, ("Responder has sent Finish!"));
		return(DS_ERROR_PROVIDER);

            default:
		LLOG(log_dsap, LLOG_FATAL, ("Unknown return from RoInvokeRequest : %d", ret1));
		return(DS_ERROR_PROVIDER);
            }

	    ret2 = RoWaitRequest(ad, NOTOK, roi2);

	    DLOG(log_dsap, LLOG_DEBUG, ("Abandon RoInvoke returns: %d", ret1));

	    switch(ret2)
	    {
	    case OK:
		/* What have we got? */
		switch(roi2->roi_type)
		{
		case ROI_RESULT:
#ifdef PDU_DUMP
	    pdu_dump (*resp_pe,DUMP_RES,op);
#endif
		    if(roi2->roi_result.ror_id == old_id)
		    {
			/* Ferret result away for later */
	    		*resp_type = op;
	    		*resp_pe = roi2->roi_result.ror_result;
			result = DS_OK;
		    }
		    else if(roi2->roi_result.ror_id == (old_id + 1))
		    {
			ab_resp_pe = roi2->roi_result.ror_result;
			/* Should check this really !! */
		    }
		    else
		    {
			LLOG(log_dsap, LLOG_EXCEPTIONS, ("ARRGH! Abandon sent and event for neither op nor abandon op returned!!"));
			return(DS_ERROR_PROVIDER);
		    }
		    break;

		case ROI_ERROR:
#ifdef PDU_DUMP
	    pdu_dump (*resp_pe,DUMP_ERR,op);
#endif
		    if(roi2->roi_error.roe_id == old_id)
		    {
			/* Ferret error away for later */
			*resp_type = roi2->roi_error.roe_error;
			*resp_pe = roi2->roi_error.roe_param;
			result = DS_ERROR_REMOTE;
		    }
		    else if(roi2->roi_error.roe_id == (old_id + 1))
		    {
			ab_resp_pe = roi2->roi_error.roe_param;
			if(decode_OPError(ab_resp_pe, roi2->roi_error.roe_error, &(ab_err)) != OK)
			{
				LLOG(log_dsap, LLOG_EXCEPTIONS, ("Failed to decode abandonFailed"));
				return(DS_ERROR_PROVIDER);
			}
			else
			{
				if(ab_err.dse_type != DSE_ABANDON_FAILED)
				{
					LLOG(log_dsap, LLOG_EXCEPTIONS, ("Failed to abandon correctly"));
					return(DS_ERROR_PROVIDER);
				}
				else
				{
					LLOG(log_dsap, LLOG_NOTICE, ("Abandon failed error!!!"));
					log_ds_error(&ab_err);
					ds_error_free(&ab_err);
				}
			}
		    }
		    else
		    {
			LLOG(log_dsap, LLOG_EXCEPTIONS, ("Abandon sent : event for neither op nor abandon op returned!!"));
			return(DS_ERROR_PROVIDER);
		    }
		    break;

		default:
		    LLOG(log_dsap, LLOG_FATAL, ("Unknown roi_type : %d", roi2->roi_type));
		    return(DS_ERROR_PROVIDER);
		}
		break;

	    case NOTOK:
		ros_log(rop2, "RO-WAIT.REQUEST (Abandon)");
		return(DS_ERROR_PROVIDER);

	    case DONE:
		/*
		* Assume A-RELEASE.INDICATION since RO-END.INDICATION is obsolete.
		*/
		LLOG(log_dsap, LLOG_EXCEPTIONS, ("Responder has sent Finish!"));
		return(DS_ERROR_PROVIDER);

            default:
		LLOG(log_dsap, LLOG_FATAL, ("Unknown return from RoInvokeRequest : %d", ret2));
		return(DS_ERROR_PROVIDER);
            }
	}

	return(result);
}