VirtualBox

Changeset 61365 in vbox


Ignore:
Timestamp:
Jun 1, 2016 11:23:47 AM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
107667
Message:

Main/glue-java.xsl: Addendum for r107491, make sure there is only a single object manager instance for all VirtualBoxManager instances or unregistering objects might end up with the wrong hash map if there is more than one VirtualBoxManager instance

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/glue/glue-java.xsl

    r61203 r61365  
    45434543    private final static ReferenceQueue<IUnknown> refQ = new ReferenceQueue<IUnknown>();
    45444544
    4545     private final VboxPortType port;
    45464545    private final ConcurrentMap<String, ManagedObj> map = new ConcurrentHashMap<String, ManagedObj>();
    45474546    private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
    45484547    private final ObjRefMgrCleanupThread objRefMgrCleanup;
    45494548
    4550     public ObjectRefManager(VboxPortType port)
    4551     {
    4552         this.port = port;
     4549    public ObjectRefManager()
     4550    {
    45534551        this.objRefMgrCleanup = new ObjRefMgrCleanupThread(this, 100);
    45544552        this.objRefMgrCleanup.start();
     
    45974595    public void registerObj(IUnknown obj)
    45984596    {
     4597        assert lock.getReadLockCount() > 0;
    45994598        ManagedObjRef ref = new ManagedObjRef(obj);
    46004599
     
    46074606        {
    46084607            /* Create new. */
    4609             mgrobj = new ManagedObj(obj.getWrapped());
     4608            mgrobj = new ManagedObj(obj.getWrapped(), obj.getRemoteWSPort());
    46104609            mgrobj.addObject(ref);
    46114610            map.put(obj.getWrapped(), mgrobj);
     
    46214620    public ManagedObj unregisterObj(ManagedObjRef objRef)
    46224621    {
    4623         assert lock.isWriteLockedByCurrentThread();
    4624 
    46254622        ManagedObj obj = this.map.get(objRef.objId);
    46264623
     
    46354632    public void releaseRemoteObj(ManagedObj obj)
    46364633    {
     4634        assert lock.isWriteLockedByCurrentThread();
     4635
    46374636        if (!obj.isReferenced())
    46384637        {
    46394638            try
    46404639            {
    4641                 this.port.iManagedObjectRefRelease(obj.objId);
     4640                obj.port.iManagedObjectRefRelease(obj.objId);
    46424641            }
    46434642            catch (InvalidObjectFaultMsg e)
     
    46634662    {
    46644663        private final String                               objId;
     4664        private final VboxPortType                         port;
    46654665        private final ConcurrentLinkedQueue<ManagedObjRef> refQ;
    46664666
    4667         ManagedObj(String objId)
     4667        ManagedObj(String objId,  VboxPortType port)
    46684668        {
    46694669          this.objId = objId;
     4670          this.port  = port;
    46704671          this.refQ  = new ConcurrentLinkedQueue<ManagedObjRef>();
    46714672        }
     
    48974898{
    48984899    private static PortPool pool = new PortPool(true);
     4900    private static final ObjectRefManager objMgr = new ObjectRefManager();
    48994901    protected VboxPortType port;
    49004902
    49014903    private IVirtualBox vbox;
    4902     private ObjectRefManager objMgr;
    49034904
    49044905    private VirtualBoxManager()
     
    49174918    {
    49184919        this.port = pool.getPort();
    4919         this.objMgr = new ObjectRefManager(this.port);
    49204920        try
    49214921        {
     
    49384938
    49394939            String handle = port.iWebsessionManagerLogon(username, passwd);
    4940             this.vbox = new IVirtualBox(handle, this.objMgr, port);
     4940            this.objMgr.preventObjRelease();
     4941            try
     4942            {
     4943                this.vbox = new IVirtualBox(handle, this.objMgr, port);
     4944            }
     4945            finally
     4946            {
     4947                this.objMgr.allowObjRelease();
     4948            }
    49414949        }
    49424950        catch (Throwable t)
     
    49564964    {
    49574965        this.port = pool.getPort();
    4958         this.objMgr = new ObjectRefManager(this.port);
    4959 
    49604966        try
    49614967        {
     
    49704976                put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);
    49714977            String handle = port.iWebsessionManagerLogon(username, passwd);
    4972             this.vbox = new IVirtualBox(handle, this.objMgr, port);
     4978            this.objMgr.preventObjRelease();
     4979            try
     4980            {
     4981                this.vbox = new IVirtualBox(handle, this.objMgr, port);
     4982            }
     4983            finally
     4984            {
     4985                this.objMgr.allowObjRelease();
     4986            }
    49734987        }
    49744988        catch (Throwable t)
     
    50315045        {
    50325046            String handle = port.iWebsessionManagerGetSessionObject(this.vbox.getWrapped());
    5033             return new ISession(handle, this.objMgr, port);
     5047            this.objMgr.preventObjRelease();
     5048            try
     5049            {
     5050                return new ISession(handle, this.objMgr, port);
     5051            }
     5052            finally
     5053            {
     5054                this.objMgr.allowObjRelease();
     5055            }
    50345056        }
    50355057        catch (InvalidObjectFaultMsg e)
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