MCPcopy Index your code
hub / github.com/sshuttle/sshuttle / gc

Method gc

sshuttle/methods/windivert.py:240–258  ·  view source on GitHub ↗
(self, connection_timeout_sec=15)

Source from the content-addressed store, hash-verified

238
239 @synchronized_method("rlock")
240 def gc(self, connection_timeout_sec=15):
241 # self.dump()
242 now = int(time.time())
243 n = 0
244 for i in tuple(self.used_slots):
245 state_packed = self.shm_list[i][-5:]
246 (state_epoch, state) = self.struct_state_tuple.unpack(state_packed)
247 if (now - state_epoch) < connection_timeout_sec:
248 continue
249 if ConnState.can_timeout(state):
250 conn = self._unpack(self.shm_list[i])
251 self.shm_list[i] = b""
252 self.used_slots.remove(i)
253 n += 1
254 debug3(
255 f"ConnTrack: GC: removed ({conn.protocol.name} src={conn.src_addr}:{conn.src_port} state={conn.state.name})"
256 f" from slot={i} | #ActiveConn={len(self.used_slots)}"
257 )
258 debug3(f"ConnTrack: GC: collected {n} connections | #ActiveConn={len(self.used_slots)}")
259
260 def _unpack(self, packed):
261 (

Callers 1

_connection_gcMethod · 0.80

Calls 4

_unpackMethod · 0.95
debug3Function · 0.90
can_timeoutMethod · 0.80
removeMethod · 0.80

Tested by

no test coverage detected