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 a

⟦2805cc2dd⟧ TextFile

    Length: 9288 (0x2448)
    Types: TextFile
    Names: »activity.c«

Derivation

└─⟦3d0c2be1b⟧ Bits:30001254 ISODE-5.0 Tape
    └─⟦eba4602b1⟧ »./isode-5.0.tar.Z« 
        └─⟦d3ac74d73⟧ 
            └─⟦this⟧ »isode-5.0/quipu/activity.c« 

TextFile

/* activity.c - */

#ifndef lint
static char *rcsid = "$Header: /f/osi/quipu/RCS/activity.c,v 6.0 89/03/18 23:41:02 mrose Rel $";
#endif

/*
 * $Header: /f/osi/quipu/RCS/activity.c,v 6.0 89/03/18 23:41:02 mrose Rel $
 *
 *
 * $Log:	activity.c,v $
 * Revision 6.0  89/03/18  23:41:02  mrose
 * Release 5.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.
 *
 */


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

extern LLog * log_dsap;

struct activity *act_alloc()
{
    struct activity     *act_ret;

    act_ret = (struct activity *) calloc(1,sizeof(struct activity));

    act_ret->act_cha = &(act_ret->act_req.dca_charg);
    act_ret->act_result = &(act_ret->act_resp.resp_res);
    act_ret->act_error = &(act_ret->act_resp.resp_err);

    return(act_ret);
}

struct activity *oper_alloc()
{
    struct activity     *oper_ret = act_alloc();

    oper_ret->act_initiator = INITIATED_BY_THIS;

    return(oper_ret);
}

struct activity *task_alloc()
{
    struct activity     *task_ret = act_alloc();

    task_ret->act_initiator = INITIATED_BY_THAT;

    return(task_ret);
}

act_free(act)
struct activity *act;
{
	response_free (&(act->act_resp));
	if(act->act_initiator == INITIATED_BY_THAT)
	    op_arg_free (&(act->act_req));

	free((char *)act);
}

task_extract(task)
struct activity *task;
{
    struct activity     *on;
    struct activity     *tk;

    DLOG (log_dsap,LLOG_TRACE, ("task_extract()"));
    if(task == NULLACTIVITY)
    {
	LLOG (log_dsap,LLOG_FATAL,("Attempted to extract NULLACTIVITY!!"));
	return;
    }

    for(on = task->tk_operlist; on!=NULLACTIVITY; on = on->on_next_task)
    {
	oper_task_extract(on);
	if(on->act_conn == NULLCONN)
	    act_free(on);
    }

    if(task->act_conn->cn_tasklist == task)
    {
	task->act_conn->cn_tasklist = task->act_conn->cn_tasklist->tk_next;
    }
    else
    {
	for(tk = task->act_conn->cn_tasklist; tk->tk_next != NULLACTIVITY; tk = tk->tk_next)
	{
	    if(tk->tk_next == task)
		break;
	}

	if(tk->tk_next == NULLACTIVITY)
	{
	    LLOG(log_dsap, LLOG_FATAL, ("Task memerr extract 1"));
	}
	else
	{
	    tk->tk_next = task->tk_next;
	}
    }
    act_free(task);
    DLOG (log_dsap,LLOG_TRACE, ("task block freed"));
}

oper_extract(oper)
struct activity *oper;
{
    if(oper->act_conn != NULLCONN)
	oper_conn_extract(oper);

    if(oper->on_task != NULLACTIVITY)
	oper_task_extract(oper);

    act_free(oper);
}

oper_conn_extract(oper)
struct activity *oper;
{
    /*
    * Extract the operation activity block from the list held by its
    * connection.
    */
    struct activity     *on;

    if(oper == NULLACTIVITY)
    {
	LLOG (log_dsap,LLOG_FATAL, ("Cannot extract NULLOPER"));
	return;
	/* This is an implementation error */
    }

    if(oper->act_conn == NULLCONN)
	return;
	/* This operation must have already been extracted for some reason. */

    if(oper->act_conn->cn_operlist == oper)
	oper->act_conn->cn_operlist = oper->on_next_conn;
    else
    {
	for(on=oper->act_conn->cn_operlist; on->on_next_conn!=NULLACTIVITY; on=on->on_next_conn)
	{
	    if(on->on_next_conn == oper)
		break;
	}

	if(on->on_next_conn == NULLACTIVITY)
	{
	    LLOG(log_dsap, LLOG_FATAL, ("Task memerr extract 2"));
	}
	else
	{
	    on->on_next_conn = oper->on_next_conn;
	}
    }

