The MySQL INSERT statements to move processed Redis acc records from
Redis to the respective backup/trash MySQL tables are always issued
within a MySQL transaction (med_handler via medmysql_batch_start), but
the deletions from Redis were done immediately. Therefore if mediator
were to abort within a processing loop, the MySQL transaction would be
rolled back after the entries had already been deleted from Redis,
therefore losing the acc entries.
Solve this by using an internal queue for Redis entries to hold the
lists of entries to be deleted until the MySQL transaction is commited.
Change-Id: Ib41d0e2ca722c66f9e078ca31f7e5ca2b9d9fe2d
When processing acc records for a call that was the result of a REFER,
there will be two BYE records, one for the call itself without further
info in dst_leg, and another one for the original call that includes the
record for the REFER, with extra info in dst_leg that points back to the
original call. Skip the BYE with this extra info when processing record
so that it's still present when the other call (with the REFER) is being
processed.
Change-Id: Ia8b405c1d9d556ccb30f9b51a0bbd001f48da180
This allows us to fetch only specific records that we're interested in,
based on context, instead of all of them and then having to do a second
pass over them.
Change-Id: I5e314fa633f57c79db85476e347a3305b5f585e9
Instead of using two lists to keep the acc records (based on where they
were retrieved from) use only a single list for all acc records.
Make sure the list is only appended to in the functions doing the record
retrieval.
Since the list of acc records needs to be sorted only when records were
retrieved from Redis, change the return value of the retrieval functions
to indiciate whether this needs to be done, or -1 for error.
Change-Id: Ie61c054b430cb5d390b1f2b742c64be1df831fd4
This makes it possible to reuse the data from the JSON object in several
places in the code without having to re-parse it.
Change-Id: I62f3b2b814acc52ae3fb84c88b7b4f99bff9232f
Use strdup/free for string fields in med_entry_t that are highly
variable in length. This elimiates future problems if one of these
fields ever has its length extended.
Use g_strdup as it guarantees a non-NULL return value.
Change-Id: Ia0f5883547feb62f04fcd4c5353850eb9d815413
Using an array in this context (to return a list of acc records) is
mostly pointless as it wastes memory and incurs the additional overhead
of having to initialise the array and an extra layer of copying strings
around. This also ultimately allows us to dynamically append to the list
of acc records without having to reallocate the array.
Change-Id: I1039f01861f8d3f82fdc3a80377fd7535fa24bab
Using an array in this context (to return a list of call IDs) is mostly
pointless as it wastes memory and incurs the additional overhead of
having to initialise the array and an extra layer of copying strings
around. This also eliminates the auxiliary type `med_callid_t` and
ultimately allows us to dynamically append to the list of call IDs
without having to reallocate the array.
Use g_strdup for string allocation as it guarantees a non-NULL return
value.
Change-Id: Iae6c97f80c216352ab36de89d361f09ee355b6c8
As the number of subscribers grows, the current approach of doing a full
table dump of the subscribers DB and caching it in memory becomes less
and less feasible. The new approach is to simply do a straight DB query
for each subscriber as records are processed, and then cache the result
in memory for a little while.
Change-Id: I19a6271d779bd0abccc29e3548e7bcdb2e00baa3
We cannot overwrite the reallocated variable, otherwise on failure we
leak it.
Change-Id: I541537ade71086c9ceb851d8c5223364e3908b07
Warned-by: cppcheck (memleakOnRealloc)
The mediator is doing nothing when maintenance mode is enabled,
it has been implemented in TT#16753 but later after migration to
systemd and after migration to unit 'type=notify' we forget to send READY=1.
Fixing it here, as it cause 90 seconds delay on ngcpcfg apply on
active node if maintenance mode is enabled.
Change-Id: I66c3dc13506f7069ec60c56edcbe875b4a9912e4
* type=id values are pre-fetched from cdr_tag_data on init
* 3 new data columns are stored in cdr_tag_data
furnished_charing_info,
header=P-Asserted-Identity
header=Diversion
Change-Id: I228743beb05cc09cc28d7df8dedc90dd3cdbcfed
* Fetch acc records both from mysql and redis
* Backup/trash redis acc records into mysql
* Introduce loglevel config option and log macros
Change-Id: I9bc55ed72502feaff03550c99ce481aea33e5e58
This is a callback, so we cannot control the interface. Just mark it as
unused with the __attribute__ keyword.
Warned-by: gcc -Wextra
Change-Id: If9ddfe5861b1113670cd4ec52696d869334951eb
We need a new configuration file for multiple reasons. For security
purposes, to avoid passing passwords as part of the program arguments,
which are publicly visible. And to be able to use systemd services
files, because there's at least the maintenance configuration that's set
conditionally, and that's not easily supported in systemd service files.
Refactor the code to make it easier to add a simple config file parser,
based on a key or key=value per line, with support for comments starting
with # on the first column.
In addition this also gives us long command-line options for the
existing short options.
Change-Id: I611f262847fa2ec4e3c569ca27e01b691e585fcc
In parsing config options, it might be possible that an option is
provided more than once, where the allocated string buffer is then
overwritten without being free'd.
When copying call codes, assume a fixed length size of 3.
Check return code of open() when opening /dev/null for std* re-
directs.
Fixed spaces vs tabs in intendations.
Use fropen() for daemonization.
Refactor medmysql_fetch_callids to return malloc'd array.
Change-Id: I51ab7ebc01bdd747c8b5bb320998a5c13d64009e
Revert logic to pick peer id from stop record. This needs a better
approach somehow.
Instead, add logic to always take -pbx_1 and -xfer_1 stop records
into account when searching for stop records, to fix duration of
CDRs on transfer and park/unpark (which is just a special case
of transfer).
Change-Id: Ia80add6d5cb762800c563889c0d95ee25ed74168
When enabled, mediator will look for acc records belonging to the
$ci_pbx-1 call leg and use the stop/bye records from this call leg in
place of the regular one.
Change-Id: I46d326fb30fcf105642d188a07ae771a659ff17f
- use separate user,pass,port,db for the stats database connection
- cosmetic change in the DEFAULT_STATS definition names
- add db connection info logging for PROV and STATS
Change-Id: I389bed46c634ac973616335581d7a7495d5866a3
- Calls info (call_code, period) data is accumulated into $stats_db.'call_info'
table on the cdr insert
- Add stats_db and stats_period options (1=hour, 2=day, 3=month)
Change-Id: I4e1f7655eebfbe45a43e2c34d9c3b3bffe05fb40
Squashed commit of the following:
commit e137454f9d871332ef055b3de8eb9c703caece03
Author: Richard Fuchs <rfuchs@sipwise.com>
Date: Fri Jul 25 11:03:17 2014 -0400
MT#8195 lookup peer host ID against peer group/contract ID
commit 47e3509e634d9892fc1e2bc8111df6a90416addc
Author: Richard Fuchs <rfuchs@sipwise.com>
Date: Fri Jul 18 11:03:23 2014 -0400
MT#8195 use dst_leg peer id