mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-23 10:00:35 +00:00
Currently, it is hard for injected code to wait for some events, for example, requests on some REST endpoint. This commit adds the `inject_with_handler` method that executes injected function and passes `injection_handler` as its argument. The `injection_handler` class is used to wait for events inside the injected code. The `error_injection` class can notify the injection's handler or handlers associated with the injection on all shards about the received message. There is a counter of received messages in `received_messages_counter`; it is shared between the injection_data, which is created once when enabling an injection on a given shard, and all `injection_handler`s, that are created separately for each firing of this injection. The `counter` is incremented when receiving a message from the REST endpoint and the condition variable is signaled. Each `injection_handler` (separate for each firing) stores its own private counter, `_read_messages_counter` that private counter is incremented whenever we wait for a message, and compared to the received counter. We sleep on the condition variable if not enough messages were received.