Logo Search packages:      
Sourcecode: virtualbox-ose version File versions

PRInt32 tmQueue::AttachClient ( PRUint32  aClientID  ) 

Adds the clientID to the list of queue listeners. A reply is created and sent to the client. The reply contains both the name of the queue and the id, so the client can match the id to the name and then use the id in all further communications to the queue. All current transactions in the queue are then sent to the client.

If the client was already attached the reply is sent, but not the outstanding transactions, the assumption being made that all transactions have already been sent to the client.

The reply is sent for all cases, with the return value in the status field.

>= 0 if the client was attached successfully

-1 if the client was not attached

-2 if the client was already attached

Definition at line 84 of file tmQueue.cpp.

References tmVector::Append(), tmTransaction::Init(), IsAttached(), tmTransactionManager::SendTransaction(), and tmVector::Size().

Referenced by tmTransactionManager::HandleTransaction().


  PRInt32 status = NS_OK;                 // success of adding client

  if (!IsAttached(aClientID)) {
    // add the client to the listener list -- null safe call
    status = mListeners.Append((void*) aClientID);
    status = -2;

  // create & init a reply transaction
  tmTransaction trans;
  if (NS_SUCCEEDED(trans.Init(aClientID,        // owner's ipc ID
                              mID,              // client gets our ID
                              TM_ATTACH_REPLY,  // action
                              status,           // success of the add
                              (PRUint8*)mName,  // client matches name to ID
                              PL_strlen(mName)+1))) {
    // send the reply
    mTM->SendTransaction(aClientID, &trans);

  // if we successfully added the client - send all current transactions
  if (status >= 0) { // append returns the index of the added element
    PRUint32 size = mTransactions.Size();
    for (PRUint32 index = 0; index < size; index++) {
      if (mTransactions[index])
        mTM->SendTransaction(aClientID, (tmTransaction*) mTransactions[index]);
  return status;

Generated by  Doxygen 1.6.0   Back to index