Warning: Can't synchronize with repository "(default)" (/home/git/ome.git does not appear to be a Git repository.). Look in the Trac log for more information.
Notice: In order to edit this ticket you need to be either: a Product Owner, The owner or the reporter of the ticket, or, in case of a Task not yet assigned, a team_member"

Task #5723 (closed)

Opened 13 years ago

Closed 13 years ago

Bug: gateway setSecure may leak Communicators

Reported by: jamoore Owned by: wmoore
Priority: critical Milestone: OMERO-Beta4.3
Component: OmeroPy Version: n.a.
Keywords: n.a. Cc: python-team@…
Resources: n.a. Referenced By: n.a.
References: n.a. Remaining Time: 0.0d
Sprint: 2011-06-16 (14)

Description (last modified by jmoore)

The BlitzGateway.setSecure method should almost certainly call self.c.closeSession() (or self.c.__del__()) before re-assigning the self.c value.

    def setSecure (self, secure=True):
        """ 
        Switches between SSL and insecure (faster) connections to Blitz.
        The gateway must already be connected.
        
        @param secure:  If False, use an insecure connection
        @type secure:   Boolean
        """
        if hasattr(self.c, 'createClient') and (secure ^ self.c.isSecure()):
            self.c = self.c.createClient(secure=secure)
            self._createProxies()
            self.secure = secure

See: #2007 for the root cause of the leak.

Change History (6)

comment:1 Changed 13 years ago by jmoore

  • Owner set to wmoore
  • Priority changed from major to critical
  • Sprint set to 2011-06-16 (14)

