[PyOpenSSL branch]

- Close connection after creating account. Fixes #2676
- Handle normal connection close by server. Fixes #2671
- Do not disconnect if we haven't received starttag yet. Fixes #2668. Fixes unticketed bug causing account creation not to work with PyOpenSSL and asynchronous handshake (see also #2671). Behaviour of #2634 is also improved but now results in deadlock.
This commit is contained in:
junglecow 2006-11-18 15:09:40 +00:00
parent 321020751d
commit 3c77ffd406
3 changed files with 23 additions and 4 deletions

View File

@ -131,7 +131,7 @@ class Dispatcher(PlugIn):
try:
self.Stream.Parse(data)
# end stream:stream tag received
if self.Stream and self.Stream._NodeBuilder__depth == 0:
if self.Stream and self.Stream.has_received_endtag():
self._owner.Connection.disconnect()
return 0
except ExpatError:
@ -141,6 +141,7 @@ class Dispatcher(PlugIn):
if len(self._pendingExceptions) > 0:
_pendingException = self._pendingExceptions.pop()
raise _pendingException[0], _pendingException[1], _pendingException[2]
if len(data) == 0: return '0'
return len(data)
def RegisterNamespace(self, xmlns, order='info'):

View File

@ -290,6 +290,8 @@ class NodeBuilder:
self.Parse = self._parser.Parse
self.__depth = 0
self.__last_depth = 0
self.__max_depth = 0
self._dispatch_depth = 1
self._document_attrs = None
self._mini_dom=initial_node
@ -326,7 +328,7 @@ class NodeBuilder:
ns=attr[:sp] #
attrs[self.namespaces[ns]+attr[sp+1:]]=attrs[attr]
del attrs[attr] #
self.__depth += 1
self._inc_depth()
self.DEBUG(DBG_NODEBUILDER, "DEPTH -> %i , tag -> %s, attrs -> %s" % (self.__depth, tag, `attrs`), 'down')
if self.__depth == self._dispatch_depth:
if not self._mini_dom :
@ -354,7 +356,7 @@ class NodeBuilder:
self._ptr = self._ptr.parent
else:
self.DEBUG(DBG_NODEBUILDER, "Got higher than dispatch level. Stream terminated?", 'stop')
self.__depth -= 1
self._dec_depth()
self.last_is_data = 0
if self.__depth == 0: self.stream_footer_received()
@ -387,6 +389,19 @@ class NodeBuilder:
""" Method called when stream just closed. """
self.check_data_buffer()
def has_received_endtag(self, level=0):
""" Return True if at least one end tag was seen (at level) """
return self.__depth <= level and self.__max_depth > level
def _inc_depth(self):
self.__last_depth = self.__depth
self.__depth += 1
self.__max_depth = max(self.__depth, self.__max_depth)
def _dec_depth(self):
self.__last_depth = self.__depth
self.__depth -= 1
def XML2Node(xml):
""" Converts supplied textual string into XML node. Handy f.e. for reading configuration file.
Raises xml.parser.expat.parsererror if provided string is not well-formed XML. """

View File

@ -650,9 +650,12 @@ class NonBlockingTLS(PlugIn):
#print "Done handshake"
print "Async handshake started..."
# fake it, for now
self.starttls='success'
def _on_ssl_handshake_done(self):
print "Handshake done!"
self.starttls='success'
#self.starttls='success'
tcpsock = self._owner.Connection
cert = tcpsock._sslObj.get_peer_certificate()