next up previous contents
Next: Reference Counting Sessions Up: Example Protocol Previous: Control Operations

Close

Finally, aspClose is called indirectly through xClose when a high-level protocol wants to close a session it had opened earlier. This routine removes the entry in the active map corresponding to this session, closes the lower level session, and destroys the session object. As you can see, the session object includes a field in which the binding in the active map for this session was recorded ( binding). Also, the routine xMyProtl returns the protocol object that corresponds to this session (e.g., the protocol object that represents ASP).

static XkReturn
aspClose(Sessn s)
{
    ProtlState *pstate = (ProtlState *)xMyProtl(s)->state;

    /* remove this session from the active map */
    mapRemoveBinding(pstate->activemap, s->binding);

    /* close the lower level session on which it depends */
    xClose(xGetSessnDown(s, 0));

    /* de-allocate the session object itself */
    xDestroySessn(s);

    return XK_SUCCESS;
}



Larry Peterson
Wed Feb 21 13:58:06 MST 1996