MT#55283 convert call structs to int64_t

Change-Id: If1a077d206d96914651b3e4624e7fc09f239ed09
pull/2061/head
Richard Fuchs 1 year ago
parent 9405f3df63
commit ad65c9096f

@ -79,7 +79,7 @@ static struct media_subscription *__subscribe_medias_both_ways(struct call_media
static int call_timer_delete_monologues(call_t *c) { static int call_timer_delete_monologues(call_t *c) {
struct call_monologue *ml; struct call_monologue *ml;
int ret = 0; int ret = 0;
time_t min_deleted = 0; int64_t min_deleted = 0;
bool update = false; bool update = false;
/* we need a write lock here */ /* we need a write lock here */
@ -89,11 +89,11 @@ static int call_timer_delete_monologues(call_t *c) {
for (__auto_type i = c->monologues.head; i; i = i->next) { for (__auto_type i = c->monologues.head; i; i = i->next) {
ml = i->data; ml = i->data;
if (!ml->deleted) if (!ml->deleted_us)
continue; continue;
if (ml->deleted > timeval_from_us(rtpe_now).tv_sec) { if (ml->deleted_us > rtpe_now) {
if (!min_deleted || ml->deleted < min_deleted) if (!min_deleted || ml->deleted_us < min_deleted)
min_deleted = ml->deleted; min_deleted = ml->deleted_us;
continue; continue;
} }
@ -101,7 +101,7 @@ static int call_timer_delete_monologues(call_t *c) {
update = true; update = true;
} }
c->ml_deleted = min_deleted; c->ml_deleted_us = min_deleted;
rwlock_unlock_w(&c->master_lock); rwlock_unlock_w(&c->master_lock);
if (update) if (update)
@ -141,7 +141,7 @@ static void call_timer_iterator(call_t *c, struct iterator_helper *hlp) {
// final timeout applicable to all calls (own and foreign) // final timeout applicable to all calls (own and foreign)
if (atomic_get_na(&rtpe_config.final_timeout) if (atomic_get_na(&rtpe_config.final_timeout)
&& timeval_from_us(rtpe_now).tv_sec >= (timeval_from_us(c->created).tv_sec + atomic_get_na(&rtpe_config.final_timeout))) && rtpe_now >= (c->created + atomic_get_na(&rtpe_config.final_timeout) * 1000000LL)) // XXX scale to micro
{ {
ilog(LOG_INFO, "Closing call due to final timeout"); ilog(LOG_INFO, "Closing call due to final timeout");
tmp_t_reason = FINAL_TIMEOUT; tmp_t_reason = FINAL_TIMEOUT;
@ -159,11 +159,11 @@ static void call_timer_iterator(call_t *c, struct iterator_helper *hlp) {
goto out; goto out;
} }
if (c->deleted && timeval_from_us(rtpe_now).tv_sec >= c->deleted if (c->deleted_us && rtpe_now >= c->deleted_us
&& c->last_signal <= c->deleted) && c->last_signal_us <= c->deleted_us)
goto delete; goto delete;
if (c->ml_deleted && timeval_from_us(rtpe_now).tv_sec >= c->ml_deleted) { if (c->ml_deleted_us && rtpe_now >= c->ml_deleted_us) {
if (call_timer_delete_monologues(c)) if (call_timer_delete_monologues(c))
goto delete; goto delete;
} }
@ -174,7 +174,7 @@ static void call_timer_iterator(call_t *c, struct iterator_helper *hlp) {
// ignore media timeout if call was recently taken over // ignore media timeout if call was recently taken over
if (CALL_ISSET(c, FOREIGN_MEDIA) if (CALL_ISSET(c, FOREIGN_MEDIA)
&& timeval_from_us(rtpe_now).tv_sec - c->last_signal <= atomic_get_na(&rtpe_config.timeout)) && rtpe_now - c->last_signal_us <= atomic_get_na(&rtpe_config.timeout) * 1000000L) // XXX scale to micro
goto out; goto out;
ice_fragments_cleanup(c->sdp_fragments, false); ice_fragments_cleanup(c->sdp_fragments, false);
@ -237,14 +237,14 @@ no_sfd:
if (good) if (good)
goto next; goto next;
check = atomic_get_na(&rtpe_config.timeout) * 1000000L; // XXX scale to micro check = atomic_get_na(&rtpe_config.timeout) * 1000000LL; // XXX scale to micro
tmp_t_reason = TIMEOUT; tmp_t_reason = TIMEOUT;
if (!MEDIA_ISSET(ps->media, RECV) || !sfd) { if (!MEDIA_ISSET(ps->media, RECV) || !sfd) {
check = atomic_get_na(&rtpe_config.silent_timeout) * 1000000L; // XXX scale to micro check = atomic_get_na(&rtpe_config.silent_timeout) * 1000000LL; // XXX scale to micro
tmp_t_reason = SILENT_TIMEOUT; tmp_t_reason = SILENT_TIMEOUT;
} }
else if (!PS_ISSET(ps, FILLED)) { else if (!PS_ISSET(ps, FILLED)) {
check = atomic_get_na(&rtpe_config.offer_timeout) * 1000000L; // XXX scale to micro check = atomic_get_na(&rtpe_config.offer_timeout) * 1000000LL; // XXX scale to micro
tmp_t_reason = OFFER_TIMEOUT; tmp_t_reason = OFFER_TIMEOUT;
} }
@ -277,7 +277,7 @@ next:
goto out; goto out;
} }
if (c->ml_deleted) if (c->ml_deleted_us)
goto out; goto out;
for (__auto_type it = c->monologues.head; it; it = it->next) { for (__auto_type it = c->monologues.head; it; it = it->next) {
@ -2720,8 +2720,8 @@ static void __call_monologue_init_from_flags(struct call_monologue *ml, struct c
{ {
call_t *call = ml->call; call_t *call = ml->call;
call->last_signal = timeval_from_us(rtpe_now).tv_sec; call->last_signal_us = rtpe_now;
call->deleted = 0; call->deleted_us = 0;
call->media_rec_slots = (flags->media_rec_slots > 0 && call->media_rec_slots == 0) call->media_rec_slots = (flags->media_rec_slots > 0 && call->media_rec_slots == 0)
? flags->media_rec_slots ? flags->media_rec_slots
: call->media_rec_slots; : call->media_rec_slots;
@ -4087,14 +4087,14 @@ void call_destroy(call_t *c) {
// stats output only - no cleanups // stats output only - no cleanups
ilog(LOG_INFO, "--- Tag '" STR_FORMAT_M "'%s"STR_FORMAT"%s, created " ilog(LOG_INFO, "--- Tag '" STR_FORMAT_M "'%s" STR_FORMAT "%s, created "
"%u:%02u ago for branch '" STR_FORMAT_M "'", "%u:%02u ago for branch '" STR_FORMAT_M "'",
STR_FMT_M(&ml->tag), STR_FMT_M(&ml->tag),
ml->label.s ? " (label '" : "", ml->label.s ? " (label '" : "",
STR_FMT(ml->label.s ? &ml->label : &STR_EMPTY), STR_FMT(ml->label.s ? &ml->label : &STR_EMPTY),
ml->label.s ? "')" : "", ml->label.s ? "')" : "",
(unsigned int) (timeval_from_us(rtpe_now).tv_sec - ml->created) / 60, (unsigned int) ((rtpe_now - ml->created_us) / 1000000LL) / 60,
(unsigned int) (timeval_from_us(rtpe_now).tv_sec - ml->created) % 60, (unsigned int) ((rtpe_now - ml->created_us) / 1000000LL) % 60,
STR_FMT_M(&ml->viabranch)); STR_FMT_M(&ml->viabranch));
for (__auto_type alias = ml->tag_aliases.head; alias; alias = alias->next) for (__auto_type alias = ml->tag_aliases.head; alias; alias = alias->next)
@ -4199,12 +4199,12 @@ void call_destroy(call_t *c) {
se->average_mos.mos / mos_samples % 10, se->average_mos.mos / mos_samples % 10,
se->lowest_mos->mos / 10, se->lowest_mos->mos / 10,
se->lowest_mos->mos % 10, se->lowest_mos->mos % 10,
((se->lowest_mos->reported - c->created) / 1000000) / 60, ((se->lowest_mos->reported - c->created) / 1000000L) / 60,
((se->lowest_mos->reported - c->created) / 1000000) % 60, ((se->lowest_mos->reported - c->created) / 1000000L) % 60,
se->highest_mos->mos / 10, se->highest_mos->mos / 10,
se->highest_mos->mos % 10, se->highest_mos->mos % 10,
((se->highest_mos->reported - c->created) / 1000000) / 60, ((se->highest_mos->reported - c->created) / 1000000L) / 60,
((se->highest_mos->reported - c->created) / 1000000) % 60, ((se->highest_mos->reported - c->created) / 1000000L) % 60,
(unsigned int) se->packets_lost); (unsigned int) se->packets_lost);
ilog(LOG_INFO, "------ respective (avg/min/max) jitter %" PRIu64 "/%" PRIu64 "/%" PRIu64 " ms, " ilog(LOG_INFO, "------ respective (avg/min/max) jitter %" PRIu64 "/%" PRIu64 "/%" PRIu64 " ms, "
"RTT-e2e %" PRIu64 ".%" PRIu64 "/%" PRIu64 ".%" PRIu64 "RTT-e2e %" PRIu64 ".%" PRIu64 "/%" PRIu64 ".%" PRIu64
@ -4679,7 +4679,7 @@ struct call_monologue *__monologue_create(call_t *call) {
ret = uid_alloc(&call->monologues); ret = uid_alloc(&call->monologues);
ret->call = call; ret->call = call;
ret->created = timeval_from_us(rtpe_now).tv_sec; ret->created_us = rtpe_now;
ret->associated_tags = g_hash_table_new(g_direct_hash, g_direct_equal); ret->associated_tags = g_hash_table_new(g_direct_hash, g_direct_equal);
ret->medias = medias_arr_new(); ret->medias = medias_arr_new();
ret->media_ids = media_id_ht_new(); ret->media_ids = media_id_ht_new();
@ -4870,7 +4870,7 @@ void monologue_destroy(struct call_monologue *monologue) {
} }
} }
monologue->deleted = 0; monologue->deleted_us = 0;
} }
/* must be called with call->master_lock held in W */ /* must be called with call->master_lock held in W */
@ -4897,9 +4897,9 @@ static bool monologue_delete_iter(struct call_monologue *a, int delete_delay) {
ilog(LOG_INFO, "Scheduling deletion of call branch '" STR_FORMAT_M "' " ilog(LOG_INFO, "Scheduling deletion of call branch '" STR_FORMAT_M "' "
"(via-branch '" STR_FORMAT_M "') in %d seconds", "(via-branch '" STR_FORMAT_M "') in %d seconds",
STR_FMT_M(&a->tag), STR_FMT0_M(&a->viabranch), delete_delay); STR_FMT_M(&a->tag), STR_FMT0_M(&a->viabranch), delete_delay);
a->deleted = timeval_from_us(rtpe_now).tv_sec + delete_delay; a->deleted_us = rtpe_now + delete_delay * 1000000LL; // XXX scale to micro
if (!call->ml_deleted || call->ml_deleted > a->deleted) if (!call->ml_deleted_us || call->ml_deleted_us > a->deleted_us)
call->ml_deleted = a->deleted; call->ml_deleted_us = a->deleted_us;
} }
else { else {
ilog(LOG_INFO, "Deleting call branch '" STR_FORMAT_M "' (via-branch '" STR_FORMAT_M "')", ilog(LOG_INFO, "Deleting call branch '" STR_FORMAT_M "' (via-branch '" STR_FORMAT_M "')",
@ -4956,8 +4956,8 @@ struct call_monologue *call_get_or_create_monologue(call_t *call, const str *fro
* associated with another one, which happens during offer/answer. * associated with another one, which happens during offer/answer.
*/ */
static void __tags_associate(struct call_monologue *a, struct call_monologue *b) { static void __tags_associate(struct call_monologue *a, struct call_monologue *b) {
a->deleted = 0; a->deleted_us = 0;
b->deleted = 0; b->deleted_us = 0;
g_hash_table_insert(a->associated_tags, b, b); g_hash_table_insert(a->associated_tags, b, b);
g_hash_table_insert(b->associated_tags, a, a); g_hash_table_insert(b->associated_tags, a, a);
} }
@ -5357,7 +5357,7 @@ del_all:
if (delete_delay > 0) { if (delete_delay > 0) {
ilog(LOG_INFO, "Scheduling deletion of entire call in %d seconds", delete_delay); ilog(LOG_INFO, "Scheduling deletion of entire call in %d seconds", delete_delay);
c->deleted = timeval_from_us(rtpe_now).tv_sec + delete_delay; c->deleted_us = rtpe_now + delete_delay * 1000000LL; // XXX scale to micro
rwlock_unlock_w(&c->master_lock); rwlock_unlock_w(&c->master_lock);
} }
else { else {

@ -448,7 +448,7 @@ static void call_status_iterator(call_t *c, struct streambuf_stream *s) {
streambuf_printf(s->outbuf, "session "STR_FORMAT" - - - - %" PRId64 "\n", streambuf_printf(s->outbuf, "session "STR_FORMAT" - - - - %" PRId64 "\n",
STR_FMT(&c->callid), STR_FMT(&c->callid),
(rtpe_now - c->created) / 1000000); (rtpe_now - c->created) / 1000000L);
/* XXX restore function */ /* XXX restore function */
@ -2796,9 +2796,9 @@ static void ng_stats_stream(ng_command_ctx_t *ctx, parser_arg list, const struct
if (ps->crypto.params.crypto_suite) if (ps->crypto.params.crypto_suite)
parser->dict_add_string(dict, "crypto suite", parser->dict_add_string(dict, "crypto suite",
ps->crypto.params.crypto_suite->name); ps->crypto.params.crypto_suite->name);
parser->dict_add_int(dict, "last packet", packet_stream_last_packet(ps) / 1000000LL); parser->dict_add_int(dict, "last packet", packet_stream_last_packet(ps) / 1000000L);
parser->dict_add_int(dict, "last kernel packet", atomic64_get_na(&ps->stats_in->last_packet_us) / 1000000LL); parser->dict_add_int(dict, "last kernel packet", atomic64_get_na(&ps->stats_in->last_packet_us) / 1000000L);
parser->dict_add_int(dict, "last user packet", atomic64_get_na(&ps->last_packet_us) / 1000000LL); parser->dict_add_int(dict, "last user packet", atomic64_get_na(&ps->last_packet_us) / 1000000L);
flags = parser->dict_add_list(dict, "flags"); flags = parser->dict_add_list(dict, "flags");
@ -2931,7 +2931,7 @@ static void ng_stats_monologue(ng_command_ctx_t *ctx, parser_arg dict, const str
} }
if (ml->label.s) if (ml->label.s)
parser->dict_add_str(sub, "label", &ml->label); parser->dict_add_str(sub, "label", &ml->label);
parser->dict_add_int(sub, "created", ml->created); parser->dict_add_int(sub, "created", ml->created_us / 1000000L);
if (ml->metadata.s) if (ml->metadata.s)
parser->dict_add_str(sub, "metadata", &ml->metadata); parser->dict_add_str(sub, "metadata", &ml->metadata);
@ -3013,7 +3013,7 @@ static void ng_stats_ssrc_mos_entry(const ng_parser_t *parser, parser_arg subent
struct ssrc_stats_block *sb) struct ssrc_stats_block *sb)
{ {
ng_stats_ssrc_mos_entry_common(parser, subent, sb, 1); ng_stats_ssrc_mos_entry_common(parser, subent, sb, 1);
parser->dict_add_int(subent, "reported at", sb->reported / 1000000); parser->dict_add_int(subent, "reported at", sb->reported / 1000000L);
} }
static void ng_stats_ssrc_mos_entry_dict(const ng_parser_t *parser, parser_arg ent, const char *label, static void ng_stats_ssrc_mos_entry_dict(const ng_parser_t *parser, parser_arg ent, const char *label,
struct ssrc_stats_block *sb) struct ssrc_stats_block *sb)
@ -3058,7 +3058,7 @@ static void ng_stats_ssrc(const ng_parser_t *parser, parser_arg dict, const stru
= ((struct ssrc_stats_block *) se->stats_blocks.tail->data)->reported = ((struct ssrc_stats_block *) se->stats_blocks.tail->data)->reported
- sb->reported; - sb->reported;
interval /= 10; interval /= 10;
parser->dict_add_int(progdict, "interval", interval / 1000000); parser->dict_add_int(progdict, "interval", interval / 1000000L);
int64_t next_step = sb->reported; int64_t next_step = sb->reported;
parser_arg entlist = parser->dict_add_list(progdict, "entries"); parser_arg entlist = parser->dict_add_list(progdict, "entries");
@ -3095,10 +3095,10 @@ void ng_call_stats(ng_command_ctx_t *ctx, call_t *call, const str *fromtag, cons
parser = ctx->parser_ctx.parser; parser = ctx->parser_ctx.parser;
parser->dict_add_int(ctx->resp, "created", call->created / 1000000); parser->dict_add_int(ctx->resp, "created", call->created / 1000000L);
parser->dict_add_int(ctx->resp, "created_us", call->created % 1000000); parser->dict_add_int(ctx->resp, "created_us", call->created % 1000000L);
parser->dict_add_int(ctx->resp, "created_ts", call->created); parser->dict_add_int(ctx->resp, "created_ts", call->created);
parser->dict_add_int(ctx->resp, "last signal", call->last_signal); parser->dict_add_int(ctx->resp, "last signal", call->last_signal_us / 1000000L);
parser->dict_add_int(ctx->resp, "last redis update", atomic64_get_na(&call->last_redis_update)); parser->dict_add_int(ctx->resp, "last redis update", atomic64_get_na(&call->last_redis_update));
if (call->metadata.s) if (call->metadata.s)
parser->dict_add_str(ctx->resp, "metadata", &call->metadata); parser->dict_add_str(ctx->resp, "metadata", &call->metadata);

@ -48,7 +48,7 @@ void cdr_update_entry(call_t * c) {
if (_log_facility_cdr) { if (_log_facility_cdr) {
g_string_append_printf(cdr, "ci=%s, ",c->callid.s); g_string_append_printf(cdr, "ci=%s, ",c->callid.s);
g_string_append_printf(cdr, "created_from=%s, ", c->created_from); g_string_append_printf(cdr, "created_from=%s, ", c->created_from);
g_string_append_printf(cdr, "last_signal=%llu, ", (unsigned long long)c->last_signal); g_string_append_printf(cdr, "last_signal=%" PRId64 ", ", c->last_signal_us / 1000000L);
g_string_append_printf(cdr, "tos=%u, ", (unsigned int)c->tos); g_string_append_printf(cdr, "tos=%u, ", (unsigned int)c->tos);
} }

@ -363,7 +363,7 @@ next:;
// destroy calls // destroy calls
call_t *c = NULL; call_t *c = NULL;
while ((c = t_queue_pop_head(&calls))) { while ((c = t_queue_pop_head(&calls))) {
if (!c->ml_deleted) { if (!c->ml_deleted_us) {
for (__auto_type i = c->monologues.head; i; i = i->next) { for (__auto_type i = c->monologues.head; i; i = i->next) {
ml = i->data; ml = i->data;
ml->terminated = rtpe_now; ml->terminated = rtpe_now;
@ -695,14 +695,14 @@ static void cli_list_call_info(struct cli_writer *cw, call_t *c) {
"created: %" PRId64 "\n" "created: %" PRId64 "\n"
"proxy: %s\n" "proxy: %s\n"
"tos: %u\n" "tos: %u\n"
"last_signal: %llu\n" "last_signal: %" PRId64 "\n"
"redis_keyspace: %i\n" "redis_keyspace: %i\n"
"last redis update: %llu\n" "last redis update: %llu\n"
"foreign: %s\n" "foreign: %s\n"
"recording: %s\n" "recording: %s\n"
"\n", "\n",
c->callid.s, c->ml_deleted ? "yes" : "no", c->created / 1000000, c->created_from, c->callid.s, c->ml_deleted_us ? "yes" : "no", c->created / 1000000, c->created_from,
(unsigned int) c->tos, (unsigned long long) c->last_signal, c->redis_hosted_db, (unsigned int) c->tos, c->last_signal_us / 1000000L, c->redis_hosted_db,
(unsigned long long) atomic64_get_na(&c->last_redis_update), (unsigned long long) atomic64_get_na(&c->last_redis_update),
IS_FOREIGN_CALL(c) ? "yes" : "no", c->recording ? "yes" : "no"); IS_FOREIGN_CALL(c) ? "yes" : "no", c->recording ? "yes" : "no");
@ -868,7 +868,7 @@ static void cli_incoming_list_sessions(str *instr, struct cli_writer *cw, const
found = true; found = true;
cw->cw_printf(cw, "ID: %60s | del:%s | creat:%12" PRId64 " | prx:%s | redis:%2i | frgn:%s | rec:%s\n", cw->cw_printf(cw, "ID: %60s | del:%s | creat:%12" PRId64 " | prx:%s | redis:%2i | frgn:%s | rec:%s\n",
call->callid.s, call->ml_deleted ? "y" : "n", call->callid.s, call->ml_deleted_us ? "y" : "n",
call->created / 1000000, call->created / 1000000,
call->created_from, call->redis_hosted_db, call->created_from, call->redis_hosted_db,
IS_FOREIGN_CALL(call) ? "y" : "n", IS_FOREIGN_CALL(call) ? "y" : "n",
@ -1129,7 +1129,7 @@ static void cli_incoming_terminate(str *instr, struct cli_writer *cw, const cli_
return; return;
} }
if (!c->ml_deleted) { if (!c->ml_deleted_us) {
for (__auto_type i = c->monologues.head; i; i = i->next) { for (__auto_type i = c->monologues.head; i; i = i->next) {
ml = i->data; ml = i->data;
ml->terminated = rtpe_now; ml->terminated = rtpe_now;
@ -1248,10 +1248,10 @@ static void cli_incoming_active_standby(struct cli_writer *cw, bool foreign) {
ITERATE_CALL_LIST_START(CALL_ITERATOR_MAIN, c); ITERATE_CALL_LIST_START(CALL_ITERATOR_MAIN, c);
rwlock_lock_w(&c->master_lock); rwlock_lock_w(&c->master_lock);
call_make_own_foreign(c, foreign); call_make_own_foreign(c, foreign);
c->last_signal = MAX(c->last_signal, timeval_from_us(rtpe_now).tv_sec); c->last_signal_us = MAX(c->last_signal_us, rtpe_now);
if (!foreign) { if (!foreign) {
CALL_SET(c, FOREIGN_MEDIA); // ignore timeout until we have media CALL_SET(c, FOREIGN_MEDIA); // ignore timeout until we have media
c->last_signal++; // we are authoritative now c->last_signal_us++; // we are authoritative now
} }
rwlock_unlock_w(&c->master_lock); rwlock_unlock_w(&c->master_lock);
redis_update_onekey(c, rtpe_redis_write); redis_update_onekey(c, rtpe_redis_write);

@ -1878,7 +1878,7 @@ void kernelize(struct packet_stream *stream) {
g_free(redi); g_free(redi);
} }
stream->kernel_time = timeval_from_us(rtpe_now).tv_sec; stream->kernel_time_us = rtpe_now;
PS_SET(stream, KERNELIZED); PS_SET(stream, KERNELIZED);
return; return;
@ -1886,7 +1886,7 @@ no_kernel_warn:
ilog(LOG_WARNING, "No support for kernel packet forwarding available (%s)", nk_warn_msg); ilog(LOG_WARNING, "No support for kernel packet forwarding available (%s)", nk_warn_msg);
no_kernel: no_kernel:
PS_SET(stream, KERNELIZED); PS_SET(stream, KERNELIZED);
stream->kernel_time = timeval_from_us(rtpe_now).tv_sec; stream->kernel_time_us = rtpe_now;
PS_SET(stream, NO_KERNEL_SUPPORT); PS_SET(stream, NO_KERNEL_SUPPORT);
} }
@ -2508,7 +2508,7 @@ static bool media_packet_address_check(struct packet_handler_ctx *phc)
/* wait at least 3 seconds after last signal before committing to a particular /* wait at least 3 seconds after last signal before committing to a particular
* endpoint address */ * endpoint address */
bool wait_time = false; bool wait_time = false;
if (!phc->mp.call->last_signal || timeval_from_us(rtpe_now).tv_sec <= phc->mp.call->last_signal + 3) if (!phc->mp.call->last_signal_us || rtpe_now <= phc->mp.call->last_signal_us + 3000000LL)
wait_time = true; wait_time = true;
const struct endpoint *use_endpoint_confirm = &phc->mp.fsin; const struct endpoint *use_endpoint_confirm = &phc->mp.fsin;

@ -1120,7 +1120,15 @@ static atomic64 strtoa64(const char *c, char **endp, int base) {
return ret; return ret;
} }
define_get_int_type(time_t, time_t, strtoull); static int64_t time_t_conv(const char *c, char **endp, int base) {
// hack for compatibility - to be removed XXX
int64_t us = strtoll(c, endp, base);
if (us < 4000000LL)
return us * 1000000L;
return us;
}
define_get_int_type(time_t, int64_t, time_t_conv);
define_get_int_type(int64_t, int64_t, strtoll); define_get_int_type(int64_t, int64_t, strtoll);
define_get_int_type(int, int, strtol); define_get_int_type(int, int, strtol);
define_get_int_type(llu, unsigned long long, strtoll); define_get_int_type(llu, unsigned long long, strtoll);
@ -1486,7 +1494,7 @@ static int redis_tags(call_t *c, struct redis_list *tags, parser_arg arg) {
if (!ml) if (!ml)
return -1; return -1;
if (redis_hash_get_time_t(&ml->created, rh, "created")) if (redis_hash_get_time_t(&ml->created_us, rh, "created"))
return -1; return -1;
if (!redis_hash_get_str(&s, rh, "tag")) if (!redis_hash_get_str(&s, rh, "tag"))
__monologue_tag(ml, &s); __monologue_tag(ml, &s);
@ -1496,7 +1504,7 @@ static int redis_tags(call_t *c, struct redis_list *tags, parser_arg arg) {
ml->label = call_str_cpy(&s); ml->label = call_str_cpy(&s);
if (!redis_hash_get_str(&s, rh, "metadata")) if (!redis_hash_get_str(&s, rh, "metadata"))
c->metadata = call_str_cpy(&s); c->metadata = call_str_cpy(&s);
redis_hash_get_time_t(&ml->deleted, rh, "deleted"); redis_hash_get_time_t(&ml->deleted_us, rh, "deleted");
if (!redis_hash_get_int(&ii, rh, "block_dtmf")) if (!redis_hash_get_int(&ii, rh, "block_dtmf"))
ml->block_dtmf = ii; ml->block_dtmf = ii;
if (!redis_hash_get_a64(&a64, rh, "ml_flags")) if (!redis_hash_get_a64(&a64, rh, "ml_flags"))
@ -2002,7 +2010,7 @@ static void json_restore_call(struct redis *r, const str *callid, bool foreign)
struct redis_list tags, sfds, streams, medias, maps; struct redis_list tags, sfds, streams, medias, maps;
call_t *c = NULL; call_t *c = NULL;
str s, id; str s, id;
time_t last_signal; int64_t last_signal;
const char *err = 0; const char *err = 0;
int i; int i;
@ -2068,13 +2076,13 @@ static void json_restore_call(struct redis *r, const str *callid, bool foreign)
if (redis_hash_get_time_t(&last_signal, &call, "last_signal")) if (redis_hash_get_time_t(&last_signal, &call, "last_signal"))
goto err3; goto err3;
if (c->last_signal) { if (c->last_signal_us) {
err = NULL; err = NULL;
// is the call we're loading newer than the one we have? // is the call we're loading newer than the one we have?
if (last_signal > c->last_signal) { if (last_signal > c->last_signal_us) {
// switch ownership // switch ownership
call_make_own_foreign(c, foreign); call_make_own_foreign(c, foreign);
c->last_signal = last_signal; c->last_signal_us = last_signal;
} }
goto err3; // no error, just bail goto err3; // no error, just bail
} }
@ -2099,13 +2107,13 @@ static void json_restore_call(struct redis *r, const str *callid, bool foreign)
if (redis_hash_get_int64_t(&c->created, &call, "created")) if (redis_hash_get_int64_t(&c->created, &call, "created"))
goto err8; goto err8;
redis_hash_get_int64_t(&c->destroyed, &call, "destroyed"); redis_hash_get_int64_t(&c->destroyed, &call, "destroyed");
c->last_signal = last_signal; c->last_signal_us = last_signal;
if (redis_hash_get_int(&i, &call, "tos")) if (redis_hash_get_int(&i, &call, "tos"))
c->tos = 184; c->tos = 184;
else else
c->tos = i; c->tos = i;
redis_hash_get_time_t(&c->deleted, &call, "deleted"); redis_hash_get_time_t(&c->deleted_us, &call, "deleted");
redis_hash_get_time_t(&c->ml_deleted, &call, "ml_deleted"); redis_hash_get_time_t(&c->ml_deleted_us, &call, "ml_deleted");
if (!redis_hash_get_str(&id, &call, "created_from")) if (!redis_hash_get_str(&id, &call, "created_from"))
c->created_from = call_strdup_str(&id); c->created_from = call_strdup_str(&id);
if (!redis_hash_get_str(&id, &call, "created_from_addr")) { if (!redis_hash_get_str(&id, &call, "created_from_addr")) {
@ -2454,15 +2462,15 @@ static str redis_encode_json(ng_parser_ctx_t *ctx, call_t *c, void **to_free) {
{ {
JSON_SET_SIMPLE("created","%" PRId64, c->created); JSON_SET_SIMPLE("created","%" PRId64, c->created);
JSON_SET_SIMPLE("destroyed","%" PRId64, c->destroyed); JSON_SET_SIMPLE("destroyed","%" PRId64, c->destroyed);
JSON_SET_SIMPLE("last_signal","%ld", (long int) c->last_signal); JSON_SET_SIMPLE("last_signal","%" PRId64, c->last_signal_us);
JSON_SET_SIMPLE("tos","%u", (int) c->tos); JSON_SET_SIMPLE("tos","%u", (int) c->tos);
JSON_SET_SIMPLE("deleted","%ld", (long int) c->deleted); JSON_SET_SIMPLE("deleted","%" PRId64, c->deleted_us);
JSON_SET_SIMPLE("num_sfds","%u", t_queue_get_length(&c->stream_fds)); JSON_SET_SIMPLE("num_sfds","%u", t_queue_get_length(&c->stream_fds));
JSON_SET_SIMPLE("num_streams","%u", t_queue_get_length(&c->streams)); JSON_SET_SIMPLE("num_streams","%u", t_queue_get_length(&c->streams));
JSON_SET_SIMPLE("num_medias","%u", t_queue_get_length(&c->medias)); JSON_SET_SIMPLE("num_medias","%u", t_queue_get_length(&c->medias));
JSON_SET_SIMPLE("num_tags","%u", t_queue_get_length(&c->monologues)); JSON_SET_SIMPLE("num_tags","%u", t_queue_get_length(&c->monologues));
JSON_SET_SIMPLE("num_maps","%u", t_queue_get_length(&c->endpoint_maps)); JSON_SET_SIMPLE("num_maps","%u", t_queue_get_length(&c->endpoint_maps));
JSON_SET_SIMPLE("ml_deleted","%ld", (long int) c->ml_deleted); JSON_SET_SIMPLE("ml_deleted","%" PRId64, c->ml_deleted_us);
JSON_SET_SIMPLE_CSTR("created_from", c->created_from); JSON_SET_SIMPLE_CSTR("created_from", c->created_from);
JSON_SET_SIMPLE_CSTR("created_from_addr", sockaddr_print_buf(&c->created_from_addr)); JSON_SET_SIMPLE_CSTR("created_from_addr", sockaddr_print_buf(&c->created_from_addr));
JSON_SET_SIMPLE("redis_hosted_db","%u", c->redis_hosted_db); JSON_SET_SIMPLE("redis_hosted_db","%u", c->redis_hosted_db);
@ -2557,8 +2565,8 @@ static str redis_encode_json(ng_parser_ctx_t *ctx, call_t *c, void **to_free) {
{ {
JSON_SET_SIMPLE("created", "%llu", (long long unsigned) ml->created); JSON_SET_SIMPLE("created", "%" PRId64, ml->created_us);
JSON_SET_SIMPLE("deleted", "%llu", (long long unsigned) ml->deleted); JSON_SET_SIMPLE("deleted", "%" PRId64, ml->deleted_us);
JSON_SET_SIMPLE("block_dtmf", "%i", ml->block_dtmf); JSON_SET_SIMPLE("block_dtmf", "%i", ml->block_dtmf);
JSON_SET_SIMPLE("ml_flags", "%" PRIu64, atomic64_get_na(&ml->ml_flags)); JSON_SET_SIMPLE("ml_flags", "%" PRIu64, atomic64_get_na(&ml->ml_flags));
JSON_SET_SIMPLE_CSTR("desired_family", ml->desired_family ? ml->desired_family->rfc_name : ""); JSON_SET_SIMPLE_CSTR("desired_family", ml->desired_family ? ml->desired_family->rfc_name : "");

@ -445,7 +445,7 @@ struct packet_stream {
ssrc_out_idx; /* LOCK: out_lock */ ssrc_out_idx; /* LOCK: out_lock */
struct send_timer *send_timer; /* RO */ struct send_timer *send_timer; /* RO */
struct jitter_buffer *jb; /* RO */ struct jitter_buffer *jb; /* RO */
time_t kernel_time; int64_t kernel_time_us;
struct stream_stats *stats_in; struct stream_stats *stats_in;
struct stream_stats *stats_out; struct stream_stats *stats_out;
@ -588,8 +588,8 @@ struct call_monologue {
str_q tag_aliases; str_q tag_aliases;
enum tag_type tagtype; enum tag_type tagtype;
str label; str label;
time_t created; /* RO */ int64_t created_us; /* RO */
time_t deleted; int64_t deleted_us;
int64_t started; /* for CDR */ int64_t started; /* for CDR */
int64_t terminated; /* for CDR */ int64_t terminated; /* for CDR */
enum termination_reason term_reason; enum termination_reason term_reason;
@ -770,9 +770,9 @@ struct call {
str_q callid_aliases; str_q callid_aliases;
int64_t created; int64_t created;
int64_t destroyed; int64_t destroyed;
time_t last_signal; int64_t last_signal_us;
time_t deleted; int64_t deleted_us;
time_t ml_deleted; int64_t ml_deleted_us;
unsigned char tos; unsigned char tos;
char *created_from; char *created_from;
sockaddr_t created_from_addr; sockaddr_t created_from_addr;

Loading…
Cancel
Save