Will, this is a quite easy fix, but is quite important. (I've gone over the repercussions with Carlos). If you'd like to discuss, please let me know.

comment:2 Changed 13 years ago by jmoore

  • Description modified (diff)

comment:3 Changed 13 years ago by wmoore

  • Status changed from new to accepted

comment:4 Changed 13 years ago by wmoore

Making either of the suggested changes, self.c.closeSession() or self.c.del() causes gateawaytest connection tests to fail...

    def setSecure (self, secure=True):
        """ 
        Switches between SSL and insecure (faster) connections to Blitz.
        The gateway must already be connected.
        
        @param secure:  If False, use an insecure connection
        @type secure:   Boolean
        """
        if hasattr(self.c, 'createClient') and (secure ^ self.c.isSecure()):
            #self.c.closeSession()
            self.c.__del__()
            self.c = self.c.createClient(secure=secure)
            self._createProxies()
            self.secure = secure

Test failures below - all tests fail:

wjm:OmeroPy will$ python test/gatewaytest/connection.py
Can not connect
ECan not connect
ECan not connect
ECan not connect
E
======================================================================
ERROR: testMiscellaneous (__main__.ConnectionMethodsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test/gatewaytest/connection.py", line 20, in setUp
    super(ConnectionMethodsTest, self).setUp()
  File "/Users/will/Desktop/OMERO/components/tools/OmeroPy/build/lib/omero/gateway/scripts/testdb_create.py", line 54, in setUp
    self.prepTestDB()
  File "/Users/will/Desktop/OMERO/components/tools/OmeroPy/build/lib/omero/gateway/scripts/testdb_create.py", line 126, in prepTestDB
    dbhelpers.bootstrap()
  File "/Users/will/Desktop/OMERO/components/tools/OmeroPy/build/lib/omero/gateway/scripts/dbhelpers.py", line 381, in bootstrap
    if not u.create(client):
  File "/Users/will/Desktop/OMERO/components/tools/OmeroPy/build/lib/omero/gateway/scripts/dbhelpers.py", line 127, in create
    a = client.getAdminService()
AttributeError: 'NoneType' object has no attribute 'getAdminService'

======================================================================
ERROR: testMultiProcessSession (__main__.ConnectionMethodsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test/gatewaytest/connection.py", line 20, in setUp
    super(ConnectionMethodsTest, self).setUp()
  File "/Users/will/Desktop/OMERO/components/tools/OmeroPy/build/lib/omero/gateway/scripts/testdb_create.py", line 54, in setUp
    self.prepTestDB()
  File "/Users/will/Desktop/OMERO/components/tools/OmeroPy/build/lib/omero/gateway/scripts/testdb_create.py", line 126, in prepTestDB
    dbhelpers.bootstrap()
  File "/Users/will/Desktop/OMERO/components/tools/OmeroPy/build/lib/omero/gateway/scripts/dbhelpers.py", line 381, in bootstrap
    if not u.create(client):
  File "/Users/will/Desktop/OMERO/components/tools/OmeroPy/build/lib/omero/gateway/scripts/dbhelpers.py", line 127, in create
    a = client.getAdminService()
AttributeError: 'NoneType' object has no attribute 'getAdminService'

======================================================================
ERROR: testSeppuku (__main__.ConnectionMethodsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test/gatewaytest/connection.py", line 20, in setUp
    super(ConnectionMethodsTest, self).setUp()
  File "/Users/will/Desktop/OMERO/components/tools/OmeroPy/build/lib/omero/gateway/scripts/testdb_create.py", line 54, in setUp
    self.prepTestDB()
  File "/Users/will/Desktop/OMERO/components/tools/OmeroPy/build/lib/omero/gateway/scripts/testdb_create.py", line 126, in prepTestDB
    dbhelpers.bootstrap()
  File "/Users/will/Desktop/OMERO/components/tools/OmeroPy/build/lib/omero/gateway/scripts/dbhelpers.py", line 381, in bootstrap
    if not u.create(client):
  File "/Users/will/Desktop/OMERO/components/tools/OmeroPy/build/lib/omero/gateway/scripts/dbhelpers.py", line 127, in create
    a = client.getAdminService()
AttributeError: 'NoneType' object has no attribute 'getAdminService'

======================================================================
ERROR: testTopLevelObjects (__main__.ConnectionMethodsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test/gatewaytest/connection.py", line 20, in setUp
    super(ConnectionMethodsTest, self).setUp()
  File "/Users/will/Desktop/OMERO/components/tools/OmeroPy/build/lib/omero/gateway/scripts/testdb_create.py", line 54, in setUp
    self.prepTestDB()
  File "/Users/will/Desktop/OMERO/components/tools/OmeroPy/build/lib/omero/gateway/scripts/testdb_create.py", line 126, in prepTestDB
    dbhelpers.bootstrap()
  File "/Users/will/Desktop/OMERO/components/tools/OmeroPy/build/lib/omero/gateway/scripts/dbhelpers.py", line 381, in bootstrap
    if not u.create(client):
  File "/Users/will/Desktop/OMERO/components/tools/OmeroPy/build/lib/omero/gateway/scripts/dbhelpers.py", line 127, in create
    a = client.getAdminService()
AttributeError: 'NoneType' object has no attribute 'getAdminService'

----------------------------------------------------------------------
Ran 4 tests in 2.000s

FAILED (errors=4)
wjm:OmeroPy will$ 

comment:5 Changed 13 years ago by jmoore

Can't close the session while you still need it. Maybe something like:

        if hasattr(self.c, 'createClient') and (secure ^ self.c.isSecure()):
            oldC = self.c
            self.c = oldC.createClient(secure=secure)
            oldC.__del__() # only needs to be called if previous doesn't throw
            self._createProxies()
            self.secure = secure

comment:6 Changed 13 years ago by Will Moore <will@…>

  • Remaining Time set to 0
  • Resolution set to fixed
  • Status changed from accepted to closed

(In [8d81854f9529f76685f85abc6209f8db91af0f53/ome.git] on branch develop) Old connections deleted in Blitz setSecure(). Closes #5723

Note: See TracTickets for help on using tickets. You may also have a look at Agilo extensions to the ticket.

1.3.13-PRO © 2008-2011 Agilo Software all rights reserved (this page was served in: 0.68712 sec.)

We're Hiring!