The index j we get is not the position in the output array/list, but
rather the index into the source array. Simply append each new element
to the array in order.
Also make sure we don't skip over empty elements in the array when
building the JSON list, so that the order is preserved.
Change-Id: Id6577410e114f0ddbea745977118f1bab2e38fa9
With the "foreign" flag now stored in call_flags, restoring a call from
Redis restores this flag as well, overwriting the desired flag as we had
set it through call_get_or_create().
Reverse the flag setting by taking it out of call_get_or_create() (where
it's always false anyway, except when coming from Redis) and setting it
explicitly with call_make_own_foreign() after restorting call and its
flags.
Change-Id: Ib68be2aeedfa988b7555e426fa337657e1062245
Move linking of the media to its monologue, from the `json_link_medias()`
to the `json_medias()`. This is required, becase the `json_link_medias()`
already needs to operate on medias list, which is fully linked
to their monologues. Otherwise it can happen, that during the
linking of media to media in `json_link_medias()` (subscribing them)
the monologue for the other media is still not linked.
Change-Id: Ifc4dd8dff27f65e664b4fd21332a1d296d07759b
Start using the media subscriptions model
(based on newly introduced `media_subscription` objects)
in scope of:
- `redis_encode_json()`
- `json_link_medias()`
- `rbl_subs_cb()`
Change-Id: I3f7267ab156b361d7e7bec4ff91a8976a7be02ee
Start using the media subscriptions model
(based on newly introduced `media_subscription` objects)
in scope of `__find_subscriber()`
Change-Id: Ief3e9d0785ad53884be347ca21d6766c3ad2b275
Previous implementation assumes that we use the `call_subscription`
objects in:
- `call_offer_answer_ng()`
- `call_update_lookup_udp()`
- `call_request_lookup_tcp()`
when appealing to the `call_get_mono_dialogue()`, in order to
get the `call_subscription` objects, in order to then pass it
for usage in the `monologue_offer_answer()`, where the most important
again is to use monologue references stored inside
the given `call_subscription` objects.
Instead of using the `call_subscription`, just use `call_monologue`
objects as a base data objects for this work,
which will allow us in the coming commits to deprecate
the `call_subscriptions` based model and
get to the subscription model based on medias.
Change-Id: Ia9ee5ba66522929acbceca28854ebccd3705635a
Pass the subscription object to codec_handlers_update to eliminate the
need for a return type and the subsequent if/else.
Change-Id: I311b3e8ca14ee5090cf329163975354385cee800
Using a pointer array instead of a linked lists allows us to directly
reference a media section by index number, without having to spool into
the linked list.
No functional changes.
Change-Id: I8b0e93f0c2e9addbcb4c938894118ed4a6aec768
Keep track which tags (monologues) were created together as part of an
offer/answer exchange with a separate hash table, regardless of whether
these monologues actually have tagged names or are just nameless
branches.
Change-Id: I60aa114c8caf6ecdff4705e3399f60190d04dda6
Create a dedicated struct to hold certain attributes shared by both sink
handlers and media subscriptions, as a preparation to simplify handling
these attributs.
Change-Id: I866159c33ed6d6a2873d2cf68c4906ea705d253e
This makes it possible to refactor and simplify the interface functions,
as pointers and offsets can't be utilised with bit fields.
Change-Id: I70f1ac0eca7d2ccf8e8d5f5794580163f3f5b7ad
Keyspace notifications are set up before existing calls are restored
(restore_thread). Therefore the following scenario is possible:
NOTIF THREAD: receives SET, creates call
RESTORE THREAD: executes KEYS *
NOTIF THREAD: receives another SET:
NOTIF THREAD: does call_destroy(), which:
adds ports to late-release list
RESTORE THREAD: comes across call ID, does GET
RESTORE THREAD: creates new call
RESTORE THREAD: wants to allocate ports, but they're still in use
NOTIF THREAD: now does release_closed_sockets()
Use a multi-A multi-B lock to protect the two code sections from each
other and make sure that notification threads have always released all
ports before a restore thread attempts to allocate any.
Reported in #1503
Change-Id: I322062488e2ce3515c5a3e6609a5700830ac1fd4
To prevent a race condition that might miss updates about call info, set
up the Redis keyspace notifications first and then run loop to restore
calls from the existing data.
closes#1503
Change-Id: I6afa4c50fe0a34c602063fc2f45b2ee38133cf1e
When ports are closed early (while the call is still running), we must
first update a slave rtpengine with this new information (that these
ports are now closed) before actually releasing the ports ourselves. Not
doing so leads to a race condition where the master instance re-uses a
port that was just closed before the slave instance knows about the port
being closed.
We implement this using a thread-local list to keep track of ports that
were released while processing a control message, and process this list
to actually close the ports only after Redis has been updated.
Additional calls to the function to close the ports are placed in
strategic locations to make sure this is triggered in every code path.
closes#1495
Change-Id: I803f4594f30ca315da0b84c6e76893f54ca3a7c9
This is useful for functions which are used both from a timer and from
other callers. These functions would reset the logging context at their
end to free the reference held by the logging context, which would
wrongly reset the logging context when the same function was called from
a different code path. Using a stack with push/pop semantics makes it
safe to use these functions from any code path.
Additionally introduce an explicit reset function that clears the entire
stack regardless of context. This reset function is called at the end of
every work iteration in every worker thread, just in case not everything
was popped from the stack.
Change-Id: I0e2c142b95806b26473c65a882737e39d161d24d
libcs are implementing changes to fix the year 2038 issue on 32 bit
platforms (see [1]). musl libc already went ahead and implemented it,
starting with musl-1.2.0 (see [2]).
This commit adds a new definition to lib/loglib.h:
TIME_T_INT_FMT
If __USE_TIME_BITS64 is defined (by a time64 libc, see [1]), it's set to
the proper conversions for type int64_t, PRId64. If __USE_TIME_BITS64 is
not defined, the status quo remains unchanged ("%ld" is used).
The new definition is used in the different parts of rtpengine, where
appropriate.
Note: Richard confirmed that the "%u" format in daemon/cdr.c is not
needed, so this gets swept under the rug.
These changes get rid of the new warnings that appeared with musl-1.2.0.
Below an example warning:
In file included from ./log.h:6,
from ../include/obj.h:94,
from ../include/media_socket.h:9,
from ../include/call.h:26,
from ../include/redis.h:15,
from redis.c:1:
redis.c: In function 'redis_check_conn':
../lib/loglib.h:56:30: warning: format '%ld' expects argument of type 'long int', but argument 5 has type 'time_t' {aka 'long long int'} [-Wformat=]
56 | __ilog(prio, "[%s] " fmt, log_level_names[system], ##__VA_ARGS__); \
| ^~~~~~~
../lib/loglib.h:64:39: note: in expansion of macro 'ilogsn'
64 | #define ilogs(system, prio, fmt, ...) ilogsn(log_level_index_ ## system, prio, fmt, ##__VA_ARGS__)
| ^~~~~~
../lib/loglib.h:63:30: note: in expansion of macro 'ilogs'
63 | #define ilog(prio, fmt, ...) ilogs(core, prio, fmt, ##__VA_ARGS__)
| ^~~~~
redis.c:887:17: note: in expansion of macro 'ilog'
887 | ilog(LOG_WARNING, "Redis server %s is disabled. Don't try RE-Establishing for %ld more seconds",
| ^~~~
[1] https://sourceware.org/glibc/wiki/Y2038ProofnessDesign
[2] https://musl.libc.org/time64.html
Signed-off-by: Sebastian Kemper <sebastian_ml@gmx.net>
This makes it possible to add new streams without specifying the
direction/interface again.
Reported in #1366
Change-Id: I8f320ecbe72f123d755ba80370de9c40960eb0f0
If a keyspace notification SET is received and the call already exists
as a foreign call, the call is first destroyed before being re-restored.
The call destruction involves a DEL from Redis on the "hosted DB"
number, which points to the foreign DB. This makes it impossible to then
restore the call because it's just been deleted.
closes#1308closes#1334
Change-Id: Ie895b021441b2d299f8ebb5bde1824b01e12633c
commit d15fd4a547
Author: Damir Nedžibović <damir.nedzibovic@enreach.com>
Date: Tue Jul 6 14:07:42 2021 +0200
Also free the character data.
commit 8869187215
Author: Damir Nedžibović <damir.nedzibovic@enreach.com>
Date: Mon Jul 5 16:11:32 2021 +0200
Make documentation and parameters consistant.
commit 4b15aea2ee
Author: Damir Nedžibović <damir.nedzibovic@enreach.com>
Date: Thu Jun 10 15:34:00 2021 +0200
Update documentation.
commit 6ec1b3035d
Author: Damir Nedžibović <damir.nedzibovic@enreach.com>
Date: Thu Jun 10 15:33:12 2021 +0200
Do not use metadata for setting the recording file; use output_destination instead.
commit f65a76e8a3
Author: Damir Nedžibović <damir.nedzibovic@enreach.com>
Date: Wed Jun 9 15:56:02 2021 +0200
Only append file extension if skip_filename_extension is not set.
commit 92e9d7c679
Author: Damir Nedžibović <damir.nedzibovic@enreach.com>
Date: Wed Jun 9 14:12:48 2021 +0200
Rename the option to better match its usage.
commit 11128bff49
Author: Damir Nedžibović <damir.nedzibovic@enreach.com>
Date: Wed Jun 9 13:19:10 2021 +0200
Implement support for seting an output file and folder per recording.
Change-Id: I1579d62467eaf06a7aa1ac11e59dbb374f150deb
Complete overhaul of the codec handling code:
*) obsolete flags `asymmetric codecs`, `symmetric codecs`, `reorder
codecs`
*) support proper codec offer/answer
*) split codec manipulation (strip/offer/accept/etc) into separate
functions for clarity and better code maintenance
*) fully update codec handlers in both directions after an answer
*) explicit allocation and handling of codecs and payload types in a
codec_store object
*) improve codec matchup logic during answer
*) more explicit handling of supplemental codecs (CN/DTMF)
*) remove now obsolete hacks for handling certain use cases
Change-Id: I996705ba8fe339524c2f70e6bb0fd854f9a1f4fb
This solves problems when the same SSRC is looped through the same call
multiple times in different mono/dialogues, with different parameters.
Change-Id: I1d033cb1f012574d82b5bcbfffe11eb5f983cfd8
This makes the type in line with string(3) functions and eliminates some
compiler warnings.
Also update the related bencode data type.
Change-Id: I7ef4024f4b5a0f737b3dbe03bcd078032395bce6
Initially created branches don't have a tag associated with them, so
they don't appear in `other_tags`. We need to keep track of which
branches were created from a single from-tag through their via-branch
values so we know when all branches have been deleted.
closes#1037
Change-Id: I4c6ce602b99a9104de98098cd06ca399eb28e1b2
Commit a6d2f9296 introduced usage of libevent_global_shutdown(),
which is available in libevent-dev >=2.1.1-alpha only.
For example travis CI is running Ubuntu 16.04 / xenial and ships
libevent-dev 2.0.21-stable-2, so we can't just raise the
build-dependency of libevent-dev to >= 2.1.1+ if we still want
to support older systems.
Change-Id: I9dcf9ca0a19f59051d42f0d2383d1938b60a97df
fix cleanup being skipped on redis slaves
fixes an SDES related Redis mem leak
adds a hash for the ports free list to avoid duplicate entries
fixes#898
Change-Id: I34aad67290ff5ef8824142682aac03cb600d0ecb
stun.c: In function ‘stun_error_len’:
stun.c:388:62: warning: taking address of packed member of ‘struct header’ may result in an unaligned pointer value [-Waddress-of-packed-member]
388 | output_init(&mh, iov, &hdr, STUN_BINDING_ERROR_RESPONSE, req->transaction);
| ~~~^~~~~~~~~~~~~
stun.c: In function ‘stun_binding_success’:
stun.c:479:64: warning: taking address of packed member of ‘struct header’ may result in an unaligned pointer value [-Waddress-of-packed-member]
479 | output_init(&mh, iov, &hdr, STUN_BINDING_SUCCESS_RESPONSE, req->transaction);
| ~~~^~~~~~~~~~~~~
stun.c: In function ‘__stun_success’:
stun.c:540:42: warning: taking address of packed member of ‘struct header’ may result in an unaligned pointer value [-Waddress-of-packed-member]
540 | return ice_response(sfd, sin, attrs, req->transaction);
| ~~~^~~~~~~~~~~~~
stun.c: In function ‘__stun_error’:
stun.c:545:42: warning: taking address of packed member of ‘struct header’ may result in an unaligned pointer value [-Waddress-of-packed-member]
545 | return ice_response(sfd, sin, attrs, req->transaction);
| ~~~^~~~~~~~~~~~~
redis.c: In function ‘redis_hash_get_sdes_params.isra.0’:
redis.c:1095:39: warning: ‘_tag’ directive output may be truncated writing 4 bytes into a region of size between 1 and 32 [-Wformat-truncation=]
1095 | snprintf(tagkey, sizeof(tagkey), "%s_tag", kk);
| ^~~~
In file included from /usr/include/stdio.h:867,
from ../lib/str.h:9,
from ../lib/compat.h:16,
from ../include/redis.h:8,
from redis.c:1:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:67:10: note: ‘__builtin___snprintf_chk’ output between 5 and 36 bytes into a destination of size 32
67 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
68 | __bos (__s), __fmt, __va_arg_pack ());
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Change-Id: I214458fd3f596e565b1bba9d88808b7c99f9c876
We need to set the redis context to NULL after freeing it, otherwise
other code will try to free it again, which will make the program
abort when exiting.
Change-Id: Id634075344351eb1c924c59739b72bbf57de3c89
We should offer all crypto suites that we support. If passing through
SDES, we should amend the list of crypto suites with all additional ones
that we support that weren't included in the received offer.
closes#577
Change-Id: I9b6c16e8eadecf01cdbc8043bd8361e0f683e456
Instead of just remembering the last seen RTP payload type, this adds a
tracker that keeps track of the last 32 seen payload types and keep the
list in order of how often each type was seen.
Change-Id: I062a43b7bfc9413b755dca548d72953ff8245477
Force re-checking of the synchronous redis context state in case of processing
a redis notification. It is possible that redis async context is up while the
blocking one is down.