(self, connection_timeout_sec=15)
| 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 | ( |
no test coverage detected