Browse Source

Merge branch 'redis-onekey-concept-improvements' of https://github.com/1and1/rtpengine

pull/334/head
Richard Fuchs 9 years ago
parent
commit
0cd3b9f650
7 changed files with 68 additions and 980 deletions
  1. +0
    -4
      daemon/call.c
  2. +0
    -1
      daemon/call.h
  3. +2
    -14
      daemon/call_interfaces.c
  4. +0
    -3
      daemon/main.c
  5. +1
    -5
      daemon/media_socket.c
  6. +58
    -942
      daemon/redis.c
  7. +7
    -11
      daemon/redis.h

+ 0
- 4
daemon/call.c View File

@ -595,11 +595,7 @@ static void callmaster_timer(void *ptr) {
rwlock_unlock_r(&sfd->call->master_lock); rwlock_unlock_r(&sfd->call->master_lock);
if (update) { if (update) {
if (m->conf.redis_multikey) {
redis_update(ps->call, m->conf.redis_write);
} else {
redis_update_onekey(ps->call, m->conf.redis_write); redis_update_onekey(ps->call, m->conf.redis_write);
}
} }
next: next:


+ 0
- 1
daemon/call.h View File

@ -463,7 +463,6 @@ struct callmaster_config {
GQueue *redis_subscribed_keyspaces; GQueue *redis_subscribed_keyspaces;
struct redisAsyncContext *redis_notify_async_context; struct redisAsyncContext *redis_notify_async_context;
unsigned int redis_expires_secs; unsigned int redis_expires_secs;
unsigned int redis_multikey;
char *b2b_url; char *b2b_url;
unsigned char default_tos; unsigned char default_tos;
enum xmlrpc_format fmt; enum xmlrpc_format fmt;


+ 2
- 14
daemon/call_interfaces.c View File

@ -186,11 +186,7 @@ static str *call_update_lookup_udp(char **out, struct callmaster *m, enum call_o
sp.index, sp.index, out[RE_UDP_COOKIE], SAF_UDP); sp.index, sp.index, out[RE_UDP_COOKIE], SAF_UDP);
rwlock_unlock_w(&c->master_lock); rwlock_unlock_w(&c->master_lock);
if (m->conf.redis_multikey) {
redis_update(c, m->conf.redis_write);
} else {
redis_update_onekey(c, m->conf.redis_write);
}
redis_update_onekey(c, m->conf.redis_write);
gettimeofday(&(monologue->started), NULL); gettimeofday(&(monologue->started), NULL);
@ -338,11 +334,7 @@ out2:
rwlock_unlock_w(&c->master_lock); rwlock_unlock_w(&c->master_lock);
streams_free(&s); streams_free(&s);
if (m->conf.redis_multikey) {
redis_update(c, m->conf.redis_write);
} else {
redis_update_onekey(c, m->conf.redis_write);
}
redis_update_onekey(c, m->conf.redis_write);
ilog(LOG_INFO, "Returning to SIP proxy: "STR_FORMAT"", STR_FMT0(ret)); ilog(LOG_INFO, "Returning to SIP proxy: "STR_FORMAT"", STR_FMT0(ret));
obj_put(c); obj_put(c);
@ -774,11 +766,7 @@ static const char *call_offer_answer_ng(bencode_item_t *input, struct callmaster
rwlock_unlock_w(&call->master_lock); rwlock_unlock_w(&call->master_lock);
if (!flags.no_redis_update) { if (!flags.no_redis_update) {
if (m->conf.redis_multikey) {
redis_update(call, m->conf.redis_write);
} else {
redis_update_onekey(call,m->conf.redis_write); redis_update_onekey(call,m->conf.redis_write);
}
} else { } else {
ilog(LOG_DEBUG, "Not updating Redis due to present no-redis-update flag"); ilog(LOG_DEBUG, "Not updating Redis due to present no-redis-update flag");
} }


+ 0
- 3
daemon/main.c View File

@ -62,7 +62,6 @@ static unsigned int timeout;
static unsigned int silent_timeout; static unsigned int silent_timeout;
static unsigned int final_timeout; static unsigned int final_timeout;
static unsigned int redis_expires = 86400; static unsigned int redis_expires = 86400;
static unsigned int redis_multikey = 0;
static int port_min = 30000; static int port_min = 30000;
static int port_max = 40000; static int port_max = 40000;
static int max_sessions = -1; static int max_sessions = -1;
@ -299,7 +298,6 @@ static void options(int *argc, char ***argv) {
{ "redis-write",'w', 0, G_OPTION_ARG_STRING, &redisps_write, "Connect to Redis write database", "[PW@]IP:PORT/INT" }, { "redis-write",'w', 0, G_OPTION_ARG_STRING, &redisps_write, "Connect to Redis write database", "[PW@]IP:PORT/INT" },
{ "redis-num-threads", 0, 0, G_OPTION_ARG_INT, &redis_num_threads, "Number of Redis restore threads", "INT" }, { "redis-num-threads", 0, 0, G_OPTION_ARG_INT, &redis_num_threads, "Number of Redis restore threads", "INT" },
{ "redis-expires", 0, 0, G_OPTION_ARG_INT, &redis_expires, "Expire time in seconds for redis keys", "INT" }, { "redis-expires", 0, 0, G_OPTION_ARG_INT, &redis_expires, "Expire time in seconds for redis keys", "INT" },
{ "redis-multikey", 0, 0, G_OPTION_ARG_NONE, &redis_multikey, "Use multiple redis keys for storing the call (old behaviour) DEPRECATED", NULL },
{ "no-redis-required", 'q', 0, G_OPTION_ARG_NONE, &no_redis_required, "Start no matter of redis connection state", NULL }, { "no-redis-required", 'q', 0, G_OPTION_ARG_NONE, &no_redis_required, "Start no matter of redis connection state", NULL },
{ "b2b-url", 'b', 0, G_OPTION_ARG_STRING, &b2b_url, "XMLRPC URL of B2B UA" , "STRING" }, { "b2b-url", 'b', 0, G_OPTION_ARG_STRING, &b2b_url, "XMLRPC URL of B2B UA" , "STRING" },
{ "log-facility",0, 0, G_OPTION_ARG_STRING, &log_facility_s, "Syslog facility to use for logging", "daemon|local0|...|local7"}, { "log-facility",0, 0, G_OPTION_ARG_STRING, &log_facility_s, "Syslog facility to use for logging", "daemon|local0|...|local7"},
@ -628,7 +626,6 @@ no_kernel:
} }
mc.redis_expires_secs = redis_expires; mc.redis_expires_secs = redis_expires;
mc.redis_multikey = redis_multikey;
ctx->m->conf = mc; ctx->m->conf = mc;


+ 1
- 5
daemon/media_socket.c View File

@ -1472,11 +1472,7 @@ out:
ca = sfd->call ? : NULL; ca = sfd->call ? : NULL;
if (ca && update) { if (ca && update) {
if (ca->callmaster->conf.redis_multikey) {
redis_update(ca, ca->callmaster->conf.redis_write);
} else {
redis_update_onekey(ca, ca->callmaster->conf.redis_write);
}
redis_update_onekey(ca, ca->callmaster->conf.redis_write);
} }
done: done:
log_info_clear(); log_info_clear();


+ 58
- 942
daemon/redis.c
File diff suppressed because it is too large
View File


+ 7
- 11
daemon/redis.h View File

@ -13,6 +13,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <hiredis/hiredis.h> #include <hiredis/hiredis.h>
#include "call.h" #include "call.h"
#include "str.h"
#define REDIS_RESTORE_NUM_THREADS 4 #define REDIS_RESTORE_NUM_THREADS 4
@ -61,10 +62,11 @@ struct redis {
int state; int state;
int no_redis_required; int no_redis_required;
}; };
struct redis_hash { struct redis_hash {
redisReply *rr;
GHashTable *ht; GHashTable *ht;
}; };
struct redis_list { struct redis_list {
unsigned int len; unsigned int len;
struct redis_hash *rh; struct redis_hash *rh;
@ -72,12 +74,6 @@ struct redis_list {
}; };
#if !GLIB_CHECK_VERSION(2,40,0) #if !GLIB_CHECK_VERSION(2,40,0)
INLINE gboolean g_hash_table_insert_check(GHashTable *h, gpointer k, gpointer v) { INLINE gboolean g_hash_table_insert_check(GHashTable *h, gpointer k, gpointer v) {
gboolean ret = TRUE; gboolean ret = TRUE;
@ -129,12 +125,12 @@ int redis_notify_subscribe_action(struct callmaster *cm, enum subscribe_action a
#define define_get_int_type(name, type, func) \ #define define_get_int_type(name, type, func) \
static int redis_hash_get_ ## name(type *out, const struct redis_hash *h, const char *k) { \ static int redis_hash_get_ ## name(type *out, const struct redis_hash *h, const char *k) { \
redisReply *r; \
str* s; \
\ \
r = g_hash_table_lookup(h->ht, k); \
if (!r) \
s = g_hash_table_lookup(h->ht, k); \
if (!s) \
return -1; \ return -1; \
*out = func(r->str, NULL, 10); \
*out = func(s->s, NULL, 10); \
return 0; \ return 0; \
} }


Loading…
Cancel
Save