[repo] don't set cnxset when getting the session to close it
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 03 Apr 2014 18:09:57 +0200
changeset 9623 2171da5b9234
parent 9622 637a12b0d3a2
child 9624 a42fae4cd45a
[repo] don't set cnxset when getting the session to close it and avoid warning about that. session._cnx.rollback won't do anything if it's not set and a newer connection is now created to run the session_close hook, so there is not need to set cnxset. Notice we have to take care about not trying to rollback the underlying cnx when the session is not 'session_handled' (i.e. bw compat mode). This case only occurs due to hackish things to keep bw compat in testlib.
server/repository.py
server/session.py
--- a/server/repository.py	Wed Apr 02 12:38:02 2014 +0200
+++ b/server/repository.py	Thu Apr 03 18:09:57 2014 +0200
@@ -823,10 +823,11 @@
 
     def close(self, sessionid, txid=None, checkshuttingdown=True):
         """close the session with the given id"""
-        session = self._get_session(sessionid, setcnxset=True, txid=txid,
+        session = self._get_session(sessionid, txid=txid,
                                     checkshuttingdown=checkshuttingdown)
         # operation uncommited before close are rolled back before hook is called
-        session._cnx.rollback(free_cnxset=False)
+        if session._cnx._session_handled:
+            session._cnx.rollback(free_cnxset=False)
         with session.new_cnx() as cnx:
             self.hm.call_hooks('session_close', cnx)
             # commit connection at this point in case write operation has been
--- a/server/session.py	Wed Apr 02 12:38:02 2014 +0200
+++ b/server/session.py	Thu Apr 03 18:09:57 2014 +0200
@@ -1654,7 +1654,8 @@
         with self._lock:
             self._closed = True
         tracker.close()
-        self._rollback()
+        if self._cnx._session_handled:
+            self._rollback()
         self.debug('waiting for open connection of session: %s', self)
         timeout = 10
         pendings = tracker.wait(timeout)