    if((oper->act_conn->cn_initiator == INITIATED_BY_THIS)
      && (oper->act_conn->cn_state == CN_STATE_INIT)
      && (oper->act_conn->cn_operlist == NULLACTIVITY))
    {
	LLOG (log_dsap,LLOG_NOTICE, ("Extracting conn while extracting oper"));
	oper->act_conn->cn_state = CN_STATE_FAIL;
    }

    oper->act_conn = NULLCONN; /* Shows that this has been conn_extracted */
}

oper_task_extract(oper)
struct activity *oper;
{
    /*
    * Extract this operation from the list held by its task.
    */
    struct activity     *on;

    if(oper == NULLACTIVITY)
    {
	LLOG (log_dsap,LLOG_FATAL, ("Cannot extract NULLOPER"));
	return;
	/* This is an implementation error */
    }

    if(oper->on_task == NULLACTIVITY)
	return;
	/* Must have been extracted previously. */

    if(oper->on_task->tk_operlist == oper)
	oper->on_task->tk_operlist = oper->on_next_task;
    else
    {
	for(on=oper->on_task->tk_operlist; on->on_next_task!=NULLACTIVITY; on=on->on_next_task)
	{
	    if(on->on_next_task == oper)
		break;
	}

	if(on->on_next_task == NULLACTIVITY)
	{
	    LLOG(log_dsap, LLOG_FATAL, ("Task memerr extract 3"));
	}
	else
	{
	    on->on_next_task = oper->on_next_task;
	}
    }

    oper->on_task->act_class = ACTIVITY_COLLATE;
    oper->on_task = NULLACTIVITY; /* Shows that this has been task_extracted */
}

task_log(task)
struct activity *task;
{
    struct activity     * oper;

    DLOG (log_dsap,LLOG_NOTICE, ("Task [%x]", task));
    act_log(task);
    if(task->tk_operlist != NULLACTIVITY)
	DLOG (log_dsap,LLOG_NOTICE, ("Task-Opers:"));
    for(oper=task->tk_operlist; oper != NULLACTIVITY; oper = oper->on_next_task)
	oper_log(oper);
}

oper_log(oper)
struct activity * oper;
{
    DLOG (log_dsap,LLOG_NOTICE, ("Oper [%x]", oper));
    act_log(oper);
}

act_log(act)
struct activity * act;
{
    DLOG (log_dsap,LLOG_TRACE, ("  activity: id = %d, class = %d, type = %d, prio = %d.",
      act->act_id, act->act_class, act->act_type, act->act_prio));
}

op_arg_free (arg)
struct ds_op_arg * arg;
{
	/* free chain bits */
	dn_free (arg->dca_charg.cha_originator);
	dn_free (arg->dca_charg.cha_target);
	if (arg->dca_charg.cha_domaininfo != NULLPE)
		pe_free (arg->dca_charg.cha_domaininfo);

	if(arg->dca_charg.cha_trace != NULLTRACEINFO)
		trace_info_free (arg->dca_charg.cha_trace);

	if (arg->dca_charg.cha_timelimit != (struct UTCTime *)NULL)
		free ((char*)arg->dca_charg.cha_timelimit);
	
