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 n

⟦a37ea002e⟧ TextFile

    Length: 6472 (0x1948)
    Types: TextFile
    Names: »net_monitor.c«

Derivation

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

TextFile

/* net_monitor.c - accept and process events listened for */

#ifndef lint
static char *rcsid = "$Header: /f/osi/quipu/RCS/net_monitor.c,v 6.1 89/03/23 22:27:56 mrose Exp $";
#endif

/*
 * $Header: /f/osi/quipu/RCS/net_monitor.c,v 6.1 89/03/23 22:27:56 mrose Exp $
 *
 *
 * $Log:	net_monitor.c,v $
 * Revision 6.1  89/03/23  22:27:56  mrose
 * out-the-door
 * 
 * Revision 6.0  89/03/18  23:41:42  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 "rosap.h"
#include "tsap.h"
#include "quipu/util.h"
#include "quipu/connection.h"


extern LLog * log_dsap;
extern int start_nameserver;

net_monitor(secs)
int	  secs;
{
    int                         vecp = 0;
    char                        *vec[4];
    fd_set                      iads;
    fd_set                      wads;
    int                         nads;
    struct TSAPdisconnect       td_s;
    struct TSAPdisconnect       *td = &td_s;
    Conn                        cn;
    int                         i;
    char			ibuffer[BUFSIZ];
    char			*ibp;
    char			wbuffer[BUFSIZ];
    char			*wbp;
#ifdef DSAP
    extern int 			nameservice;
#endif

    ibp = ibuffer;
    wbp = wbuffer;
    for(i=id_st.nads; i>0; i--)
    {
	if (FD_ISSET (i, &id_st.iads))
	{
	    (void) sprintf(ibp, ", %d.", i);
	    ibp += (strlen(ibp) - 1);
	}
	if (FD_ISSET (i, &id_st.wads))
	{
	/*  secs = 0; 			/* Force polling to allow RETRYs */
	    (void) sprintf(wbp, ", %d.", i);
	    wbp += (strlen(wbp) - 1);
	}
    }

    if(ibp == ibuffer)
    {
	DLOG (log_dsap, LLOG_DEBUG, ("Listening for new associations"));
    }
    else
    {
	DLOG (log_dsap, LLOG_DEBUG, ("Listening on ads: %s", (ibuffer+1)));
    }

    if(wbp == wbuffer)
    {
	DLOG (log_dsap, LLOG_DEBUG, ("Not making new associations"));
    }
    else
    {
	DLOG (log_dsap, LLOG_DEBUG, ("Making ads: %s", (wbuffer+1)));
    }

#ifdef DSAP
    if (start_nameserver) {
	DLOG (log_dsap, LLOG_DEBUG, ("Nameservice on ad: %d", nameservice));
	if ( FD_ISSET (nameservice, &id_st.iads)) {
	    DLOG(log_dsap, LLOG_DEBUG, ("Nameservice already set! WHERE?"));
	}
	else {
	    if(secs != 0) {
		if (nameservice >= id_st.nads)
			id_st.nads = nameservice + 1;
	    	FD_SET (nameservice,&id_st.iads);
	        DLOG(log_dsap, LLOG_DEBUG, ("Not polling: set nameservice"));
	    }
	    else {
	        DLOG(log_dsap, LLOG_DEBUG, ("Polling: don't set nameservice"));
	    }
	}
    }
    else {
	DLOG (log_dsap, LLOG_DEBUG, ("Nameservice off"));
    }
#endif

    iads = id_st.iads;
    wads = id_st.wads;
    nads = id_st.nads;

    DLOG (log_dsap, LLOG_DEBUG, ("secs : %d; nads : %d", secs, nads));

    if(TNetAccept(&vecp, vec, nads, &iads, &wads, NULLFD, secs, td) == NOTOK)
    {
	LLOG(log_dsap, LLOG_EXCEPTIONS, ("TNetAccept Failed"));
	td_log(td);
	return;
    }

#ifdef DSAP
    if (start_nameserver)
	    if (FD_ISSET (nameservice,&iads)) {
		ns_process (nameservice);
		return;
    	    }
