VirtualBox

Changeset 47561 in vbox for trunk/src/VBox/Main/include


Ignore:
Timestamp:
Aug 6, 2013 3:18:17 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
87761
Message:

Main/VirtualBox+Machine+Session: separate out the client death detection functionality into separate objects

Location:
trunk/src/VBox/Main/include
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/MachineImpl.h

    r47409 r47561  
    783783    }
    784784
    785 #if defined(RT_OS_WINDOWS)
    786 
    787     bool isSessionOpen(ComObjPtr<SessionMachine> &aMachine,
    788                        ComPtr<IInternalSessionControl> *aControl = NULL,
    789                        HANDLE *aIPCSem = NULL, bool aAllowClosing = false);
    790     bool isSessionSpawning(RTPROCESS *aPID = NULL);
    791 
    792     bool isSessionOpenOrClosing(ComObjPtr<SessionMachine> &aMachine,
    793                                 ComPtr<IInternalSessionControl> *aControl = NULL,
    794                                 HANDLE *aIPCSem = NULL)
    795     { return isSessionOpen(aMachine, aControl, aIPCSem, true /* aAllowClosing */); }
    796 
    797 #elif defined(RT_OS_OS2)
    798 
    799     bool isSessionOpen(ComObjPtr<SessionMachine> &aMachine,
    800                        ComPtr<IInternalSessionControl> *aControl = NULL,
    801                        HMTX *aIPCSem = NULL, bool aAllowClosing = false);
    802 
    803     bool isSessionSpawning(RTPROCESS *aPID = NULL);
    804 
    805     bool isSessionOpenOrClosing(ComObjPtr<SessionMachine> &aMachine,
    806                                  ComPtr<IInternalSessionControl> *aControl = NULL,
    807                                  HMTX *aIPCSem = NULL)
    808     { return isSessionOpen(aMachine, aControl, aIPCSem, true /* aAllowClosing */); }
    809 
    810 #else
    811 
    812785    bool isSessionOpen(ComObjPtr<SessionMachine> &aMachine,
    813786                       ComPtr<IInternalSessionControl> *aControl = NULL,
     
    819792    { return isSessionOpen(aMachine, aControl, true /* aAllowClosing */); }
    820793
    821 #endif
    822 
    823794    bool checkForSpawnFailure();
    824795
     
    848819
    849820protected:
     821
     822    class ClientToken;
    850823
    851824    HRESULT checkStateDependency(StateDependency aDepType);
     
    10751048    STDMETHOD(SetRemoveSavedStateFile)(BOOL aRemove);
    10761049    STDMETHOD(UpdateState)(MachineState_T machineState);
    1077     STDMETHOD(GetIPCId)(BSTR *id);
    10781050    STDMETHOD(BeginPowerUp)(IProgress *aProgress);
    10791051    STDMETHOD(EndPowerUp)(LONG iResult);
     
    11341106    bool checkForDeath();
    11351107
     1108    void getTokenId(Utf8Str &strTokenId);
     1109    // getClientToken must be only used by callers who can guarantee that
     1110    // the object cannot be deleted in the mean time, i.e. have a caller/lock.
     1111    ClientToken *getClientToken();
     1112
    11361113    HRESULT onNetworkAdapterChange(INetworkAdapter *networkAdapter, BOOL changeAdapter);
    11371114    HRESULT onNATRedirectRuleChange(ULONG ulSlot, BOOL aNatRuleRemove, IN_BSTR aRuleName,
     
    12361213    ConsoleTaskData mConsoleTaskData;
    12371214
    1238     /** interprocess semaphore handle for this machine */
    1239 #if defined(RT_OS_WINDOWS)
    1240     HANDLE mIPCSem;
    1241     Bstr mIPCSemName;
    1242     friend bool Machine::isSessionOpen(ComObjPtr<SessionMachine> &aMachine,
    1243                                        ComPtr<IInternalSessionControl> *aControl,
    1244                                        HANDLE *aIPCSem, bool aAllowClosing);
    1245 #elif defined(RT_OS_OS2)
    1246     HMTX mIPCSem;
    1247     Bstr mIPCSemName;
    1248     friend bool Machine::isSessionOpen(ComObjPtr<SessionMachine> &aMachine,
    1249                                        ComPtr<IInternalSessionControl> *aControl,
    1250                                        HMTX *aIPCSem, bool aAllowClosing);
    1251 #elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER)
    1252     int mIPCSem;
    1253 # ifdef VBOX_WITH_NEW_SYS_V_KEYGEN
    1254     Bstr mIPCKey;
    1255 # endif /*VBOX_WITH_NEW_SYS_V_KEYGEN */
    1256 #else
    1257 # error "Port me!"
    1258 #endif
     1215    /** client token for this machine */
     1216    ClientToken *mClientToken;
    12591217
    12601218    static DECLCALLBACK(int) taskHandler(RTTHREAD thread, void *pvUser);
  • trunk/src/VBox/Main/include/SessionImpl.h

    r46775 r47561  
    2424#ifdef RT_OS_WINDOWS
    2525# include "win/resource.h"
    26 #endif
    27 
    28 /** @def VBOX_WITH_SYS_V_IPC_SESSION_WATCHER
    29  *  Use SYS V IPC for watching a session.
    30  *  This is defined in the Makefile since it's also used by MachineImpl.h/cpp.
    31  */
    32 #ifdef DOXYGEN_RUNNING
    33 # define VBOX_WITH_SYS_V_IPC_SESSION_WATCHER
    3426#endif
    3527
     
    8173    STDMETHOD(GetPID)(ULONG *aPid);
    8274    STDMETHOD(GetRemoteConsole)(IConsole **aConsole);
    83     STDMETHOD(AssignMachine)(IMachine *aMachine, LockType_T aLockType);
     75    STDMETHOD(AssignMachine)(IMachine *aMachine, LockType_T aLockType, IN_BSTR aTokenId);
    8476    STDMETHOD(AssignRemoteMachine)(IMachine *aMachine, IConsole *aConsole);
    8577    STDMETHOD(UpdateMachineState)(MachineState_T aMachineState);
     
    124116
    125117    HRESULT unlockMachine(bool aFinalRelease, bool aFromServer);
    126     HRESULT grabIPCSemaphore();
    127     void releaseIPCSemaphore();
    128118
    129119    SessionState_T mState;
     
    139129    ComPtr<IVirtualBox> mVirtualBox;
    140130
    141     /* interprocess semaphore handle (id) for the opened machine */
    142 #if defined(RT_OS_WINDOWS)
    143     HANDLE mIPCSem;
    144     HANDLE mIPCThreadSem;
    145 #elif defined(RT_OS_OS2)
    146     RTTHREAD mIPCThread;
    147     RTSEMEVENT mIPCThreadSem;
    148 #elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER)
    149     int mIPCSem;
    150 #else
    151 # error "Port me!"
    152 #endif
     131    class ClientTokenHolder;
     132
     133    ClientTokenHolder *mClientTokenHolder;
    153134};
    154135
  • trunk/src/VBox/Main/include/VirtualBoxImpl.h

    r47525 r47561  
    2020
    2121#include "VirtualBoxBase.h"
     22#include "objectslist.h"
    2223
    2324#ifdef RT_OS_WINDOWS
     
    3334class SessionMachine;
    3435class GuestOSType;
    35 class SharedFolder;
    3636class Progress;
    3737class Host;
     
    3939class DHCPServer;
    4040class PerformanceCollector;
    41 class VirtualBoxCallbackRegistration; /* see VirtualBoxImpl.cpp */
    4241#ifdef VBOX_WITH_EXTPACK
    4342class ExtPackManager;
     
    5251class SVCHlpClient;
    5352#endif
    54 
    55 struct VMClientWatcherData;
    5653
    5754namespace settings
     
    7168
    7269    typedef std::list<ComPtr<IInternalSessionControl> > InternalControlList;
     70    typedef ObjectsList<Machine> MachinesOList;
    7371
    7472    class CallbackEvent;
     
    216214    void onGuestPropertyChange(const Guid &aMachineId, IN_BSTR aName, IN_BSTR aValue,
    217215                               IN_BSTR aFlags);
    218     void onMachineUninit(Machine *aMachine);
    219216    void onNatRedirectChange(const Guid &aMachineId, ULONG ulSlot, bool fRemove, IN_BSTR aName,
    220217                                   NATProtocol_T aProto, IN_BSTR aHostIp, uint16_t aHostPort,
     
    234231    void getOpenedMachines(SessionMachinesList &aMachines,
    235232                           InternalControlList *aControls = NULL);
     233    MachinesOList &getMachinesList();
    236234
    237235    HRESULT findMachine(const Guid &aId,
     
    322320
    323321private:
     322    class ClientWatcher;
    324323
    325324    static HRESULT setErrorStatic(HRESULT aResultCode,
     
    361360    static Bstr sAPIVersion;
    362361
    363     static DECLCALLBACK(int) ClientWatcher(RTTHREAD thread, void *pvUser);
    364362    static DECLCALLBACK(int) AsyncEventHandler(RTTHREAD thread, void *pvUser);
    365363
Note: See TracChangeset for help on using the changeset viewer.

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