	/* free argument structure */
	switch (arg->dca_dsarg.arg_type) {
	case OP_READ:
		ca_free (&arg->dca_dsarg.arg_rd.rda_common);
		dn_free (arg->dca_dsarg.arg_rd.rda_object);
		as_free (arg->dca_dsarg.arg_rd.rda_eis.eis_select);
		break;
	case OP_COMPARE:
		ca_free (&arg->dca_dsarg.arg_cm.cma_common);
		dn_free (arg->dca_dsarg.arg_cm.cma_object);
		AttrT_free (arg->dca_dsarg.arg_cm.cma_purported.ava_type);
		AttrV_free (arg->dca_dsarg.arg_cm.cma_purported.ava_value);
		break;
	case OP_ABANDON:
		break;
	case OP_LIST:
		ca_free (&arg->dca_dsarg.arg_ls.lsa_common);
		dn_free (arg->dca_dsarg.arg_ls.lsa_object);
		break;
	case OP_SEARCH:
		ca_free (&arg->dca_dsarg.arg_sr.sra_common);
		dn_free (arg->dca_dsarg.arg_sr.sra_baseobject);
		as_free (arg->dca_dsarg.arg_sr.sra_eis.eis_select);
		filter_free (arg->dca_dsarg.arg_sr.sra_filter);
		break;
	case OP_ADDENTRY:
		ca_free (&arg->dca_dsarg.arg_ad.ada_common);
		dn_free (arg->dca_dsarg.arg_ad.ada_object);
		as_free (arg->dca_dsarg.arg_ad.ada_entry);
		break;
	case OP_REMOVEENTRY:		
		ca_free (&arg->dca_dsarg.arg_rm.rma_common);
		dn_free (arg->dca_dsarg.arg_rm.rma_object);
		break;
	case OP_MODIFYENTRY:
		ca_free (&arg->dca_dsarg.arg_me.mea_common);
		dn_free (arg->dca_dsarg.arg_me.mea_object);
		ems_free (arg->dca_dsarg.arg_me.mea_changes);
		break;
	case OP_MODIFYRDN:
		ca_free (&arg->dca_dsarg.arg_mr.mra_common);
		dn_free (arg->dca_dsarg.arg_mr.mra_object);
		rdn_free (arg->dca_dsarg.arg_mr.mra_newrdn);
		break;
	case OP_GETEDB:
		dn_free (arg->dca_dsarg.arg_ge.ga_entry);
		break;
	default:
		break;
	}

}

trace_info_free (arg)
struct trace_info * arg;
{
	if (arg == NULLTRACEINFO)
		return;
	dn_free (arg->ti_target);
	dn_free (arg->ti_dsa);
	trace_info_free (arg->ti_next);
	free( (char *) arg);

}

ca_free (arg)
CommonArgs * arg;
{
	dn_free (arg->ca_requestor);
	extension_free (arg->ca_extensions);
}

extension_free (arg)
struct extension * arg;
{
	for (; arg != NULLEXT; arg=arg->ext_next) {
		if (arg->ext_item != NULLPE)
			pe_free (arg->ext_item);
		free ((char *) arg);
	}
}

response_free (arg)
struct response * arg;
{
	if (arg->ret_type == RET_TYPE_ERR)
		ds_error_free (&arg->resp_err);
	else
		op_res_free (&arg->resp_res);

	crefs_free (arg->resp_ref);
}


op_res_free (arg)
struct ds_op_res * arg;
{
	/* free chain bits */
	if (arg->dcr_chres.chr_domaininfo != NULLPE)
		pe_free (arg->dcr_chres.chr_domaininfo);

	cross_refs_free (arg->dcr_chres.chr_crossrefs);

	/* free argument structure */
	switch (arg->dcr_dsres.result_type) {
	case OP_READ:
/*
		dn_free (&arg->dcr_dsres.res_rd.rdr_common.cr_requestor);
*/
		entryinfo_comp_free (&arg->dcr_dsres.res_rd.rdr_entry,1);
		break;
	case OP_COMPARE:
/*
		dn_free (&arg->dcr_dsres.res_cm.cmr_common.cr_requestor);
*/
		dn_free (arg->dcr_dsres.res_cm.cmr_object);
		break;
	case OP_LIST:
/*
		dn_free (&arg->dcr_dsres.res_ls.lsr_common.cr_requestor);
*/
		dn_free (arg->dcr_dsres.res_ls.lsr_object);
		subords_free (arg->dcr_dsres.res_ls.lsr_subordinates);
		crefs_free (arg->dcr_dsres.res_ls.lsr_cr);
		break;
	case OP_SEARCH:
		search_result_free(&(arg->dcr_dsres.res_sr));
		break;
	case OP_GETEDB:
		break;	/* don't free EDB */
	default:
		break;
	}
	
}

cross_refs_free (arg)
struct cross_ref * arg;
{
	if (arg == NULLXREF)
		return;
	dn_free (arg->xref_dn);
	aps_free (arg->xref_ap);
	cross_refs_free (arg->xref_next);
	free ((char *)arg);
}