@@ -15,26 +15,26 @@ cdef _create_transport_context(server_side, server_hostname):
15
15
cdef object READ_MAX_SIZE = 256 * 1024
16
16
17
17
18
- class _SSLProtocolTransport :
18
+ cdef class _SSLProtocolTransport:
19
19
20
20
# TODO:
21
21
# _sendfile_compatible = constants._SendfileMode.FALLBACK
22
22
23
- def __init__ (self , loop , ssl_protocol ):
23
+ def __cinit__ (self , loop , ssl_protocol ):
24
24
self ._loop = loop
25
25
# SSLProtocol instance
26
26
self ._ssl_protocol = ssl_protocol
27
27
self ._closed = False
28
28
29
29
def get_extra_info (self , name , default = None ):
30
30
""" Get optional transport information."""
31
- return ( < SSLProtocol > self ._ssl_protocol) ._get_extra_info(name, default)
31
+ return self ._ssl_protocol._get_extra_info(name, default)
32
32
33
33
def set_protocol (self , protocol ):
34
- ( < SSLProtocol > self ._ssl_protocol) ._set_app_protocol(protocol)
34
+ self ._ssl_protocol._set_app_protocol(protocol)
35
35
36
36
def get_protocol (self ):
37
- return ( < SSLProtocol > self ._ssl_protocol) ._app_protocol
37
+ return self ._ssl_protocol._app_protocol
38
38
39
39
def is_closing (self ):
40
40
return self ._closed
@@ -48,33 +48,33 @@ class _SSLProtocolTransport:
48
48
with None as its argument.
49
49
"""
50
50
self ._closed = True
51
- ( < SSLProtocol > self ._ssl_protocol) ._start_shutdown()
51
+ self ._ssl_protocol._start_shutdown()
52
52
53
- def __del__ (self ):
53
+ def __dealloc__ (self ):
54
54
if not self ._closed:
55
55
_warn_with_source(
56
56
" unclosed transport {!r}" .format(self ),
57
57
ResourceWarning, self )
58
- self .close()
58
+ self ._closed = True
59
59
60
60
def is_reading (self ):
61
- return not ( < SSLProtocol > self ._ssl_protocol) ._app_reading_paused
61
+ return not self ._ssl_protocol._app_reading_paused
62
62
63
63
def pause_reading (self ):
64
64
""" Pause the receiving end.
65
65
66
66
No data will be passed to the protocol's data_received()
67
67
method until resume_reading() is called.
68
68
"""
69
- ( < SSLProtocol > self ._ssl_protocol) ._pause_reading()
69
+ self ._ssl_protocol._pause_reading()
70
70
71
71
def resume_reading (self ):
72
72
""" Resume the receiving end.
73
73
74
74
Data received will once again be passed to the protocol's
75
75
data_received() method.
76
76
"""
77
- ( < SSLProtocol > self ._ssl_protocol) ._resume_reading()
77
+ self ._ssl_protocol._resume_reading()
78
78
79
79
def set_write_buffer_limits (self , high = None , low = None ):
80
80
""" Set the high- and low-water limits for write flow control.
@@ -95,16 +95,16 @@ class _SSLProtocolTransport:
95
95
reduces opportunities for doing I/O and computation
96
96
concurrently.
97
97
"""
98
- ( < SSLProtocol > self ._ssl_protocol) ._set_write_buffer_limits(high, low)
99
- ( < SSLProtocol > self ._ssl_protocol) ._control_app_writing()
98
+ self ._ssl_protocol._set_write_buffer_limits(high, low)
99
+ self ._ssl_protocol._control_app_writing()
100
100
101
101
def get_write_buffer_limits (self ):
102
- return (( < SSLProtocol > self ._ssl_protocol) ._outgoing_low_water,
103
- ( < SSLProtocol > self ._ssl_protocol) ._outgoing_high_water)
102
+ return (self ._ssl_protocol._outgoing_low_water,
103
+ self ._ssl_protocol._outgoing_high_water)
104
104
105
105
def get_write_buffer_size (self ):
106
106
""" Return the current size of the write buffers."""
107
- return ( < SSLProtocol > self ._ssl_protocol) ._get_write_buffer_size()
107
+ return self ._ssl_protocol._get_write_buffer_size()
108
108
109
109
def set_read_buffer_limits (self , high = None , low = None ):
110
110
""" Set the high- and low-water limits for read flow control.
@@ -125,21 +125,21 @@ class _SSLProtocolTransport:
125
125
reduces opportunities for doing I/O and computation
126
126
concurrently.
127
127
"""
128
- ( < SSLProtocol > self ._ssl_protocol) ._set_read_buffer_limits(high, low)
129
- ( < SSLProtocol > self ._ssl_protocol) ._control_ssl_reading()
128
+ self ._ssl_protocol._set_read_buffer_limits(high, low)
129
+ self ._ssl_protocol._control_ssl_reading()
130
130
131
131
def get_read_buffer_limits (self ):
132
- return (( < SSLProtocol > self ._ssl_protocol) ._incoming_low_water,
133
- ( < SSLProtocol > self ._ssl_protocol) ._incoming_high_water)
132
+ return (self ._ssl_protocol._incoming_low_water,
133
+ self ._ssl_protocol._incoming_high_water)
134
134
135
135
def get_read_buffer_size (self ):
136
136
""" Return the current size of the read buffer."""
137
- return ( < SSLProtocol > self ._ssl_protocol) ._get_read_buffer_size()
137
+ return self ._ssl_protocol._get_read_buffer_size()
138
138
139
139
@property
140
140
def _protocol_paused (self ):
141
141
# Required for sendfile fallback pause_writing/resume_writing logic
142
- return ( < SSLProtocol > self ._ssl_protocol) ._app_writing_paused
142
+ return self ._ssl_protocol._app_writing_paused
143
143
144
144
def write (self , data ):
145
145
""" Write some data bytes to the transport.
@@ -152,15 +152,15 @@ class _SSLProtocolTransport:
152
152
f" got {type(data).__name__}" )
153
153
if not data:
154
154
return
155
- ( < SSLProtocol > self ._ssl_protocol) ._write_appdata((data,))
155
+ self ._ssl_protocol._write_appdata((data,))
156
156
157
157
def writelines (self , list_of_data ):
158
158
""" Write a list (or any iterable) of data bytes to the transport.
159
159
160
160
The default implementation concatenates the arguments and
161
161
calls write() on the result.
162
162
"""
163
- ( < SSLProtocol > self ._ssl_protocol) ._write_appdata(list_of_data)
163
+ self ._ssl_protocol._write_appdata(list_of_data)
164
164
165
165
def write_eof (self ):
166
166
""" Close the write end after flushing buffered data.
@@ -184,7 +184,12 @@ class _SSLProtocolTransport:
184
184
185
185
def _force_close (self , exc ):
186
186
self ._closed = True
187
- (< SSLProtocol> self ._ssl_protocol)._abort(exc)
187
+ self ._ssl_protocol._abort(exc)
188
+
189
+ def _test__append_write_backlog (self , data ):
190
+ # for test only
191
+ self ._ssl_protocol._write_backlog.append(data)
192
+ self ._ssl_protocol._write_buffer_size += len (data)
188
193
189
194
190
195
cdef class SSLProtocol:
@@ -318,7 +323,7 @@ cdef class SSLProtocol:
318
323
self ._outgoing_read()
319
324
self ._conn_lost += 1
320
325
321
- # Just mark the app transport as closed so that its __del__
326
+ # Just mark the app transport as closed so that its __dealloc__
322
327
# doesn't complain.
323
328
if self ._app_transport is not None :
324
329
self ._app_transport._closed = True
@@ -600,11 +605,6 @@ cdef class SSLProtocol:
600
605
except Exception as ex:
601
606
self ._fatal_error(ex, ' Fatal error on SSL protocol' )
602
607
603
- def _test__append_write_backlog (self , data ):
604
- # for test only
605
- self ._write_backlog.append(data)
606
- self ._write_buffer_size += len (data)
607
-
608
608
cdef _do_write(self ):
609
609
cdef size_t data_len, count
610
610
try :
0 commit comments