Browse Source

move matching regexps out of callmaster into global

Change-Id: I42779b3a1b9aef8b98ddecce6fa4093589ab6d62
pull/432/merge
Richard Fuchs 8 years ago
parent
commit
e87b2710c8
5 changed files with 27 additions and 18 deletions
  1. +0
    -12
      daemon/call.c
  2. +0
    -4
      daemon/call.h
  3. +23
    -2
      daemon/call_interfaces.c
  4. +2
    -0
      daemon/call_interfaces.h
  5. +2
    -0
      daemon/main.c

+ 0
- 12
daemon/call.c View File

@ -610,8 +610,6 @@ next:
struct callmaster *callmaster_new(struct poller *p) { struct callmaster *callmaster_new(struct poller *p) {
struct callmaster *c; struct callmaster *c;
const char *errptr;
int erroff;
c = obj_alloc0("callmaster", sizeof(*c), NULL); c = obj_alloc0("callmaster", sizeof(*c), NULL);
@ -621,16 +619,6 @@ struct callmaster *callmaster_new(struct poller *p) {
c->poller = p; c->poller = p;
rwlock_init(&rtpe_callhash_lock); rwlock_init(&rtpe_callhash_lock);
c->info_re = pcre_compile("^([^:,]+)(?::(.*?))?(?:$|,)", PCRE_DOLLAR_ENDONLY | PCRE_DOTALL, &errptr, &erroff, NULL);
if (!c->info_re)
goto fail;
c->info_ree = pcre_study(c->info_re, 0, &errptr);
c->streams_re = pcre_compile("^([\\d.]+):(\\d+)(?::(.*?))?(?:$|,)", PCRE_DOLLAR_ENDONLY | PCRE_DOTALL, &errptr, &erroff, NULL);
if (!c->streams_re)
goto fail;
c->streams_ree = pcre_study(c->streams_re, 0, &errptr);
poller_add_timer(p, callmaster_timer, &c->obj); poller_add_timer(p, callmaster_timer, &c->obj);
mutex_init(&c->totalstats.total_average_lock); mutex_init(&c->totalstats.total_average_lock);


+ 0
- 4
daemon/call.h View File

@ -425,10 +425,6 @@ struct callmaster {
struct totalstats totalstats_lastinterval; struct totalstats totalstats_lastinterval;
struct poller *poller; struct poller *poller;
pcre *info_re;
pcre_extra *info_ree;
pcre *streams_re;
pcre_extra *streams_ree;
struct callmaster_config conf; struct callmaster_config conf;
struct timeval latest_graphite_interval_start; struct timeval latest_graphite_interval_start;


+ 23
- 2
daemon/call_interfaces.c View File

@ -26,6 +26,10 @@
#include "streambuf.h" #include "streambuf.h"
static pcre *info_re;
static pcre_extra *info_ree;
static pcre *streams_re;
static pcre_extra *streams_ree;
int trust_address_def; int trust_address_def;
int dtls_passive_def; int dtls_passive_def;
@ -231,7 +235,7 @@ static int info_parse_func(char **a, void **ret, void *p) {
} }
static void info_parse(const char *s, GHashTable *ih, struct callmaster *m) { static void info_parse(const char *s, GHashTable *ih, struct callmaster *m) {
pcre_multi_match(m->info_re, m->info_ree, s, 2, info_parse_func, ih, NULL);
pcre_multi_match(info_re, info_ree, s, 2, info_parse_func, ih, NULL);
} }
@ -271,7 +275,7 @@ fail:
static void streams_parse(const char *s, struct callmaster *m, GQueue *q) { static void streams_parse(const char *s, struct callmaster *m, GQueue *q) {
int i; int i;
i = 0; i = 0;
pcre_multi_match(m->streams_re, m->streams_ree, s, 3, streams_parse_func, &i, q);
pcre_multi_match(streams_re, streams_ree, s, 3, streams_parse_func, &i, q);
} }
/* XXX move these somewhere else */ /* XXX move these somewhere else */
@ -1230,3 +1234,20 @@ const char *call_stop_recording_ng(bencode_item_t *input, struct callmaster *m,
return NULL; return NULL;
} }
int call_interfaces_init() {
const char *errptr;
int erroff;
info_re = pcre_compile("^([^:,]+)(?::(.*?))?(?:$|,)", PCRE_DOLLAR_ENDONLY | PCRE_DOTALL, &errptr, &erroff, NULL);
if (!info_re)
return -1;
info_ree = pcre_study(info_re, 0, &errptr);
streams_re = pcre_compile("^([\\d.]+):(\\d+)(?::(.*?))?(?:$|,)", PCRE_DOLLAR_ENDONLY | PCRE_DOTALL, &errptr, &erroff, NULL);
if (!streams_re)
return -1;
streams_ree = pcre_study(streams_re, 0, &errptr);
return 0;
}

+ 2
- 0
daemon/call_interfaces.h View File

@ -88,5 +88,7 @@ const char *call_stop_recording_ng(bencode_item_t *, struct callmaster *, bencod
void ng_call_stats(struct call *call, const str *fromtag, const str *totag, bencode_item_t *output, void ng_call_stats(struct call *call, const str *fromtag, const str *totag, bencode_item_t *output,
struct call_stats *totals); struct call_stats *totals);
int call_interfaces_init(void);
#endif #endif

+ 2
- 0
daemon/main.c View File

@ -493,6 +493,8 @@ static void init_everything() {
interfaces_init(&interfaces); interfaces_init(&interfaces);
iptables_init(); iptables_init();
control_ng_init(); control_ng_init();
if (call_interfaces_init())
abort();
} }


Loading…
Cancel
Save