Browse Source

TT#89352 use bool type for foreign call functions

Change-Id: If8d5e28db534e6aeaaffb885e732e2bdd7338831
pull/1311/head
Richard Fuchs 4 years ago
parent
commit
765b1e3bca
8 changed files with 24 additions and 21 deletions
  1. +4
    -4
      daemon/call.c
  2. +2
    -2
      daemon/call_interfaces.c
  3. +4
    -3
      daemon/cli.c
  4. +4
    -3
      daemon/main.c
  5. +1
    -1
      daemon/media_socket.c
  6. +6
    -5
      daemon/redis.c
  7. +2
    -2
      include/call.h
  8. +1
    -1
      include/redis.h

+ 4
- 4
daemon/call.c View File

@ -123,7 +123,7 @@ out:
void call_make_own_foreign(struct call *c, int foreign) {
void call_make_own_foreign(struct call *c, bool foreign) {
statistics_update_foreignown_dec(c); statistics_update_foreignown_dec(c);
c->foreign_call = foreign ? 1 : 0; c->foreign_call = foreign ? 1 : 0;
statistics_update_foreignown_inc(c); statistics_update_foreignown_inc(c);
@ -3100,7 +3100,7 @@ static struct call *call_create(const str *callid) {
} }
/* returns call with master_lock held in W */ /* returns call with master_lock held in W */
struct call *call_get_or_create(const str *callid, int foreign) {
struct call *call_get_or_create(const str *callid, bool foreign) {
struct call *c; struct call *c;
restart: restart:
@ -3119,7 +3119,7 @@ restart:
} }
g_hash_table_insert(rtpe_callhash, &c->callid, obj_get(c)); g_hash_table_insert(rtpe_callhash, &c->callid, obj_get(c));
c->foreign_call = foreign;
c->foreign_call = foreign ? 1 : 0;
statistics_update_foreignown_inc(c); statistics_update_foreignown_inc(c);
@ -3188,7 +3188,7 @@ struct call *call_get(const str *callid) {
/* returns call with master_lock held in W, or possibly NULL iff opmode == OP_ANSWER */ /* returns call with master_lock held in W, or possibly NULL iff opmode == OP_ANSWER */
struct call *call_get_opmode(const str *callid, enum call_opmode opmode) { struct call *call_get_opmode(const str *callid, enum call_opmode opmode) {
if (opmode == OP_OFFER) if (opmode == OP_OFFER)
return call_get_or_create(callid, 0);
return call_get_or_create(callid, false);
return call_get(callid); return call_get(callid);
} }


+ 2
- 2
daemon/call_interfaces.c View File

@ -1401,7 +1401,7 @@ static const char *call_offer_answer_ng(struct ng_buffer *ngbuf, bencode_item_t
goto out; goto out;
} }
call = call_get_or_create(&flags.call_id, 0);
call = call_get_or_create(&flags.call_id, false);
} }
errstr = "Unknown call-id"; errstr = "Unknown call-id";
@ -1412,7 +1412,7 @@ static const char *call_offer_answer_ng(struct ng_buffer *ngbuf, bencode_item_t
call->debug = 1; call->debug = 1;
if (rtpe_config.active_switchover && IS_FOREIGN_CALL(call)) if (rtpe_config.active_switchover && IS_FOREIGN_CALL(call))
call_make_own_foreign(call, 0);
call_make_own_foreign(call, false);
if (!call->created_from && addr) { if (!call->created_from && addr) {
call->created_from = call_strdup(call, addr); call->created_from = call_strdup(call, addr);


+ 4
- 3
daemon/cli.c View File

@ -8,6 +8,7 @@
#include <errno.h> #include <errno.h>
#include <glib.h> #include <glib.h>
#include <inttypes.h> #include <inttypes.h>
#include <stdbool.h>
#include "poller.h" #include "poller.h"
#include "aux.h" #include "aux.h"
@ -1076,7 +1077,7 @@ static void cli_incoming_kslist(str *instr, struct cli_writer *cw) {
cw->cw_printf(cw, "\n"); cw->cw_printf(cw, "\n");
} }
static void cli_incoming_active_standby(struct cli_writer *cw, int foreign) {
static void cli_incoming_active_standby(struct cli_writer *cw, bool foreign) {
GHashTableIter iter; GHashTableIter iter;
gpointer key, value; gpointer key, value;
@ -1100,10 +1101,10 @@ static void cli_incoming_active_standby(struct cli_writer *cw, int foreign) {
cw->cw_printf(cw, "Ok, all calls set to '%s'\n", foreign ? "foreign (standby)" : "owned (active)"); cw->cw_printf(cw, "Ok, all calls set to '%s'\n", foreign ? "foreign (standby)" : "owned (active)");
} }
static void cli_incoming_active(str *instr, struct cli_writer *cw) { static void cli_incoming_active(str *instr, struct cli_writer *cw) {
cli_incoming_active_standby(cw, 0);
cli_incoming_active_standby(cw, false);
} }
static void cli_incoming_standby(str *instr, struct cli_writer *cw) { static void cli_incoming_standby(str *instr, struct cli_writer *cw) {
cli_incoming_active_standby(cw, 1);
cli_incoming_active_standby(cw, true);
} }
static void cli_incoming_debug(str *instr, struct cli_writer *cw) { static void cli_incoming_debug(str *instr, struct cli_writer *cw) {


+ 4
- 3
daemon/main.c View File

@ -16,6 +16,7 @@
#include <ifaddrs.h> #include <ifaddrs.h>
#include <net/if.h> #include <net/if.h>
#include <netdb.h> #include <netdb.h>
#include <stdbool.h>
#ifdef HAVE_MQTT #ifdef HAVE_MQTT
#include <mosquitto.h> #include <mosquitto.h>
#endif #endif
@ -1149,14 +1150,14 @@ no_kernel:
// first as the "owned" DB can do a stray update back to Redis // first as the "owned" DB can do a stray update back to Redis
for (GList *l = rtpe_config.redis_subscribed_keyspaces.head; l; l = l->next) { for (GList *l = rtpe_config.redis_subscribed_keyspaces.head; l; l = l->next) {
int db = GPOINTER_TO_INT(l->data); int db = GPOINTER_TO_INT(l->data);
if (redis_restore(rtpe_redis_notify, 1, db))
if (redis_restore(rtpe_redis_notify, true, db))
ilog(LOG_WARN, "Unable to restore calls from the active-active peer"); ilog(LOG_WARN, "Unable to restore calls from the active-active peer");
} }
if (redis_restore(rtpe_redis_write, 0, -1))
if (redis_restore(rtpe_redis_write, false, -1))
die("Refusing to continue without working Redis database"); die("Refusing to continue without working Redis database");
} }
else { else {
if (redis_restore(rtpe_redis, 0, -1))
if (redis_restore(rtpe_redis, false, -1))
die("Refusing to continue without working Redis database"); die("Refusing to continue without working Redis database");
} }


+ 1
- 1
daemon/media_socket.c View File

@ -2229,7 +2229,7 @@ static int stream_packet(struct packet_handler_ctx *phc) {
#endif #endif
if (rtpe_config.active_switchover && IS_FOREIGN_CALL(phc->mp.call)) if (rtpe_config.active_switchover && IS_FOREIGN_CALL(phc->mp.call))
call_make_own_foreign(phc->mp.call, 0);
call_make_own_foreign(phc->mp.call, false);
// this sets rtcp, in_srtp, and sinks // this sets rtcp, in_srtp, and sinks
media_packet_rtcp_demux(phc); media_packet_rtcp_demux(phc);


+ 6
- 5
daemon/redis.c View File

@ -17,6 +17,7 @@
#include <glib-object.h> #include <glib-object.h>
#include <json-glib/json-glib.h> #include <json-glib/json-glib.h>
#include <inttypes.h> #include <inttypes.h>
#include <stdbool.h>
#include "compat.h" #include "compat.h"
#include "aux.h" #include "aux.h"
@ -76,7 +77,7 @@ static int redisCommandNR(redisContext *r, const char *fmt, ...)
#define REDIS_FMT(x) (int) (x)->len, (x)->str #define REDIS_FMT(x) (int) (x)->len, (x)->str
static int redis_check_conn(struct redis *r); static int redis_check_conn(struct redis *r);
static void json_restore_call(struct redis *r, const str *id, int foreign);
static void json_restore_call(struct redis *r, const str *id, bool foreign);
static int redis_connect(struct redis *r, int wait); static int redis_connect(struct redis *r, int wait);
static int json_build_ssrc(struct call_monologue *ml, JsonReader *root_reader); static int json_build_ssrc(struct call_monologue *ml, JsonReader *root_reader);
@ -382,7 +383,7 @@ void on_redis_notification(redisAsyncContext *actx, void *reply, void *privdata)
mutex_unlock(&r->lock); mutex_unlock(&r->lock);
// unlock before restoring calls to avoid deadlock in case err happens // unlock before restoring calls to avoid deadlock in case err happens
json_restore_call(r, &callid, 1);
json_restore_call(r, &callid, true);
mutex_lock(&r->lock); mutex_lock(&r->lock);
} }
@ -1798,7 +1799,7 @@ next:
return 0; return 0;
} }
static void json_restore_call(struct redis *r, const str *callid, int foreign) {
static void json_restore_call(struct redis *r, const str *callid, bool foreign) {
redisReply* rr_jsonStr; redisReply* rr_jsonStr;
struct redis_hash call; struct redis_hash call;
struct redis_list tags, sfds, streams, medias, maps; struct redis_list tags, sfds, streams, medias, maps;
@ -1975,7 +1976,7 @@ err1:
struct thread_ctx { struct thread_ctx {
GQueue r_q; GQueue r_q;
mutex_t r_m; mutex_t r_m;
int foreign;
bool foreign;
}; };
static void restore_thread(void *call_p, void *ctx_p) { static void restore_thread(void *call_p, void *ctx_p) {
@ -1998,7 +1999,7 @@ static void restore_thread(void *call_p, void *ctx_p) {
mutex_unlock(&ctx->r_m); mutex_unlock(&ctx->r_m);
} }
int redis_restore(struct redis *r, int foreign, int db) {
int redis_restore(struct redis *r, bool foreign, int db) {
redisReply *calls = NULL, *call; redisReply *calls = NULL, *call;
int i, ret = -1; int i, ret = -1;
GThreadPool *gtp; GThreadPool *gtp;


+ 2
- 2
include/call.h View File

@ -536,9 +536,9 @@ void free_sink_handler(void *);
void __add_sink_handler(GQueue *, struct packet_stream *); void __add_sink_handler(GQueue *, struct packet_stream *);
struct call *call_get_or_create(const str *callid, int foreign);
struct call *call_get_or_create(const str *callid, bool foreign);
struct call *call_get_opmode(const str *callid, enum call_opmode opmode); struct call *call_get_opmode(const str *callid, enum call_opmode opmode);
void call_make_own_foreign(struct call *c, int foreign);
void call_make_own_foreign(struct call *c, bool foreign);
int call_get_mono_dialogue(struct call_monologue *dialogue[2], struct call *call, const str *fromtag, int call_get_mono_dialogue(struct call_monologue *dialogue[2], struct call *call, const str *fromtag,
const str *totag, const str *totag,
const str *viabranch); const str *viabranch);


+ 1
- 1
include/redis.h View File

@ -108,7 +108,7 @@ void redis_delete_async_loop(void *d);
struct redis *redis_new(const endpoint_t *, int, const char *, enum redis_role, int); struct redis *redis_new(const endpoint_t *, int, const char *, enum redis_role, int);
void redis_close(struct redis *r); void redis_close(struct redis *r);
int redis_restore(struct redis *, int foreign, int db);
int redis_restore(struct redis *, bool foreign, int db);
void redis_update(struct call *, struct redis *); void redis_update(struct call *, struct redis *);
void redis_update_onekey(struct call *c, struct redis *r); void redis_update_onekey(struct call *c, struct redis *r);
void redis_delete(struct call *, struct redis *); void redis_delete(struct call *, struct redis *);


Loading…
Cancel
Save