Beispiel #1
0
VOID
MO_delmon( MO_MON_BLOCK *mp )
{
    MO_MON_BLOCK *nmp;		/* next monitor */
    MO_CLASS *cp = mp->mo_class;

    /* free the regexp we saved earlier */

    if( mp->qual_regexp != NULL )
	MO_delstring( mp->qual_regexp );

    /* If this is the first monitor for the class, then we need to
       point the class at the next one, because this one is going away.
       If the next one is for a different class, then there are no more
       monitors for this class. */

    if( cp->monitor == mp )
    {
	nmp = (MO_MON_BLOCK *)SPfnext( &mp->node );
	cp->monitor = ( nmp != NULL && nmp->mo_class == cp ) ? nmp : NULL;

	if( cp->twin )
	    cp->twin->monitor = cp->monitor;
    }

    /* slice it out of the tree*/

    SPdelete( &mp->node, MO_monitors );

    /* recover memory for the node */

    MO_free( (PTR)mp, sizeof(*mp) );

    MO_ndel_monitor++;
}
Beispiel #2
0
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 );
    }
}
Beispiel #3
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 );
}
Beispiel #4
0
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 */
}
Beispiel #5
0
/*{
**  Name:	MOdetach - detach an attached instance
**
**  Description:
**
**	Detaches an attached instance.  Subsequent attempts to get or
**	set it will fail, and an attempts to attach it will succeed.
**
**	Frees memory allocated by MOattach using MEfree.
**
**	If the call succeeds, it must also call the monitors for the
**	class with the MO_DETACH event, the instance id, and a NULL
**	value.
**
**  Inputs:
**	 classid
**		the classid of the object.
**	 instance
**		the instance of the object.
**  Outputs:
**	 none
**  Returns:
**	 OK
**		if the classid was detached.
**	 MO_NO_INSTANCE
**		if classid is not attached.
**	 MO_NO_DETACH
**		if the object was attached as MO_PERMANENT.
**
**    History:
**	15-jul-92 (daveb)
**	    Go back to single-instance attach/detach, as with
**	    MOcdata_index most bulky static one-offs will be
**	    right in the class definitions anyway, and this
**	    is simpler for the dynamic attach.
**	02-sep-1999 (somsa01)
**	    We were calling MO_tell_class AFTER releasing the MO mutex.
*/
STATUS
MOdetach( char *classid, char *instance )
{
    MO_INSTANCE	*ip;
    MO_CLASS	*cp;
    STATUS stat = OK;
    STATUS mutex_stat = OK;

    MO_once();
    mutex_stat = MO_mutex();
    do
    {
	if( mutex_stat != OK )		/* got mutex */
	    break;

	MO_ndetach++;

	ip = MO_getinstance( classid, instance );
	if( NULL == ip )
	{
	    stat = MO_NO_INSTANCE;
	    break;
	}

	cp = ip->classdef;
	if( cp->perms & MO_PERMANENT )
	{
	    stat = MO_NO_DETACH;
	    break;
	}

	/*
	** We have detachable instance, do it
	*/

	/* detach twin, if any, giving up it it won't go away */

	if( CMalpha( classid ) && NULL != cp->twin &&
	   (stat = MOdetach( cp->twin->node.key, ip->instance)) != OK )
	    break;

	/* delete saved instance string */

	if( (ip->iflags & MO_INSTANCE_VAR) != 0 )
	    MO_delstring( ip->instance );

	/* and finally delete this node */

	SPdelete( &ip->node, MO_instances );
	MO_free( (PTR)ip, sizeof(*ip) );

    } while( FALSE );

    if( mutex_stat == OK )
	(VOID) MO_unmutex();
    else
	stat = mutex_stat;

    if( stat == OK )
    {
	if ( (stat = MO_mutex()) == OK)
	{
	    (VOID) MO_tell_class( cp, instance, (char *)NULL, MO_DETACH );
            MO_unmutex ();
	}
    }

    return( stat );
}