@@ -253,7 +253,6 @@ cdef class SSLProtocol:
253
253
self ._app_transport_created = False
254
254
# transport, ex: SelectorSocketTransport
255
255
self ._transport = None
256
- self ._call_connection_made = call_connection_made
257
256
self ._ssl_handshake_timeout = ssl_handshake_timeout
258
257
self ._ssl_shutdown_timeout = ssl_shutdown_timeout
259
258
# SSL and state machine
@@ -264,7 +263,7 @@ cdef class SSLProtocol:
264
263
self ._outgoing_read = self ._outgoing.read
265
264
self ._state = UNWRAPPED
266
265
self ._conn_lost = 0 # Set when connection_lost called
267
- self ._eof_received = False
266
+ self ._app_state = START if call_connection_made else AFTER_CM
268
267
269
268
# Flow Control
270
269
@@ -335,7 +334,9 @@ cdef class SSLProtocol:
335
334
self ._app_transport._closed = True
336
335
337
336
if self ._state != DO_HANDSHAKE:
338
- self ._loop.call_soon(self ._app_protocol.connection_lost, exc)
337
+ if self ._app_state == AFTER_CM or self ._app_state == AFTER_ER:
338
+ self ._app_state = END
339
+ self ._loop.call_soon(self ._app_protocol.connection_lost, exc)
339
340
self ._set_state(UNWRAPPED)
340
341
self ._transport = None
341
342
self ._app_transport = None
@@ -518,7 +519,8 @@ cdef class SSLProtocol:
518
519
cipher = sslobj.cipher(),
519
520
compression = sslobj.compression(),
520
521
ssl_object = sslobj)
521
- if self ._call_connection_made:
522
+ if self ._app_state == START:
523
+ self ._app_state = AFTER_CM
522
524
self ._app_protocol.connection_made(self ._get_app_transport())
523
525
self ._wakeup_waiter()
524
526
self ._do_read()
@@ -735,8 +737,8 @@ cdef class SSLProtocol:
735
737
736
738
cdef _call_eof_received(self ):
737
739
try :
738
- if not self ._eof_received :
739
- self ._eof_received = True
740
+ if self ._app_state == AFTER_CM :
741
+ self ._app_state = AFTER_ER
740
742
keep_open = self ._app_protocol.eof_received()
741
743
if keep_open:
742
744
aio_logger.warning(' returning true from eof_received() '
0 commit comments