Requesting removal of a timer that isn't present in the list indicates a
race condition. Something else has already removed/disarmed the timer
(possibly from firing the timer), and that something else is then in
charge of freeing the object. Therefore do not free the timer object at
removal if the timer wasn't armed.
Change-Id: I26b58b6dc3400acf3241375da3cde879a5968d41
(cherry picked from commit 5c455d32dc)
This module initialises and starts the StatsUDPServer. Stop its worker
when the module is destroyed.
Change-Id: I265d7ee103866a5946b066e4e7d42376e3510cac
(cherry picked from commit 4bd36ffc89)
Wake up thread from blocking on recvfrom() so that it can shut down when
requested to.
Change-Id: Iaa05caf93877363c162d56791a6e24bdfb809094
(cherry picked from commit 392cd9d759)
The parsing code expect a null-terminated string. Make sure the string
is.
Use correct ssize_t as return value.
Change-Id: I2590dead0db5ca839ebe5fe7506b4edfe524d164
(cherry picked from commit 4a4b8fec18)
These variables used to be shell variables passed to the make
invocations in various rules. But those got refactored into make
variables. The problem is that in make the equal sign does not bind
according to surrounding lack of spaces, and the first equal sign
will mark an assignment for the rest of the string including subsequent
equal signs.
The other problem is with the CPPFLAGS assignment where it will assign
append the value and then subsequent conditional assignments will not
take place. Switch to use DEB_CPPFLAGS_APPEND, which was designed
precisely for this purpose.
Fixes: commit 9b5df2495e
Change-Id: Ice82295903729fed3f0fb11f750f3f2fdde2e09f
(cherry picked from commit b7494cf7ff)
We can now use the sets to iterate the bindings in order of their
expiry and exit the loop when we encounter the first one with an expiry
in the future.
Change-Id: I093bea9807b4a432ac965b402394edc43eef5a1f
Add an ordered set of all AorEntry objects, ordered by expire time.
Amend modifier methods to update the set whenever some expire time is
updated or an entry or binding removed.
Change-Id: I2afe5becfa2124dbc8c33b38fe1a3e6d4b8a20d5
Move deletion of bindings into AorHash, similar to how expire times are
set. This makes it possible to manage expiry in a central place.
Change-Id: I76a72881ed202e85fb70e9d8526bac55863d07db
Make AorEntry keep an ordered set of all bindings, ordered by expire
time. This makes it easy to quickly tell when the next binding is set to
expire, and which one. Store iterators to bindings in the set so that
they can be used to directly remove the binding when expired.
Change-Id: Ib63c15d5f6e8990e2f4d237726be54da76194a20
Provide accessor methods. Put the setter into AorHash and require
iterators. All bindings must be in an AorEntry container and all
AorEntry objects must be in the AorHash container. By putting the setter
in AorHash and using iterators we can make sure that the binding is in
the container already and that expiry values are kept consistent.
Change-Id: I1c5140d1a7547059f61e47cd317680fcb6eae9fe
Provide a proper class for key matching/ordering instead of
hand-crafting a key to be used as index in several places. Use a simple
ordered map instead of the bucket-based approach.
Change-Id: I9e1918a48e103b655caac160c125a0393d261fca
Put all AorEntry objects into a single hash map. Eliminates the need for
AorBucket. Use an unorered hash map for performance. Use lock guards
instead of manual lock/unlock. Remove an unused argument to gbc().
Switch to the full tick cycle length instead of the tick-based one as
there are no more buckets to iterate.
Change-Id: I7da3bacaa5a28b7e628695ab879394fc6d56f5d2
Simplify the little-used RegisterCache alias hash by using the new
hash_map template. Eliminates the need for AliasBucket. Use an unordered
hash map for performance. Use lock guards instead of manual lock/unlock.
Manually `delete` contained objects as our table's .erase() doesn't do
that.
Change-Id: Ia9721460ce8264fc0a90184a91beca46012b64dd
Instead of relying on a short tick duration to make sure the thread
exits when requested, add a dedicated condition flag and variable. Use
AmThread on_stop to set it and wake up the thread. Use the condition
variable's timed wait instead of nanosleep for the ticks.
This somewhat duplicates what other threads are doing, and what
stop_requested() is doing, and should be unified into a single mechanism
provided by AmThread in the future.
Change-Id: I364e747b4acc1986fa262588c47d83c063ff2d69
The existing hash_table and ht_map_bucket implementations are a nice
performance optimisation, but are over-engineered for certain use cases
which don't see a lot of activity. They also make housekeeping and
iterating the table contents more difficult.
Provide a simpler alternative which is directly based on STL map and
unordered_map. Retain semantic compabilitity by including a mutex and
also providing a dump() method.
Change-Id: I62664b5bb4b1bbef10ba8c85ac1e1221e71bb9de
Eliminate the need to specify the "less than" operator explicitly as
part of the template arguments by specialising std::less, which is the
default operator.
Change-Id: I435792a5b9bd1783275c9632dc7c917e47d2e2f1
This was probably intended as a helper to facilitate reference counted
pointers, but this isn't used anywhere, and the only "allocator" in use
is the default wrapper around `delete`. If reference counted pointers
are ever relevant, they can be done using a shared_ptr.
Change-Id: I2adb561b76efcaf5fb119939f25a7c2438196a5b
Obviously the intent was to have reference-counted pointers as table
value, but this isn't used anywhere, and anyway would be better
implemented using a shared_ptr.
Change-Id: I4df6e874d402d615f654f3a8df3195fe6dda46bb
Temporarily releasing the lock only to immediately re-acquire it, just
because the called function does a lock/unlock, without re-checking all
data that is protected by the lock, opens the door to subtle race
conditions. Change the semantics of removeRegistration() to require
being called with the lock held. Update handleRegistrationTimer() to
also not release and re-acquire the lock.
Change-Id: Ib7562ae138b55d0ef83ec142706ec6415037fc2a
Cover the whole conditioning with the lock,
because otherwise two threads competing on execution
can suddenly come across the `(m_playout_type != type)` getting
true (for both) and one of them by acquiring the lock can potentially
manage to modify that, what can actually make `(m_playout_type != type)`
not true anymore for the other thread in race condition here.
Change-Id: Ie352da10a515837efc696063837b70dc2c9a304d
Refactor it so, that it's not possible to go over what
`unsigned long` offers (so 4,294,967,295).
We are accumulating read bytes there, which can potentially
be more than proposed 4,3Gb, for that case check out if
the possible end result will overflow and close connection
if this is likely to happen.
Change-Id: I4e758292e77649ddfbcaaa7f8dc9f133e74c4600