Skip to content

Commit 6697003

Browse files
committed
added buffer overflow
1 parent d091362 commit 6697003

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

locator.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11

2-
32
import time
43
import netutil
54
import collections
65

76

7+
BUFFER_SIZE = 5
8+
89
LEASE = 60
910

1011
gm = netutil.GrandMasterServer()
@@ -14,6 +15,8 @@
1415
Qs = collections.defaultdict(lambda:
1516
collections.defaultdict(lambda: []))
1617

18+
FAMILYQ = []
19+
1720

1821
def suggest(trace):
1922
part = str(trace)
@@ -38,6 +41,10 @@ def push(qname, net, value):
3841
l = Qs[qname][net]
3942
print l, value
4043
l.append(value)
44+
if len(l) > BUFFER_SIZE:
45+
for x in l:
46+
FAMILYQ.append(x)
47+
Qs[qname][net] = []
4148

4249
def pull(qname, net):
4350
print Qs
@@ -50,6 +57,8 @@ def pull(qname, net):
5057
return v
5158
else:
5259
print 'Nothing in local queue'
60+
if len(FAMILYQ) > 0:
61+
return FAMILYQ.pop(0)
5362
for k in Qs[qname].keys():
5463
if len(Qs[qname][k]) > 0:
5564
print 'Found something for: ', k

0 commit comments

Comments
 (0)