chiark / gitweb /
fixes
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 2 Apr 2017 21:34:16 +0000 (22:34 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 2 Apr 2017 21:34:16 +0000 (22:34 +0100)
client
hippotat/__init__.py
server
test.cfg

diff --git a/client b/client
index a56dde2..e9bce7c 100755 (executable)
--- a/client
+++ b/client
@@ -25,6 +25,7 @@ class ResponseConsumer(GeneralResponseConsumer):
     ssddesc = '[%s] %s' % (id(req), self._desc)
     self._ssd = SlipStreamDecoder(ssddesc, cl.queue_inbound)
     self._log(DBG.HTTP_CTRL, '__init__')
+    self._success_reported = False
 
   def dataReceived(self, data):
     self._log(DBG.HTTP, 'dataReceived', d=data)
@@ -44,6 +45,9 @@ class ResponseConsumer(GeneralResponseConsumer):
       self.cl.req_fin(self._req)
     except Exception as e:
       self._handleexception()
+    if not self._success_reported:
+      log.info(cl.desc + 'running OK', dflag=False)
+      self._success_reported = True
 
   def _handleexception(self):
     self._latefailure(traceback.format_exc())
@@ -83,12 +87,13 @@ class Client():
     cl.c = c
     cl.outstanding = { }
     cl.desc = '[%s %s] ' % (ss,cs)
+    log.info(cl.desc + 'setting up', dflag=False)
 
   def log(cl, dflag, msg, **kwargs):
     log_debug(dflag, cl.desc + msg, **kwargs)
 
   def log_outstanding(cl):
-    cl.log(DBG.CTRL_DUMP, 'OS %s' % outstanding)
+    cl.log(DBG.CTRL_DUMP, 'OS %s' % cl.outstanding)
 
   def start(cl):
     cl.queue = PacketQueue('up', cl.c.max_queue_time)
@@ -120,8 +125,9 @@ class Client():
       if isinstance(err, twisted.python.failure.Failure):
         err = err.getTraceback()
       print('[%#x] %s' % (id(req), err), file=sys.stderr)
-      if not isinstance(outstanding[req], int):
-        raise RuntimeError('[%#x] previously %s' % (id(req), outstanding[req]))
+      if not isinstance(cl.outstanding[req], int):
+        raise RuntimeError('[%#x] previously %s' %
+                           (id(req), cl.outstanding[req]))
       cl.outstanding[req] = err
       cl.log_outstanding()
       reactor.callLater(cl.c.http_retry, partial(cl.req_fin, req))
@@ -130,7 +136,7 @@ class Client():
 
   def req_fin(cl, req):
     del cl.outstanding[req]
-    cl.log(DBG.HTTP_CTRL, 'req_fin OS=%d' % len(outstanding), idof=req)
+    cl.log(DBG.HTTP_CTRL, 'req_fin OS=%d' % len(cl.outstanding), idof=req)
     cl.check_outbound()
 
   def check_outbound(cl):
@@ -138,13 +144,13 @@ class Client():
       if len(cl.outstanding) >= cl.c.max_outstanding:
         break
 
-      if (not queue.nonempty() and
-          len(cl.outstanding) >= cl.c.target_outstanding):
+      if (not cl.queue.nonempty() and
+          len(cl.outstanding) >= cl.c.target_requests_outstanding):
         break
 
       d = b''
       def moredata(s): nonlocal d; d += s
-      queue.process((lambda: len(d)),
+      cl.queue.process((lambda: len(d)),
                     moredata,
                     cl.c.max_batch_up)
 
@@ -157,7 +163,8 @@ class Client():
               b'Content-Disposition: form-data; name="m"'   + crlf + crlf +
               str(cl.c.client)            .encode('ascii')  + crlf +
               cl.c.password                                 + crlf +
-              str(cl.c.target_outstanding).encode('ascii')  + crlf +
+              str(cl.c.target_requests_outstanding)
+                                          .encode('ascii')  + crlf +
               str(cl.c.http_timeout)      .encode('ascii')  + crlf +
             ((
               b'--b'                                        + crlf +
@@ -181,7 +188,7 @@ class Client():
       bytesreader = io.BytesIO(mime)
       producer = twisted.web.client.FileBodyProducer(bytesreader)
 
-      req = agent.request(b'POST',
+      req = cl.agent.request(b'POST',
                           cl.c.url,
                           twisted.web.client.Headers(hh),
                           producer)
index 3617235..8a21966 100644 (file)
@@ -86,6 +86,7 @@ class LogNotBoringTwisted:
       if event.get('log_level') != LogLevel.info:
         return yes
       dflag = event.get('dflag')
+      if dflag is False                            : return yes
       if dflag                         in debug_set: return yes
       if dflag is None and DBG.TWISTED in debug_set: return yes
       return no
@@ -430,16 +431,16 @@ def cfg_process_saddrs(c, ss):
     c.saddrs.append(sa)
 
 def cfg_process_vnetwork(c, ss):
-  c.network = ipnetwork(cfg.get(ss,'network'))
-  if c.network.num_addresses < 3 + 2:
-    raise ValueError('network needs at least 2^3 addresses')
+  c.vnetwork = ipnetwork(cfg.get(ss,'vnetwork'))
+  if c.vnetwork.num_addresses < 3 + 2:
+    raise ValueError('vnetwork needs at least 2^3 addresses')
 
 def cfg_process_vaddr(c, ss):
   try:
-    c.vaddr = cfg.get(ss,'server')
+    c.vaddr = cfg.get(ss,'vaddr')
   except NoOptionError:
     cfg_process_vnetwork(c, ss)
-    c.vaddr = next(c.network.hosts())
+    c.vaddr = next(c.vnetwork.hosts())
 
 def cfg_search_section(key,sections):
   for section in sections:
@@ -469,7 +470,7 @@ def cfg_process_client_common(cc,ss,cs,ci):
   except NoOptionError: return None
     
   pw = cfg.get(pwsection, 'password')
-  pw = pw.encode('utf-8')
+  cc.password = pw.encode('utf-8')
 
   cfg_process_client_limited(cc,ss,sections,'target_requests_outstanding')
   cfg_process_client_limited(cc,ss,sections,'http_timeout')
@@ -482,7 +483,7 @@ def cfg_process_ipif(c, sections, varmap):
     except AttributeError: continue
     setattr(c, d, v)
 
-  print('CFGIPIF',repr((varmap, sections, c.__dict__)),file=sys.stderr)
+  #print('CFGIPIF',repr((varmap, sections, c.__dict__)),file=sys.stderr)
 
   section = cfg_search_section('ipif', sections)
   c.ipif_command = cfg.get(section,'ipif', vars=c.__dict__)
diff --git a/server b/server
index 52d83b5..5bce0f3 100755 (executable)
--- a/server
+++ b/server
@@ -49,7 +49,7 @@ class Client():
     #  .target_requests_outstanding
 
     if ip not in c.vnetwork:
-      raise ValueError('client %s not in network' % ip)
+      raise ValueError('client %s not in vnetwork' % ip)
 
     self._pq = PacketQueue(str(ip), self.max_queue_time)
 
index d858da7..9f5f182 100644 (file)
--- a/test.cfg
+++ b/test.cfg
@@ -17,4 +17,4 @@ ipif = PATH=/usr/local/sbin:/sbin:/usr/sbin:$PATH really ./fake-userv /home/ian/
 # ./client -D -c test.cfg
 
 [192.0.2.4]
-password = zorkmids
+#password = zorkmids