#endif

    if(vecp > 0)
    {
	if(net_wait_init_request(vecp, vec) == OK)
	{
	    /*
	    * If OK a new connection block will have been prefixed
	    * to the existing list.
	    */
	    cn = id_st.connlist;
	    if((cn->cn_state == CN_STATE_INIT) && 
	      (cn->cn_init_act.ia_type == ACT_TYPE_REQ))
		dsa_work_init_request(cn);
	    if(cn->cn_init_act.ia_type == ACT_TYPE_RESP)
	        net_send_init_response(cn);
	}
    }

    for(cn = id_st.connlist; cn != NULLCONN; cn = cn->cn_next)
    {
	switch(cn->cn_state)
	{
	case CN_STATE_INIT:
	    LLOG(log_dsap, LLOG_EXCEPTIONS, ("Checking %d", cn->cn_ad));
	    if(FD_ISSET(cn->cn_ad, &wads))
	    {
	        LLOG(log_dsap, LLOG_EXCEPTIONS, ("Polling %d", cn->cn_ad));
	        net_wait_init_response(cn);
	    }
	break;

	case CN_STATE_INIT2:
	    LLOG (log_dsap, LLOG_EXCEPTIONS, ("Checking %d (2)", cn ->cn_ad));
	    if (FD_ISSET(cn->cn_ad, &iads))
	    {
		LLOG(log_dsap, LLOG_EXCEPTIONS, ("Polling %d (2)", cn->cn_ad));
		net_wait_init_response(cn);
	    }
	break;

	case CN_STATE_OPEN:
	case CN_STATE_EXIT:
	    if (FD_ISSET (cn->cn_ad, &iads))
	    {
		DLOG (log_dsap,LLOG_TRACE,( "Activity on association: %d", cn->cn_ad));
		net_dispatch(cn);
	    } /* if there is work on this connection */
	break;

	case CN_STATE_FAIL:
	default:
	    if (FD_ISSET (cn->cn_ad, &iads))
	    {
		LLOG (log_dsap,LLOG_EXCEPTIONS,( "Unexpected activity on association %d",
		  cn->cn_ad));
	    } /* if there is work on this connection */
	break;
	}
    } /* for each connection */
} /* net_monitor */

/*
* Something has happened on the association with descriptor "ad".
* Check what type of activity it is and dispatch to an appropriate
* routine to handle the activity.
*/
net_dispatch(cn)
Conn      cn;
{
    struct RoSAPindication      roi_s;
    struct RoSAPindication      *roi = &roi_s;
    struct RoSAPpreject         *rop = &(roi->roi_preject);
    extern void ros_log();

    DLOG (log_dsap,LLOG_TRACE,( "net_dispatch()"));

    if(RoWaitRequest(cn->cn_ad, OK, roi) ==  NOTOK)
    {
	ros_log(rop, "RoWaitRequest");
	if(ROS_FATAL(rop->rop_reason))
	{
	    cn->cn_state = CN_STATE_FAIL;
	    cn->cn_ad = 0;
	}
	return;
    }

    switch(roi->roi_type)
    {
	case ROI_INVOKE:
	{
	    struct RoSAPinvoke  *rox = &(roi->roi_invoke);

	    net_wait_ro_invoke(cn, rox);
	    ROXFREE(rox);
	}
	break;

	case ROI_RESULT:
	{
	    struct RoSAPresult  *ror = &(roi->roi_result);

	    net_wait_ro_result(cn, ror);
	    RORFREE(ror);
	}
	break;

	case ROI_ERROR:
	{
	    struct RoSAPerror   *roe = &(roi->roi_error);

	    net_wait_ro_error(cn, roe);
	    ROEFREE(roe);
	}
	break;

	case ROI_UREJECT:
	{
	    struct RoSAPureject   *rou = &roi->roi_ureject;

	    net_wait_ro_ureject(cn, rou);
	}
	break;

	case ROI_PREJECT:
	{
	     struct RoSAPpreject   *rop2 = &roi->roi_preject;

	     net_wait_ro_preject(cn, rop2);
	     ROPFREE(rop2);
	}
	break;

	case ROI_END:
	{
	    struct RoSAPend     *roe = &(roi->roi_end);

	    DLOG (log_dsap,LLOG_TRACE,( "RO-END.INDICATION outmoded"));
	    net_wait_ro_end(cn, roe);
	}
	break;

	case ROI_FINISH:
	{
	    struct AcSAPfinish *acf = &roi->roi_finish;

	    net_wait_ro_finish(cn, acf);
	}
	break;

	default:
	    LLOG (log_dsap,LLOG_EXCEPTIONS,( "Unknown indication type : %d", roi->roi_type));
	break;
    }
}