Skip to content
Commit 303cb166 authored by Luca Fancellu's avatar Luca Fancellu
Browse files

cam-service: Introduce packet lock



Currently, during the time from the packet receive to
the decoding and handling of the correct stream it belongs,
there might be the timer callback that locks the stream
few instant before.

In theory, if a packet is received, and that packet belongs
to the stream we were waiting for, the timer callback should
not prevent it to be handled, there should be a critical
section starting immediately after the receive of a new packet
and ending just after the handling is complete, so that the
timer should stop us only during the time spent waiting the
packets.

With this purpose, introduce a packet lock, a global lock for
each connection, that is locked right after a packet is received
and unlocked right after the right stream context is found for
the received packet. The timer callback would then wait for
the packet lock and afterwards will lock the stream context it
belongs, so that it can't interfere during the packet handling
time.
The timer call will be fired anyway, the only thing that stops
the function to give an error and destroy the context is that
the packet lock is held until the packet context is found, so
in case another stream's packet is keeping the packet lock, it
won't prevent the timer to return the error on the invalid
stream. But in case the packet was the one for which the timer
was fired, then since we received it and handled it, the callback
needs to return without actions because the state is fine and
the packet was received in time.

Update the unit test accordingly.

Signed-off-by: Luca Fancellu's avatarLuca Fancellu <luca.fancellu@arm.com>
parent 251bd288
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment