Commit Graph

22 Commits (b831b4ab316bdb7f021c0f647303acf36413985f)

Author SHA1 Message Date
David Wilson 3b17cb7c5b unix: add Listener.__repr__. 6 years ago
David Wilson 586c6aca9a issue #406: unix: fix ordering of stop_receive/close. 6 years ago
David Wilson 661e274556 issue #406: ensure is_path_dead() socket is finalized. 6 years ago
David Wilson 411af6c167 issue #406: unix: don't leak already-closed socket object
if Side.close() closes the socket (which it does), and it gets reused,
GC will cause socketobject.__del__ to later delete some random FD.
6 years ago
David Wilson f343bbba3a unix: fix exception catch on 3.x. 6 years ago
David Wilson 4e3830d75e tests: add basic unix_test.py. 6 years ago
David Wilson 870bbe0eae unix: don't crash listener if remote end disconnects.
In some scenarios, Ansible's worker seems to exit early, resulting in
EPIPE during .recv() or .send(). Log an error and gracefully disconnect
in that case.
6 years ago
David Wilson 2647f73501 ansible: bump UNIX listener default backlog, and set it to match forks.
The connection multiplexer can expect to not be scheduled at least until
every $forks worker processes has attempted a connection, so the backlog
must be able to hold every worker.
6 years ago
David Wilson 410016ff47 Initial Python 3.x port work.
* ansible: use unicode_literals everywhere since it only needs to be
  compatible back to 2.6.
* compat/collections.py: delete this entirely and rip out the parts of
  functools that require it.
* Introduce serializable Kwargs dict subclass that translates keys to
  Unicode on instantiation.
* enable_debug_logging() must set _v/_vv globals.
* cStringIO does not exist in 3.x.
* Treat IOLogger and LogForwarder input as latin-1.
* Avoid ResourceWarnings in first stage by explicitly closing fps.
* Fix preamble_size.py syntax errors.
6 years ago
David Wilson 356647bef4 issue #132: initial unidirectional routing mode. 7 years ago
David Wilson c4bef102fe issue #16: Python 2.4-3.x compatible exception handling. 7 years ago
David Wilson 95d50adb14 unix: simplify return statements. 7 years ago
David Wilson 6a74edce6b issue #155: parent: move master.Context into parent.
The Context and Router APIs for constructing children and making
function calls should be available in every parent context, as user code
wants to have access to the same API.
7 years ago
David Wilson a956aa409e Remove duplicate set_cloexec calls everywhere
Now it's handled in Side() constructor, it can disappear elsewhere.
7 years ago
David Wilson 86ede62241 issue #150: introduce separate connection multiplexer process
This is a work in progress.
7 years ago
David Wilson 017e8105cf issue #131: disable non-blocking IO during UNIX accept()
accept() (per interface) returns a non-blocking socket because the
listener socket is in non-blocking mode, therefore it is pure scheduling
luck that a connecting-in child has a chance to write anything for the
top-level processs to read during the subsequent .recv().

A higher forks setting in ansible.cfg was enough to cause our luck to
run out, causing the .recv() to crashi with EGAIN, and the multiplexer
to respond to the handler's crash by calling its disconnect method. This
is why some reports mentioned ECONNREFUSED -- the listener really was
gone, because its Stream class had crashed.

Meanwhile since the window where we're waiting for the remote process to
identify itself is tiny, simply flip off O_NONBLOCK for the duration of
the connection handshake. Stream.accept() (via Side.__init__) will
reenable O_NONBLOCK for the descriptors it duplicates, so we don't even
need to bother turning this back off.

A better solution entails splitting Stream up into a state machine and
doing the handshake with non-blocking IO, but that isn't going to be
available until asynchronous connect is implemented. Meanwhile in
reality this solution is probably 100% fine.
7 years ago
David Wilson 83c8412474 issue #140: permit mitogen.unix.connect() to accept preconstructed Broker.
Part of an effort to make resource management a little more explicit.
7 years ago
David Wilson 016d47aa91 Log and track PIDs everywhere for Ansible. 7 years ago
David Wilson ff617824a1 ansible: fix some flake8 errors
* Unused imports
* Undefined names in helpers.py
* Copyright header wrapping
7 years ago
David Wilson 2ce71b338b unix: add small explainer note until real docs exist 7 years ago
David Wilson f3e51a7b18 core: CALL_FUNCTION should check auth_id, not src_id 7 years ago
David Wilson 32f6ee7d43 issue #40: mitogen.unix initial implementation. 7 years ago