VirtualBox

Changeset 2440 in vbox for trunk


Ignore:
Timestamp:
Apr 30, 2007 3:55:21 PM (18 years ago)
Author:
vboxsync
Message:

XPCOM/IPC/DConnect: Improved: Prune all object instances created on behalf of a peer when it disconnects (normally or abnormally) to release affected objects.

Location:
trunk/src/libs/xpcom18a4/ipc/ipcd
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/ipc/ipcd/daemon/src/ipcd.cpp

    r1 r2440  
    118118IPC_NotifyClientUp(ipcClient *client)
    119119{
     120    LOG(("IPC_NotifyClientUp: clientID=%d\n", client->ID()));
     121
    120122    // notify modules before other clients
    121123    IPC_NotifyModulesClientUp(client);
     
    131133IPC_NotifyClientDown(ipcClient *client)
    132134{
     135    LOG(("IPC_NotifyClientDown: clientID=%d\n", client->ID()));
     136
    133137    // notify modules before other clients
    134138    IPC_NotifyModulesClientDown(client);
  • trunk/src/libs/xpcom18a4/ipc/ipcd/extensions/dconnect/src/ipcDConnectService.cpp

    r2109 r2440  
    6868
    6969// XXX TODO:
    70 //  1. add a client observer and prune mInstances when a peer disconnects
    71 //  2. add thread affinity field to SETUP messages
    72 //  3. support array parameters
     70//  1. add thread affinity field to SETUP messages
     71//  2. support array parameters
    7372
    7473//-----------------------------------------------------------------------------
     
    213212  nsISupports      *RealInstance()  { return mInstance; }
    214213  nsIInterfaceInfo *InterfaceInfo() { return mIInfo; }
     214  PRUint32          Peer()          { return mPeer; }
    215215
    216216  DConnectInstanceKey::Key GetKey() {
     
    22202220{
    22212221  // this method is to be called on ipcDConnectService shutdown only
    2222   // (after which no DConnectInstance's may exist), so forcedly delete them
     2222  // (after which no DConnectInstances may exist), so forcibly delete them
    22232223  // disregarding the reference counter
    22242224   
     
    26462646}
    26472647
     2648struct PruneInstanceMapForPeerArgs
     2649{
     2650  PRUint32 clientID;
     2651  DConnectInstanceMap &instances;
     2652  DConnectInstanceSet &instanceSet;
     2653};
     2654
     2655PR_STATIC_CALLBACK(PLDHashOperator)
     2656PruneInstanceMapForPeer (const DConnectInstanceKey::Key &aKey,
     2657                         DConnectInstance *aData,
     2658                         void *userArg)
     2659{
     2660  PruneInstanceMapForPeerArgs *args = (PruneInstanceMapForPeerArgs *)userArg;
     2661  NS_ASSERTION(args, "PruneInstanceMapForPeerArgs is NULL");
     2662
     2663  if (args && args->clientID == aData->Peer())
     2664  {
     2665#ifdef IPC_LOGGING
     2666    const char *name;
     2667    aData->InterfaceInfo()->GetNameShared(&name);
     2668    LOG(("PruneInstanceMapForClient(): instance=%p iface=%p {%s} peer=%d\n",
     2669         aData, aData->RealInstance(), name, args->clientID));
     2670#endif
     2671    args->instances.Remove(aKey);
     2672    args->instanceSet.Remove(aData);
     2673    /* ignore the reference counter: the client is officially dead */
     2674    delete aData;
     2675  }
     2676  return PL_DHASH_NEXT;
     2677}
     2678
    26482679NS_IMETHODIMP
    26492680ipcDConnectService::OnClientStateChange(PRUint32 aClientID,
    26502681                                        PRUint32 aClientState)
    26512682{
    2652   LOG (("ipcDConnectService::OnClientStateChange: aClientID=%d, aClientState=%d\n",
    2653         aClientID, aClientState));
    2654 
    2655   if (aClientID == IPC_SENDER_ANY)
    2656   {
     2683  LOG(("ipcDConnectService::OnClientStateChange: aClientID=%d, aClientState=%d\n",
     2684       aClientID, aClientState));
     2685
     2686  if (aClientState == ipcIClientObserver::CLIENT_DOWN)
     2687  {
     2688    if (aClientID == IPC_SENDER_ANY)
     2689    {
    26572690      // a special case: our IPC system is being shutdown, try to safely
    26582691      // uninitialize everything...
    26592692      Shutdown();
     2693    }
     2694    else
     2695    {
     2696      LOG(("ipcDConnectService::OnClientStateChange: "
     2697           "pruning all instances created for peer %d...\n", aClientID));
     2698
     2699      nsAutoLock lock (mLock);
     2700
     2701      // make sure we have released all instances
     2702      PruneInstanceMapForPeerArgs args = { aClientID, mInstances, mInstanceSet };
     2703      mInstances.EnumerateRead(PruneInstanceMapForPeer, (void *)&args);
     2704    }
    26602705  }
    26612706
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette