Skip to content
This repository
Browse code

tweakings

  • Loading branch information...
commit d13c65a1afa044e00adf6f7f400376a64bd87802 1 parent 02ad6ce
Tarek Ziade tarekziade authored
3  vaurien/config.py
@@ -267,7 +267,8 @@ def setdefaults(self, *args, **kwds):
267 267 'vaurien.stay_connected': False,
268 268 'vaurien.pool_max_size': 100,
269 269 'vaurien.pool_timeout': 30,
270   - 'vaurien.async_mode': True,
  270 + 'vaurien.sync': False,
  271 + 'vaurien.backlog': 8192,
271 272
272 273 # stats config
273 274 'statsd.enabled': False,
2  vaurien/protocols/tcp.py
@@ -39,7 +39,5 @@ def _handle(self, source, dest, to_backend):
39 39
40 40 # we're done - False means we'll disconnect the client
41 41 return False
42   - else:
43   - self._abort_handling(to_backend, dest)
44 42
45 43 return data != ''
13 vaurien/proxy.py
@@ -26,11 +26,12 @@ def __init__(self, proxy, backend, protocol='tcp', behaviors=None,
26 26 logger.info('Starting the Chaos TCP Server')
27 27 parsed_proxy = parse_address(proxy)
28 28 dest = parse_address(backend)
29   - StreamServer.__init__(self, parsed_proxy, **kwargs)
  29 + backlog = cfg.get('backlog', 8192)
  30 + StreamServer.__init__(self, parsed_proxy, backlog=backlog, **kwargs)
30 31 self.max_accept = 2000 # XXX option ?
31 32 self.pool_max_size = cfg.get('pool_max_size', 1000)
32 33 self.pool_timeout = cfg.get('pool_timeout', 30)
33   - self.async_mode = cfg.get('async_mode', False)
  34 + self.async_mode = not cfg.get('sync', False)
34 35 self._pool = FactoryPool(self._create_connection, self.pool_max_size,
35 36 self.pool_timeout)
36 37 self.dest = dest
@@ -99,6 +100,9 @@ def handle(self, client_sock, address):
99 100 backend_sock._closed = True
100 101 break
101 102
  103 + if client_sock.closed:
  104 + raise ValueError("Client is gone")
  105 +
102 106 greens = [gevent.spawn(self._weirdify,
103 107 client_sock, backend_sock,
104 108 sock is not backend_sock,
@@ -124,7 +128,7 @@ def statsd_incr(self, counter):
124 128 if self._statsd:
125 129 self._statsd.incr(counter)
126 130 elif self._logger:
127   - self._logger.info(counter)
  131 + self._logger.debug(counter)
128 132
129 133 def _weirdify(self, client_sock, backend_sock, to_backend,
130 134 statsd_prefix, behavior, behavior_name):
@@ -133,6 +137,9 @@ def _weirdify(self, client_sock, backend_sock, to_backend,
133 137 Depending the configuration, we will chose to either drop packets,
134 138 proxy them, wait a long time, etc, as defined in the configuration.
135 139 """
  140 + if client_sock.closed:
  141 + raise ValueError("Client is gone")
  142 +
136 143 if to_backend:
137 144 self.statsd_incr(statsd_prefix + 'to_backend')
138 145 dest = backend_sock

0 comments on commit d13c65a

Please sign in to comment.
Something went wrong with that request. Please try again.