diff options
| author | Tomás Touceda <chiiph@leap.se> | 2013-10-07 14:53:42 -0300 | 
|---|---|---|
| committer | Tomás Touceda <chiiph@leap.se> | 2013-10-07 15:55:55 -0300 | 
| commit | bf76ffa48a7d8e8993b9a61a259cc56829e1130f (patch) | |
| tree | 304e33bddce8493983d822daecea2ee4576f8c81 | |
| parent | 5548a0d9bcd2e49606a7c09f8ec1c3bc71287943 (diff) | |
Increase the max retries for the sessions in SRPAuth
| -rw-r--r-- | changes/bug_increase_retries_logout | 2 | ||||
| -rw-r--r-- | src/leap/bitmask/crypto/srpauth.py | 18 | 
2 files changed, 18 insertions, 2 deletions
| diff --git a/changes/bug_increase_retries_logout b/changes/bug_increase_retries_logout new file mode 100644 index 00000000..a3d1458b --- /dev/null +++ b/changes/bug_increase_retries_logout @@ -0,0 +1,2 @@ +  o Increase the amount of retries for the authentication request +    session. Fixes #4037.
\ No newline at end of file diff --git a/src/leap/bitmask/crypto/srpauth.py b/src/leap/bitmask/crypto/srpauth.py index cbff4b49..47ed21b0 100644 --- a/src/leap/bitmask/crypto/srpauth.py +++ b/src/leap/bitmask/crypto/srpauth.py @@ -25,6 +25,7 @@ import json  #this error is raised from requests  from simplejson.decoder import JSONDecodeError  from functools import partial +from requests.adapters import HTTPAdapter  from PySide import QtCore  from twisted.internet import threads @@ -154,7 +155,8 @@ class SRPAuth(QtCore.QObject):              self._ng = self._srp.NG_1024              # **************************************************** # -            self._session = self._fetcher.session() +            self._reset_session() +              self._session_id = None              self._session_id_lock = QtCore.QMutex()              self._uid = None @@ -172,6 +174,18 @@ class SRPAuth(QtCore.QObject):              self._username = None              self._password = None +        def _reset_session(self): +            """ +            Resets the current session and sets max retries to 30. +            """ +            self._session = self._fetcher.session() +            # We need to bump the default retries, otherwise logout +            # fails most of the times +            # NOTE: This is a workaround for the moment, the server +            # side seems to return correctly every time, but it fails +            # on the client end. +            self._session.mount('https://', HTTPAdapter(max_retries=30)) +          def _safe_unhexlify(self, val):              """              Rounds the val to a multiple of 2 and returns the @@ -508,7 +522,7 @@ class SRPAuth(QtCore.QObject):              self._username = username              self._password = password -            self._session = self._fetcher.session() +            self._reset_session()              d = threads.deferToThread(self._authentication_preprocessing,                                        username=username, | 
