MCPcopy
hub / github.com/shadowsocks/shadowsocks / _update_stream

Method _update_stream

shadowsocks/tcprelay.py:173–203  ·  view source on GitHub ↗
(self, stream, status)

Source from the content-addressed store, hash-verified

171 self._server.update_activity(self, data_len)
172
173 def _update_stream(self, stream, status):
174 # update a stream to a new waiting status
175
176 # check if status is changed
177 # only update if dirty
178 dirty = False
179 if stream == STREAM_DOWN:
180 if self._downstream_status != status:
181 self._downstream_status = status
182 dirty = True
183 elif stream == STREAM_UP:
184 if self._upstream_status != status:
185 self._upstream_status = status
186 dirty = True
187 if not dirty:
188 return
189
190 if self._local_sock:
191 event = eventloop.POLL_ERR
192 if self._downstream_status & WAIT_STATUS_WRITING:
193 event |= eventloop.POLL_OUT
194 if self._upstream_status & WAIT_STATUS_READING:
195 event |= eventloop.POLL_IN
196 self._loop.modify(self._local_sock, event)
197 if self._remote_sock:
198 event = eventloop.POLL_ERR
199 if self._downstream_status & WAIT_STATUS_READING:
200 event |= eventloop.POLL_IN
201 if self._upstream_status & WAIT_STATUS_WRITING:
202 event |= eventloop.POLL_OUT
203 self._loop.modify(self._remote_sock, event)
204
205 def _write_to_sock(self, data, sock):
206 # write data to sock

Callers 6

_write_to_sockMethod · 0.95
_handle_stage_addrMethod · 0.95
_handle_dns_resolvedMethod · 0.95
_on_local_writeMethod · 0.95
_on_remote_writeMethod · 0.95

Calls 1

modifyMethod · 0.45

Tested by

no test coverage detected