File tree Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -277,18 +277,25 @@ def done(self):
277
277
278
278
279
279
def expire_connections (now , mux ):
280
+ remove = []
280
281
for chan , timeout in dnsreqs .items ():
281
282
if timeout < now :
282
283
debug3 ('expiring dnsreqs channel=%d\n ' % chan )
284
+ remove .append (chan )
283
285
del mux .channels [chan ]
284
- del dnsreqs [chan ]
286
+ for chan in remove :
287
+ del dnsreqs [chan ]
285
288
debug3 ('Remaining DNS requests: %d\n ' % len (dnsreqs ))
289
+
290
+ remove = []
286
291
for peer , (chan , timeout ) in udp_by_src .items ():
287
292
if timeout < now :
288
293
debug3 ('expiring UDP channel channel=%d peer=%r\n ' % (chan , peer ))
289
294
mux .send (chan , ssnet .CMD_UDP_CLOSE , '' )
295
+ remove .append (peer )
290
296
del mux .channels [chan ]
291
- del udp_by_src [peer ]
297
+ for peer in remove :
298
+ del udp_by_src [peer ]
292
299
debug3 ('Remaining UDP channels: %d\n ' % len (udp_by_src ))
293
300
294
301
Original file line number Diff line number Diff line change @@ -328,14 +328,20 @@ def udp_open(channel, data):
328
328
329
329
if dnshandlers :
330
330
now = time .time ()
331
- for channel , h in list (dnshandlers .items ()):
331
+ remove = []
332
+ for channel , h in dnshandlers .items ():
332
333
if h .timeout < now or not h .ok :
333
334
debug3 ('expiring dnsreqs channel=%d\n ' % channel )
334
- del dnshandlers [ channel ]
335
+ remove . append ( channel )
335
336
h .ok = False
337
+ for channel in remove :
338
+ del dnshandlers [channel ]
336
339
if udphandlers :
337
- for channel , h in list (udphandlers .items ()):
340
+ remove = []
341
+ for channel , h in udphandlers .items ():
338
342
if not h .ok :
339
343
debug3 ('expiring UDP channel=%d\n ' % channel )
340
- del udphandlers [ channel ]
344
+ remove . append ( channel )
341
345
h .ok = False
346
+ for channel in remove :
347
+ del udphandlers [channel ]
You can’t perform that action at this time.
0 commit comments