コード例 #1
0
ファイル: csmoscb.c プロジェクト: saqibjamil/Ingres
/*{
** Name:	CS_scb_attach	- make an SCB known to MO/IMA
**
** Description:
**	Links the specified SCB into the known thread tree.  Logs
**	error to server log if it's already present (it shouldn't).
**
** Re-entrancy:
**	no.  Called with inkernel set, presumabely.
**	(OS-threads: yes, locks global tree mutex)
**
** Inputs:
**	scb		the thread to link in.
**
** Outputs:
**	scb		cs_spblk is updated.
**
** Returns:
**	none.	
**
** Side Effects:
**	May TRdisplay debug information.
**
** History:
**	26-Oct-1992 (daveb)
**	    documented.
**	06-oct-1993 (tad)
**	    Bug #56449
**	    Changed %x to %p for pointer values.
**	13-Feb-98 (fanra01)
**	    Modified to use the SID as the key.
*/
void
CS_scb_attach( CS_SCB *scb )
{
    SPBLK node;
    SPBLK *sp;

# ifdef OS_THREADS_USED
    CS_synch_lock( &Cs_srv_block.cs_scb_mutex );
# endif /* OS_THREADS_USED */
    node.key = (PTR) scb->cs_self;
    sp = SPlookup( &node, Cs_srv_block.cs_scb_ptree );
    if( sp != NULL )
    {
	TRdisplay("CS_scb_attach: attempt to attach existing SCB %p!!!\n",
		  scb );
    }
    else
    {
        scb->cs_spblk.uplink = NULL;
	scb->cs_spblk.leftlink = NULL;
	scb->cs_spblk.rightlink = NULL;
	scb->cs_spblk.key = (PTR) scb->cs_self;
	SPinstall( &scb->cs_spblk, Cs_srv_block.cs_scb_ptree );
    }
# ifdef OS_THREADS_USED
    CS_synch_unlock( &Cs_srv_block.cs_scb_mutex );
# endif /* OS_THREADS_USED */
}
コード例 #2
0
ファイル: gwmpmib.c プロジェクト: saqibjamil/Ingres
static STATUS 
GM_subpindex(i4 msg,
	   PTR cdata,
	   i4  linstance,
	   char *instance, 
	   PTR *instdata )
{
    STATUS cl_stat = MO_NO_INSTANCE;
    GM_PLACE_BLK	*pb;
    SPBLK		lookup;
    
    lookup.key = instance;
    pb = (GM_PLACE_BLK *)SPlookup( &lookup, &GM_globals.gwm_places );

    switch( msg )
    {
    case MO_GET:

	if( pb != NULL )
	    cl_stat = OK;
	break;

    case MO_GETNEXT:

	if( pb != NULL )
	{
	    pb = (GM_PLACE_BLK *) SPfnext( &pb->place_blk );
	}
	else			/* didn't find directly */
	{
	    if( *instance == EOS  )
		pb = (GM_PLACE_BLK *)SPfhead( &GM_globals.gwm_places );
	    else
		break;
	}

	if( pb == NULL )
	    cl_stat = MO_NO_NEXT;
	else
	    cl_stat = MOstrout( MO_INSTANCE_TRUNCATED,
			     pb->place_key, linstance, instance );
	break;

    default:

	cl_stat = MO_BAD_MSG;
	break;
    }

    *instdata = (PTR)pb;

    return( cl_stat );
}
コード例 #3
0
MO_MON_BLOCK *
MO_getmon( MO_CLASS *cp, PTR mon_data )
{
    MO_MON_BLOCK mon;
    MO_MON_BLOCK *mp;

    mon.node.key = (PTR)&mon;
    mon.mo_class = cp;
    mon.mon_data = mon_data;
    mp = (MO_MON_BLOCK *) SPlookup( &mon.node, MO_monitors );
    return( mp );
}
コード例 #4
0
ファイル: gwmpmib.c プロジェクト: saqibjamil/Ingres
/*{
** Name:	GM_gt_conn	- locate connection given server and con_key
**
** Description:
**	Lookup a connection block, given the server instance and the
**	conn_key.  If the connection is found, returns holding the
**	semaphore for the place.
**
** Re-entrancy:
**	yes.
**
** Inputs:
**	instance	the server instance value.
**	conn_key	the connection key.
**
** Outputs:
**	ppb		ptr to a GM_PLACE_BLK * to fill in.
**	pcb		ptr to a GM_CONN_BLK * to fill in.
**
** Returns:
**	OK		connection found.
**	MO_NO_INSTANCE	not found.
**
** History:
**	6-oct-92 (daveb)
**	    created.
*/
STATUS
GM_gt_conn( char *instance,
	   PTR conn_key,
	   GM_PLACE_BLK **ppb,
	   GM_CONN_BLK **pcb )
{
    GM_SRVR_BLK		*sb;
    GM_CONN_BLK		*cb;
    GM_PLACE_BLK	*pb;
    SPBLK		lookup;

    /* Assert: gwm_place_sem is already held */

    do
    {
	lookup.key = (PTR)instance;
	pb = (GM_PLACE_BLK *)SPlookup( &lookup, &GM_globals.gwm_places );
	if( pb == NULL || (pb)->place_type != GM_PLACE_SRVR )
	    break;
    
	sb = &pb->place_srvr;
	if( OK != GM_gt_sem( &pb->place_sem ))
	    break;
	    
	lookup.key = conn_key;
	cb = (GM_CONN_BLK *)SPlookup( &lookup,
				     &pb->place_srvr.srvr_conns );

	if( cb == NULL )
	    GM_release_sem( &pb->place_sem );
	
    } while ( FALSE );

    *ppb = pb;
    *pcb = cb;
    return( cb != NULL ? OK : MO_NO_INSTANCE );
}
コード例 #5
0
ファイル: csmoscb.c プロジェクト: saqibjamil/Ingres
void
CS_detach_scb( CS_SCB *scb )
{
    SPBLK node;
    SPBLK *sp;

    node.key = (PTR)scb->cs_self;
    sp = SPlookup( &node, Cs_srv_block.cs_scb_ptree );
    if( sp == NULL )
    {
	TRdisplay("CS_detach_scb: attempt to detach unknown SCB %x\n",
		  scb );
    }
    else
    {
	SPdelete( &scb->cs_spblk, Cs_srv_block.cs_scb_ptree );
    }
}
コード例 #6
0
MO_INSTANCE *
MO_getinstance( char *classid, char *instance )
{
    MO_CLASS	cb;
    MO_INSTANCE	ib;
    MO_INSTANCE	*ip;

    cb.node.key = classid;
    ib.classdef = &cb;
    ib.instance = instance;
    ib.node.key = (PTR)&ib;

    if( instance != NULL )	/* find exact match */
    {
	ip = (MO_INSTANCE *)SPlookup( &ib.node, MO_instances );
    }
    else			/* find first of that class */
    {
	/*
	** This relies on the comparison function returning -1
	** when classids are equal, and the input instance is NULL.
	** After the enq, ib is the lowest block of the class; the
	** next one is the old first.
	*/
	(VOID) SPenq( &ib.node, MO_instances );
	ip = (MO_INSTANCE *)SPnext( &ib.node, MO_instances );
	SPdelete( &ib.node, MO_instances );

	if( ip != NULL && !STequal( (char *)ip->classdef->node.key, classid ) )
	    ip = NULL;
    }

# ifdef xDEBUG
    SIprintf("getinstance %s:%s -> %s:%s\n",
	     classid ? classid : "<nil>",
	     instance ? instance : "<nil>",
	     ip ? ip->classdef->node.key : "<nil>",
	     ip ? ip->instance : "<nil>" );
# endif

    return( ip );
}
コード例 #7
0
ファイル: csmoscb.c プロジェクト: saqibjamil/Ingres
/*{
** Name:	CS_scb_attach	- make an SCB known to MO/IMA
**
** Description:
**	Links the specified SCB into the known thread tree.  Logs
**	error to server log if it's already present (it shouldn't).
**
** Re-entrancy:
**	no.  Called with inkernel set, presumabely.
**
** Inputs:
**	scb		the thread to link in.
**
** Outputs:
**	scb		cs_spblk is updated.
**
** Returns:
**	none.	
**
** Side Effects:
**	May TRdisplay debug information.
**
** History:
**	26-Oct-1992 (daveb)
**	    documented.
*/
void
CS_scb_attach( CS_SCB *scb )
{
    SPBLK node;
    SPBLK *sp;

    node.key = (PTR)scb->cs_self;
    sp = SPlookup( &node, Cs_srv_block.cs_scb_ptree );
    if( sp != NULL )
    {
	TRdisplay("CS_scb_attach: attempt to attach existing SCB %x!!!\n",
		  scb );
    }
    else
    {
        scb->cs_spblk.uplink = NULL;
	scb->cs_spblk.leftlink = NULL;
	scb->cs_spblk.rightlink = NULL;
	scb->cs_spblk.key = (PTR)scb->cs_self;
	SPinstall( &scb->cs_spblk, Cs_srv_block.cs_scb_ptree );
    }
}
コード例 #8
0
ファイル: csmoscb.c プロジェクト: saqibjamil/Ingres
void
CS_detach_scb( CS_SCB *scb )
{
    SPBLK node;
    SPBLK *sp;

# ifdef OS_THREADS_USED
    CS_synch_lock( &Cs_srv_block.cs_scb_mutex );
# endif /* OS_THREADS_USED */
    node.key = (PTR) scb->cs_self;
    sp = SPlookup( &node, Cs_srv_block.cs_scb_ptree );
    if( sp == NULL )
    {
	TRdisplay("CS_detach_scb: attempt to detach unknown SCB %p\n",
		  scb );
    }
    else
    {
	SPdelete( &scb->cs_spblk, Cs_srv_block.cs_scb_ptree );
    }
# ifdef OS_THREADS_USED
    CS_synch_unlock( &Cs_srv_block.cs_scb_mutex );
# endif /* OS_THREADS_USED */
}