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
Add missing initialisers and fix order.
In some cases the member was actually unused and could just be removed.
Change-Id: I0f0c927eb8271c35dcfd371f225847f62bea2812
Warned-by: Coverity
Classes that inherit from both AmThread and AmEventHandler must inherit
from AmEventQueue first and from AmThread after. This is needed so that
the AmThread dtor is called first, which will trigger the thread to shut
down, which in turn makes sure nothing is waiting on the AmEventQueue's
condition variable.
Otherwise, if AmEventQueue is destroyed first while the corresponding
thread is still running and waiting on the condition variable, it will
be a deadlock.
With this, sems finally can shut down cleanly without having to be
killed by systemd.
Change-Id: I914455763b517c96561acb0b64fce26f127f44bc
Use a timed condition waiter instead of waiting forever. This is needed
to be able to react to a requested thread shutdown.
Change-Id: I062b6045d737eb16cab8f052375d81a1988e95e8
Properly handle in the second `setRegistrationTimer`'s
overloading, wheread peerings used to not get
an insertion of timer into own dedicated map.
Change-Id: Ib793ed6a6eb13447d27321eab59957d1bec2aabf
Don't re-use a stupid code to check the type each
time it needs to printed somewhere in logs.
Just use the macro function to handle this job.
Change-Id: I942f4f3b0730fa3c66ce6df10e0e1ff109e09bd5
Don't use std::string, because all multiple
conditions based on that in the code, make code
comparisons quite heavy in comparison to enum usage.
So just use enum type with default `TYPE_UNDEFINED`.
Refactor code accordingly and remove superfluous
code that now isn't required.
Change-Id: Icf29579cd3b93a1624854bd0a47610fc061c64e6
Before to actually do any work based on that
we have to check if it actually dereferences anything
reasonable.
Change-Id: I736b7f44c9702ac49fbab967f6baea2be5279d74
Just refactoring, no func changes.
Fixes things like:
*** CID 545192: Uninitialized members (UNINIT_CTOR)
/apps/db_reg_agent/DBRegAgent.cpp: 73 in RegTimer::RegTimer()()
67 }
68
69 long object_id = 0;
70 RegistrationActionEvent::RegAction action;
71 string type;
72
>>> CID 545192: Uninitialized members (UNINIT_CTOR)
>>> Non-static class member "action" is not initialized in this constructor nor in any functions that it calls.
73 RegTimer() {}
74 };
75
76 DBRegAgent::DBRegAgent(const string& _app_name)
77 : AmDynInvokeFactory(_app_name),
78 AmEventQueue(this),
Change-Id: If7fdf53918e711a6b3d262f496ab0e0a349da4b8
No need to always check for:
`type == TYPE_SUBSCRIBER || type == TYPE_UNDEFINED`
The type is either `TYPE_PEERING` or the rest
(subscriber, or if CSTA didn't point out the type
explicitly it's undefined, but then again it's
related to subscriber's type).
Refactor the code accordingly. No func changes.
Change-Id: I5f045b645c971ef309436a5d1c3a4dbc7f180045
There is no need for a generic timer callback option without good
typing, as we can just subclass the timer class and use our own fire()
method and whatever other class members are needed.
Change-Id: I95cd60277b5b4d3f492389958fa7f2ead921479e
This commit takes care of this:
../../core/log.h:143:30: warning: format '%d' expects argument of type 'int', but argument 4 has type 'long int' [-Wformat=]
143 | _LOG(L_DBG, error_category " " fmt, ##args)
../../core/log.h:121:45: note: in definition of macro '_LOG'
121 | int n_ = snprintf(msg_, sizeof(msg_), fmt, ##args); \
| ^~~
../../core/log.h:166:29: note: in expansion of macro 'CAT_DBG'
166 | #define DBG(fmt, args...) CAT_DBG(ERROR_CATEGORY_DGENERAL, fmt, ##args)
| ^~~~~~~
DBRegAgent.cpp:298:4: note: in expansion of macro 'DBG'
298 | DBG("REGISTER: Triggering for subscriber with object_id=<%d>\n", object_id);
| ^~~
DBRegAgent.cpp:298:62: note: format string is defined here
298 | DBG("REGISTER: Triggering for subscriber with object_id=<%d>\n", object_id);
| ~^
| |
| int
| %ld
../../core/log.h:143:30: warning: format '%d' expects argument of type 'int', but argument 4 has type 'long int' [-Wformat=]
143 | _LOG(L_DBG, error_category " " fmt, ##args)
../../core/log.h:121:45: note: in definition of macro '_LOG'
121 | int n_ = snprintf(msg_, sizeof(msg_), fmt, ##args); \
| ^~~
../../core/log.h:166:29: note: in expansion of macro 'CAT_DBG'
166 | #define DBG(fmt, args...) CAT_DBG(ERROR_CATEGORY_DGENERAL, fmt, ##args)
| ^~~~~~~
DBRegAgent.cpp:423:7: note: in expansion of macro 'DBG'
423 | DBG("REGISTER: Triggering for peering with object_id=<%d>\n", object_id);
| ^~~
DBRegAgent.cpp:423:62: note: format string is defined here
423 | DBG("REGISTER: Triggering for peering with object_id=<%d>\n", object_id);
| ~^
| |
| int
| %ld
Change-Id: I088f9a1a2861d1f7aae7b7cab84ce0e66b3127c2
This commit takes care of this:
DBRegAgent.cpp: In member function 'bool DBRegAgent::loadRegistrations()':
DBRegAgent.cpp:293:24: warning: NULL used in arithmetic [-Wpointer-arith]
293 | if (object_id == NULL || object_id == 0) {
It makes no sense to compare the `object_id` of type long against
the NULL.
Change-Id: I60cdde2dd459dbfa9c7c942cd8f0d111096411e7
We need to add a possibility to control (add/modify/delete) registrations
for SIP peerings using NGCP-panel. For that to work NGCP-panel uses XMLRPC
requests being sent towards SEMS, which in its turn takes care of work with:
- locally cached map structures:
* registrations / registrations_peers
* registration_ltags / registration_ltags_peers
* registration_timers / registration_timers_peers
- MySQL database (our scope of interest is 'sems_registrations')
- triggering events
Main amount of work is concentrated on interaction with map structures which keep
an actual information on registrations of either subscribers and peerings,
and less amount of work is related to the SQL side.
Basically, the main idea is to add an identifier, which will be used by
NGCP-panel when sending XMLRPC messages to SEMS, which will let SEMS know,
whether it's an event for a usual subscriber or a SIP peering.
Also we take care of loading time, when SEMS retrieves all previously saved data
from the DB using: peer / subscriber auth preferences and loads this to be usable.
A new query has been added for peering type, to let peerings be loadable after restart.
(real ticket number: TT#66577)
Change-Id: I0a815d50dd2728f2fa1411d21adfb084434766b2
add username_with_domain option to use auth user with domain part
(real ticket number: MT#9306)
implements M758
Change-Id: Ib482d4f1d49d291cab39add1b6a61c02c36bdbe4