Fix: max_t/min_t macros are missing cast on input The semantic expected from max_t and min_t is to perform the max/min comparison in the type provided as first parameter. Cast the input parameters to the proper type before comparing them, rather than after. There is no more need to cast the result of the expression now that both inputs are cast to the right type. Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Fix: Connect timeout arithmetic in inet/inet6 (v4) The nanoseconds part of the timespec struct time_a is not always bigger than time_b since it wraps around each second. Use 64-bit arithmetic to compute the difference. Merge/move duplicated code into utils.c. This function is really doing two things. Split it into timespec_to_ms() and timespec_abs_diff(). Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Bound maximum data read to RECV_DATA_BUFFER_SIZE per iteration Do not consume everything all at once even if there is data left on the socket. This is to provide fairness to the overall data handling of all connections. It also provide a bounded processing execution for a data processing iteration. Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
relayd: do not prioritize control events over data. Simplify the algorithm used by relayd for control and data connections handling. Use the notion of activity phase. An activity phase represent a phase for which all connections with activity (poll/epoll) are not yet processed. When an active connection is processed, her activity phase is set to the current activity phase to prevent further progress during the same activity phase. Once all active connections (poll events) have been processed during the current activity phase, the current activity phase is incremented. This give fairness across all connections during a given activity phase. This can also serve as a base for future work toward resources based prioritizing. Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
consumer: Rename net_seq_idx to relayd_id The consumer's streams refer to a 'net_seq_idx' of which the meaning must have been lost in the sands of time. It is a unique identifier of a given relay daemon. Hence, renaming it to 'relayd_id' appears sensible. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Cleanup: remove dead assignment Both calling sites do not use the return value and errors are already managed inside the called function. Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Set consumer's verbosity to the max level on --verbose-consumer The consumer's verbosity is set to '1' when --verbose-consumer is used when launching the session daemon. This means that all DBG2/3() statements are ignored. This commit always sets the consumer's verbosity to the maximal level. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Fix: double put on error path Let relay_index_try_flush be responsible for the self-reference put on error path. Code flow of relay_index_try_flush is a bit tricky but the only error flow (via relay_index_file_write) will always mark the index as flushed and perform the self-reference put. Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Fix: holding the stream lock does not equate to having data pending The live timer can hold the stream lock while sending empty beacon. An empty beacon does not mean that data is still pending for the stream. Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Fix: skip uid registry when metadata key is 0 A value of zero for the metadata key indicate that metadata was never created/pushed to the consumer. This can occur in scenario were a tracker is present since metadata might never be created/pushed. Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Fix: acquire stream lock during kernel metadata snapshot The stream lock is not taken when interacting with the kernel metadata stream that is created at the time a snapshot is taken. This was noticed while reviewing the code for an unrelated reason, so there is no known problem caused by this. Nevertheless, this is incorrect as the stream is globally visible in the consumer. Moreover, the stream was not cleaned-up which can cause a leak whenever a metadata snapshot fails. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>