Fix bug with 0 entry reads

master
Ringo Watanabe 6 years ago
parent 8c9442d0b9
commit e57456a73b

@ -1,4 +1,3 @@
import sys import sys
import os import os
import os.path import os.path
@ -69,7 +68,7 @@ def encode_post(post):
return data return data
def decode_post(data): def decode_post(data):
js = pylzma.decompress(data) js = pylzma.decompress(data).decode("utf-8")
np = json.loads(js) np = json.loads(js)
mape = dict((v,k) for k,v in __pmap().items()) mape = dict((v,k) for k,v in __pmap().items())
post = dict() post = dict()
@ -257,6 +256,7 @@ class FileBuffer(StatBuffer):
def readno(self, floor): def readno(self, floor):
super()._lock() super()._lock()
posts = list() posts = list()
if self.file.tell()>0:
ent = self._readentry() ent = self._readentry()
while self.file.tell()>0 and ent!=None: while self.file.tell()>0 and ent!=None:
if(ent["no"]<=floor): break if(ent["no"]<=floor): break
@ -432,7 +432,7 @@ if args.daemon!=None:
daemon_sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) daemon_sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
daemon_sock.bind(args.daemon) daemon_sock.bind(args.daemon)
daemon_sock.settimeout(5) daemon_sock.settimeout(5)
daemon_sock.listen() daemon_sock.listen(5)
daemon = Daemon(daemon_sock, buf) daemon = Daemon(daemon_sock, buf)
daemon.start() daemon.start()

@ -0,0 +1,6 @@
#!/bin/bash
rm ./rtbw.sock
rm ./buffer.dat
python3 rtbw.py --debug --buffer buffer.dat --daemon rtbw.sock bant 10
Loading…
Cancel
Save