Back to index

openldap  2.4.31
Public Member Functions | Private Attributes
LDAPMessageQueue Class Reference

This class is created for the asynchronous LDAP-operations. More...

#include <LDAPMessageQueue.h>

Collaboration diagram for LDAPMessageQueue:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 LDAPMessageQueue (LDAPRequest *conn)
 This creates a new LDAPMessageQueue.
 ~LDAPMessageQueue ()
 Destructor.
LDAPMsggetNext ()
 This method reads exactly one Message from the results of a Request.
LDAPRequestchaseReferral (LDAPMsg *ref)
 For internat use only.
LDAPRequestStackgetRequestStack ()
 For internal use only.

Private Attributes

LDAPRequestStack m_activeReq
LDAPRequestList m_issuedReq

Detailed Description

This class is created for the asynchronous LDAP-operations.

And can be used by the client to retrieve the results of an operation.

Definition at line 27 of file LDAPMessageQueue.h.


Constructor & Destructor Documentation

This creates a new LDAPMessageQueue.

For a LDAP-request

Parameters:
connThe Request for that is queue can be used to get the results.

Definition at line 24 of file LDAPMessageQueue.cpp.

                                                  {
    DEBUG(LDAP_DEBUG_CONSTRUCT, "LDAPMessageQueue::LDAPMessageQueue()" << endl);
       m_activeReq.push(req);
    m_issuedReq.push_back(req);
}

Destructor.

Definition at line 30 of file LDAPMessageQueue.cpp.

                                   {
    DEBUG(LDAP_DEBUG_DESTROY, "LDAPMessageQueue::~LDAPMessageQueue()" << endl);
    for(LDAPRequestList::iterator i=m_issuedReq.begin(); 
            i != m_issuedReq.end(); i++){
        delete *i;
    }
    m_issuedReq.clear();
}

Member Function Documentation

For internat use only.

The method is used to start the automatic referral chasing

Definition at line 142 of file LDAPMessageQueue.cpp.

                                                        {
    DEBUG(LDAP_DEBUG_TRACE,"LDAPMessageQueue::chaseReferral()" << endl);
    LDAPRequest *req=m_activeReq.top();
    LDAPRequest *refReq=req->followReferral(ref);
    if(refReq !=0){
        if(refReq->getConstraints()->getHopLimit() < refReq->getHopCount()){
            delete(refReq);
            throw LDAPException(LDAP_REFERRAL_LIMIT_EXCEEDED);
        }
        if(refReq->isCycle()){
            delete(refReq);
            throw LDAPException(LDAP_CLIENT_LOOP);
        }
        try {
            refReq->sendRequest();
            return refReq;
        }catch (LDAPException e){
            DEBUG(LDAP_DEBUG_TRACE,"   caught exception" << endl);
            return 0;
        }
    }else{ 
        return 0;
    }
}

Here is the call graph for this function:

This method reads exactly one Message from the results of a Request.

Exceptions:
LDAPException
Returns:
A pointer to an object of one of the classes that were derived from LDAPMsg. The user has to cast it to the correct type (e.g. LDAPResult or LDAPSearchResult)

Definition at line 40 of file LDAPMessageQueue.cpp.

                                  {
    DEBUG(LDAP_DEBUG_TRACE,"LDAPMessageQueue::getNext()" << endl);

    if ( m_activeReq.empty() ) {
        return 0;
    }

    LDAPRequest *req=m_activeReq.top();
    LDAPMsg *ret=0;

    try{
        ret = req->getNextMessage();
    }catch(LDAPException e){
        //do some clean up
        m_activeReq.pop();
        throw;   
    }

    const LDAPConstraints *constr=req->getConstraints();
    switch (ret->getMessageType()) {
        case LDAPMsg::SEARCH_REFERENCE : 
            if (constr->getReferralChase() ){
                //throws Exception (limit Exceeded)
                LDAPRequest *refReq=chaseReferral(ret);
                if(refReq != 0){
                    m_activeReq.push(refReq);
                    m_issuedReq.push_back(refReq);
                    delete ret;
                    return getNext();
                }
            }
            return ret;
        break;
        case LDAPMsg::SEARCH_ENTRY :
            return ret;
        break;
        case LDAPMsg::SEARCH_DONE :
            if(req->isReferral()){
                req->unbind();
            }
            switch ( ((LDAPResult*)ret)->getResultCode()) {
                case LDAPResult::REFERRAL :
                    if(constr->getReferralChase()){
                        //throws Exception (limit Exceeded)
                        LDAPRequest *refReq=chaseReferral(ret);
                        if(refReq != 0){
                            m_activeReq.pop();
                            m_activeReq.push(refReq);
                            m_issuedReq.push_back(refReq);
                            delete ret;
                            return getNext();
                        }
                    }    
                    return ret;
                break;
                case LDAPResult::SUCCESS :
                    if(req->isReferral()){
                        delete ret;
                        m_activeReq.pop();
                        return getNext();
                    }else{
                        m_activeReq.pop();
                        return ret;
                    }
                break;
                default:
                    m_activeReq.pop();
                    return ret;
                break;
            }
        break;
        //must be some kind of LDAPResultMessage
        default:
            if(req->isReferral()){
                req->unbind();
            }
            LDAPResult* res_p=(LDAPResult*)ret;
            switch (res_p->getResultCode()) {
                case LDAPResult::REFERRAL :
                    if(constr->getReferralChase()){
                        //throws Exception (limit Exceeded)
                        LDAPRequest *refReq=chaseReferral(ret);
                        if(refReq != 0){
                            m_activeReq.pop();
                            m_activeReq.push(refReq);
                            m_issuedReq.push_back(refReq);
                            delete ret;
                            return getNext();
                        }
                    }    
                    return ret;
                break;
                default:
                    m_activeReq.pop();
                    return ret;
            }
        break;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

For internal use only.

The referral chasing algorithm needs this method to see the currently active requests.

Definition at line 167 of file LDAPMessageQueue.cpp.

                                                   {
    DEBUG(LDAP_DEBUG_TRACE,"LDAPMessageQueue::getRequestStack()" << endl);
    return &m_activeReq;
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 68 of file LDAPMessageQueue.h.

Definition at line 69 of file LDAPMessageQueue.h.


The documentation for this class was generated from the following files: