summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorTeddy <[email protected]>2013-08-29 18:43:36 +0800
committerTeddy <[email protected]>2013-08-29 18:43:36 +0800
commitd863b8381584e5ff2785d7e573c4f703270627f3 (patch)
treeac4af8dfb94d12baabaab0b110da98d2554819fd /server
parent88894471c3d35bb9d25cf416bee07b08641c3149 (diff)
limit the size of pending queues
Diffstat (limited to 'server')
-rw-r--r--server/piztor/mesg_sender.py1
-rw-r--r--server/piztor/server.py7
2 files changed, 7 insertions, 1 deletions
diff --git a/server/piztor/mesg_sender.py b/server/piztor/mesg_sender.py
index 64349a3..96a3a9d 100644
--- a/server/piztor/mesg_sender.py
+++ b/server/piztor/mesg_sender.py
@@ -24,4 +24,5 @@ send_text_mesg(token, username, mesg)
send_text_mesg(token, username, "a")
update_location(token, username, 1.2345, 2.468)
update_location(token, username, 1.2345, 2.468)
+send_text_mesg(token, username, "the last")
#logout(token, username)
diff --git a/server/piztor/server.py b/server/piztor/server.py
index 1814a39..ed4e0b9 100644
--- a/server/piztor/server.py
+++ b/server/piztor/server.py
@@ -52,6 +52,8 @@ _HEADER_SIZE = _SectionSize.LENGTH + \
_MAX_TEXT_MESG_SIZE = 1024
+_MAX_PENDING_PUSH = 100
+
class _OptCode:
user_auth = 0x00
location_update = 0x01
@@ -96,6 +98,9 @@ class PushTunnel(object):
def add(self, pdata):
logger.info("-- Push data enqued --")
self.pending.append(pdata)
+ if len(self.pending) > _MAX_PENDING_PUSH:
+ logger.info("-- Push queue is full, discarded an obsolete push --")
+ self.pending.popleft() # discard old push
def on_receive(self, data):
front = self.pending.popleft()
@@ -670,6 +675,6 @@ from twisted.internet import reactor
f = PTPFactory()
f.protocol = PTP
-reactor.listenTCP(2222, f)
+reactor.listenTCP(2223, f)
logger.warning("The server is lanuched")
reactor.run()