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
Make it quasi infinite, on cases with wrong
read of config parameter `cps_limit`,
so that if int has undefined value it doesn't
suddenly cause undefined behavior of the license
limitation agent.
Change-Id: If1ca5442135793929eb96d47642ea4314cd82803
Before using the `clock_rate` or `payload_type`
always initialize, because might be used non-defined,
which will give whatever value.
Fixes:
Uninitialized scalar variable (UNINIT)
35. uninit_use_in_call: Using uninitialized
value (int)clock_rate when calling SdpPayload.
Change-Id: Ie7cea4289ace93a169ad2dce8a402b9a469c65f8
Rework the `nbWrite()` function so, that it gets safe
in terms of:
- operating on data written/data remaining integers
- has protection guards for extra big chunks to write at once
Refactor to use size_t/ssize_t instead of primitive int,
where possible (e.g. bytesWritten).
Let the `nbWrite()` use reference instead of pointer
for the bytes written parameter.
Fixes Coverity Scan report:
4. tainted_data_return: Called function write(fd, sp, nToWrite),
and a possible return value may be less than zero.
5. cast_overflow: An assign that casts to a different type,
which might trigger an overflow.
Overflowed integer argument (INTEGER_OVERFLOW)
13. overflow_sink: nToWrite, which might have overflowed,
is passed to write(fd, sp, nToWrite).
7. overflow: The expression nToWrite is considered
to have possibly overflowed.
Change-Id: I32aa6aae5ef5715d61a91714e62b0a094bc03f21
As long as the `TypeInt` is actually a long primitive,
and we tend to switch using the long type everywhere
within xml implementation, then
there is no need to support both `int` and `long`
types, just force users to be on `long` always.
Refactor the user code accordingly.
Change-Id: I5c5b032a824a84f69f99dc7c755d0da745a9a068
As this is only a syntactic sugar there is no difference,
but from the style perspective the project tends to
use C++ style.
Change-Id: I3636c48163b3d262b272b5088e03c074e49a9ec3
Properly select the equal operator based on long instead.
Otherwise it selects the `ValueStruct` as the latest
possible from the variant based `_value` and eventually
it gets stumbled over `[]` operator for
building structs which asserts it.
Change-Id: Ib9a4fe9c66ff02554a84451df8aa940fe766fedc
Don't try to double free the `_ssl_ssl` and `_ssl_ctx`
provided by `XmlRpcSource`, because this job
is already done by `XmlRpcSource::close()`.
Additionally:
- add a separate non-null check for the _ssl_ctx freeing
- move log lines from `XmlRpcClient::close()` to `XmlRpcSource::close()`
Change-Id: Ifef799fa6a0ffa65b60415f39c51f4b54ff4bb14
Additional logic around these two objects to free it during the
destruction phase.
Also add NULLing for the according pointers in other places
which might also free it before the destructor takes place,
which would lead otherwise to a double free attempt.
Change-Id: I046a660e4b1467a7093dbf2c0c3170a950d5f607
Don't appeal to the XmlRpcSource's members (e.g. `_ssl`)
if this has been freed via `this`.
To check this out see controllable delete behavior
via introduced getter `getsDeletedOnClose()`.
Should fix:
freed_arg: close frees this.
CID 542402: (#1 of 1): Read from pointer after free (USE_AFTER_FREE)
use_after_free: Using freed pointer this.
Change-Id: I8f23564957c57491db8cf051e7296671bf2a698a
The memory referenced via it could have been freed already
(by the `update_uac_request()`). Set the original pointer to NULL
and check in the caller's function if it has been assigned to NULL
before actually using.
Fixes:
Read from pointer after free (USE_AFTER_FREE)
41. deref_after_free: Dereferencing freed pointer p_msg.
Change-Id: I07ee9360f996c8723ba46c99f512ef9562ff75c3
To be able to set msg's ptr to NULL in the `update_uac_request()`
after the memory referenced via it is freed.
Change-Id: Id8d89a6a64b78e5fd06d43e0b99aaf83c4623908
For newly created call profiles use the move operation
instead of copy one.
Fixes:
CID 542292:Variable copied when it could be moved (COPY_INSTEAD_OF_MOVE)
Change-Id: Ia130fc3e32d23e63f3d41fc6261e90ecf742ecf7
Let STL handle memory management and type safety.
In the future this can be refactored further to eliminate the "Type"
enum and value, as the variant itself keeps this information.
Fix white spacing.
Change-Id: I6e903b51de339b686ba89bb7ae81f4d86eb66bc0
Store integers as long to reduce likelihood of overflows. Retain
overloaded accessors for compatibility.
Use time_t and suseconds_t for timestamps.
Fix up formatting strings to match the new types and to also fix
incorrect formatting of decimal values.
Remove unused methods.
Change-Id: I58bfcd8a34bef2363eac06242dfedf6aae8451e0