chiark / gitweb /
fixes
[hippotat.git] / hippotat / __init__.py
index 90476f5950ad89d3481e38cb670ac28178efe443..1e8a23f11e7b717f0a17534835b65f1debe4eb33 100644 (file)
@@ -20,6 +20,8 @@ from optparse import OptionParser
 from configparser import ConfigParser
 from configparser import NoOptionError
 
+from functools import partial
+
 import collections
 import time
 import codecs
@@ -40,6 +42,7 @@ class DBG(twisted.python.constants.Names):
   QUEUE_CTRL = NamedConstant()
   HTTP_FULL = NamedConstant()
   SLIP_FULL = NamedConstant()
+  CTRL_DUMP = NamedConstant()
 
 _hex_codec = codecs.getencoder('hex_codec')
 
@@ -48,7 +51,7 @@ log = twisted.logger.Logger()
 def log_debug(dflag, msg, idof=None, d=None):
   #print('---------------->',repr((dflag, msg, idof, d)), file=sys.stderr)
   if idof is not None:
-    msg = '[%d] %s' % (id(idof), msg)
+    msg = '[%#x] %s' % (id(idof), msg)
   if d is not None:
     #d = d[0:64]
     d = _hex_codec(d)[0].decode('ascii')
@@ -60,11 +63,11 @@ defcfg = '''
 #[<client>] overrides
 max_batch_down = 65536           # used by server, subject to [limits]
 max_queue_time = 10              # used by server, subject to [limits]
-max_request_time = 54            # used by server, subject to [limits]
 target_requests_outstanding = 3  # must match; subject to [limits] on server
+http_timeout = 30                # used by both } must be
+http_timeout_grace = 5           # used by both }  compatible
 max_requests_outstanding = 4     # used by client
 max_batch_up = 4000              # used by client
-http_timeout = 30                # used by client
 http_retry = 5                   # used by client
 
 #[server] or [<client>] overrides
@@ -93,7 +96,7 @@ port = 80                  # used by server
 [limits]
 max_batch_down = 262144           # used by server
 max_queue_time = 121              # used by server
-max_request_time = 121            # used by server
+http_timeout = 121                # used by server
 target_requests_outstanding = 10  # used by server
 '''
 
@@ -168,9 +171,8 @@ class SlipStreamDecoder():
 
   def inputdata(self, data):
     self._log('inputdata', d=data)
-    data = self._buffer + data
-    self._buffer = b''
     packets = slip.decode(data)
+    packets[0] = self._buffer + packets[0]
     self._buffer = packets.pop()
     for packet in packets:
       self._maybe_packet(packet)
@@ -285,7 +287,8 @@ _crashing = False
 def crash(err):
   global _crashing
   _crashing = True
-  print('CRASH ', err, file=sys.stderr)
+  print('========== CRASH ==========', err,
+        '===========================', file=sys.stderr)
   try: reactor.stop()
   except twisted.internet.error.ReactorNotRunning: pass