Commit Graph

8 Commits

Author SHA1 Message Date
David Wilson 356647bef4 issue #132: initial unidirectional routing mode. 2018-05-08 16:06:08 +01:00
David Wilson e63ae4768e core: support Receiver.get(thread_dead=False)
For tests.
2018-04-22 05:08:37 +01:00
David Wilson 7c88e4d013 Move _DEAD into header, autogenerate dead messages
This change blocks off 2 common scenarios where a race condition is
upgraded to a hang, when the library could internally do better.

* Since we don't know whether the receiver of a `reply_to` is expecting
  a raw or pickled message, and since in the case of a raw reply, there
  is no way to signal "dead" to the receiver, override the reply_to
  field to explicitly mark a message as dead using a special handle.

  This replaces the serialized _DEAD sentinel value with a slightly
  neater interface, in the form of the reserved IS_DEAD handle, and
  enables an important subsequent change: when a context cannot route a
  message, it can send a generic 'dead' reply back towards the message
  source, ensuring any sleeping thread is woken with ChannelError.

  The use of this field could potentially be extended later on if
  additional flags are needed, but for now this seems to suffice.

* Teach Router._invoke() to reply with a dead message when it receives a
  message for an invalid local handle.

* Teach Router._async_route() to reply with a dead message when it
  receives an unroutable message.
2018-04-22 00:17:27 +01:00
David Wilson 6670cba41c Introduce handler policy functions; closes #138.
Now you can specify a function to add_handler() that authenticates the
message header, with has_parent_authority() and is_immediate_child()
built in.
2018-03-29 21:40:33 +05:45
David Wilson 40b978c9b7 core: Fix source verification.
Previously:

* src_id could be spoofed
* auth_id was checked but the message was still delivered!
2018-03-29 20:24:54 +05:45
David Wilson fe614aa966 core: cleanup handlers on broker crash; closes #112. 2018-03-29 19:32:31 +05:45
David Wilson 1ff27ada49 Add maximum message size checks. Closes #151. 2018-03-29 18:54:55 +05:45
David Wilson afc8697288 core: Ensure add_handler() callbacks really receive _DEAD on shutdown 2018-03-19 21:58:30 +05:45