Browse Source

move 'poller' member of callmaster into global scope

Change-Id: Ide88caff59529278e45ceef4f9664bfc07f67b3d
pull/432/merge
Richard Fuchs 8 years ago
parent
commit
cf3a8f9e16
5 changed files with 28 additions and 22 deletions
  1. +4
    -6
      daemon/call.c
  2. +1
    -3
      daemon/call.h
  3. +14
    -11
      daemon/main.c
  4. +7
    -0
      daemon/main.h
  5. +2
    -2
      daemon/media_socket.c

+ 4
- 6
daemon/call.c View File

@ -41,6 +41,7 @@
#include "cdr.h"
#include "statistics.h"
#include "ssrc.h"
#include "main.h"
/* also serves as array index for callstream->peers[] */
@ -608,7 +609,7 @@ next:
#undef DS
struct callmaster *callmaster_new(struct poller *p) {
struct callmaster *callmaster_new() {
struct callmaster *c;
c = obj_alloc0("callmaster", sizeof(*c), NULL);
@ -616,10 +617,9 @@ struct callmaster *callmaster_new(struct poller *p) {
rtpe_callhash = g_hash_table_new(str_hash, str_equal);
if (!rtpe_callhash)
goto fail;
c->poller = p;
rwlock_init(&rtpe_callhash_lock);
poller_add_timer(p, callmaster_timer, &c->obj);
poller_add_timer(rtpe_poller, callmaster_timer, &c->obj);
mutex_init(&c->totalstats.total_average_lock);
mutex_init(&c->totalstats_interval.total_average_lock);
@ -1769,7 +1769,6 @@ void call_destroy(struct call *c) {
struct callmaster *m;
struct packet_stream *ps=0;
struct stream_fd *sfd;
struct poller *p;
GList *l;
int ret;
struct call_monologue *ml;
@ -1782,7 +1781,6 @@ void call_destroy(struct call *c) {
}
m = c->callmaster;
p = m->poller;
rwlock_lock_w(&rtpe_callhash_lock);
ret = (g_hash_table_lookup(rtpe_callhash, &c->callid) == c);
@ -1914,7 +1912,7 @@ no_stats_output:
while (c->stream_fds.head) {
sfd = g_queue_pop_head(&c->stream_fds);
poller_del_item(p, sfd->socket.fd);
poller_del_item(rtpe_poller, sfd->socket.fd);
obj_put(sfd);
}


+ 1
- 3
daemon/call.h View File

@ -424,8 +424,6 @@ struct callmaster {
mutex_t totalstats_lastinterval_lock;
struct totalstats totalstats_lastinterval;
struct poller *poller;
struct callmaster_config conf;
struct timeval latest_graphite_interval_start;
};
@ -435,7 +433,7 @@ extern rwlock_t rtpe_callhash_lock;
extern GHashTable *rtpe_callhash;
struct callmaster *callmaster_new(struct poller *);
struct callmaster *callmaster_new(void);
void callmaster_get_all_calls(struct callmaster *m, GQueue *q);
//void calls_dump_redis(struct callmaster *);


+ 14
- 11
daemon/main.c View File

@ -1,3 +1,5 @@
#include "main.h"
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
@ -38,11 +40,12 @@
struct main_context {
struct poller *p;
struct callmaster *m;
};
struct poller *rtpe_poller;
static GQueue interfaces = G_QUEUE_INIT;
@ -519,15 +522,15 @@ static void create_everything(struct main_context *ctx) {
}
no_kernel:
ctx->p = poller_new();
if (!ctx->p)
rtpe_poller = poller_new();
if (!rtpe_poller)
die("poller creation failed");
ctx->m = callmaster_new(ctx->p);
ctx->m = callmaster_new();
if (!ctx->m)
die("callmaster creation failed");
dtls_timer(ctx->p);
dtls_timer(rtpe_poller);
ZERO(mc);
rwlock_init(&mc.config_lock);
@ -559,7 +562,7 @@ no_kernel:
ct = NULL;
if (tcp_listen_ep.port) {
ct = control_tcp_new(ctx->p, &tcp_listen_ep, ctx->m);
ct = control_tcp_new(rtpe_poller, &tcp_listen_ep, ctx->m);
if (!ct)
die("Failed to open TCP control connection port");
}
@ -567,7 +570,7 @@ no_kernel:
cu = NULL;
if (udp_listen_ep.port) {
interfaces_exclude_port(udp_listen_ep.port);
cu = control_udp_new(ctx->p, &udp_listen_ep, ctx->m);
cu = control_udp_new(rtpe_poller, &udp_listen_ep, ctx->m);
if (!cu)
die("Failed to open UDP control connection port");
}
@ -575,7 +578,7 @@ no_kernel:
cn = NULL;
if (ng_listen_ep.port) {
interfaces_exclude_port(ng_listen_ep.port);
cn = control_ng_new(ctx->p, &ng_listen_ep, ctx->m, control_tos);
cn = control_ng_new(rtpe_poller, &ng_listen_ep, ctx->m, control_tos);
if (!cn)
die("Failed to open UDP control connection port");
}
@ -583,7 +586,7 @@ no_kernel:
cl = NULL;
if (cli_listen_ep.port) {
interfaces_exclude_port(cli_listen_ep.port);
cl = cli_new(ctx->p, &cli_listen_ep, ctx->m);
cl = cli_new(rtpe_poller, &cli_listen_ep, ctx->m);
if (!cl)
die("Failed to open UDP CLI connection port");
}
@ -652,7 +655,7 @@ int main(int argc, char **argv) {
ilog(LOG_INFO, "Startup complete, version %s", RTPENGINE_VERSION);
thread_create_detach(sighandler, NULL);
thread_create_detach(poller_timer_loop, ctx.p);
thread_create_detach(poller_timer_loop, rtpe_poller);
if (!is_addr_unspecified(&redis_ep.address))
thread_create_detach(redis_notify_loop, ctx.m);
@ -671,7 +674,7 @@ int main(int argc, char **argv) {
}
for (;idx<num_threads;++idx) {
thread_create_detach(poller_loop, ctx.p);
thread_create_detach(poller_loop, rtpe_poller);
}
while (!rtpe_shutdown) {


+ 7
- 0
daemon/main.h View File

@ -0,0 +1,7 @@
#ifndef _MAIN_H_
#define _MAIN_H_
struct poller;
extern struct poller *rtpe_poller; // main global poller instance XXX convert to struct instead of pointer?
#endif

+ 2
- 2
daemon/media_socket.c View File

@ -23,6 +23,7 @@
#include "rtcplib.h"
#include "ssrc.h"
#include "iptables.h"
#include "main.h"
#ifndef PORT_RANDOM_MIN
@ -1619,7 +1620,6 @@ static void stream_fd_free(void *p) {
struct stream_fd *stream_fd_new(socket_t *fd, struct call *call, const struct local_intf *lif) {
struct stream_fd *sfd;
struct poller_item pi;
struct poller *po = call->callmaster->poller;
sfd = obj_alloc0("stream_fd", sizeof(*sfd), stream_fd_free);
sfd->unique_id = g_queue_get_length(&call->stream_fds);
@ -1637,7 +1637,7 @@ struct stream_fd *stream_fd_new(socket_t *fd, struct call *call, const struct lo
pi.readable = stream_fd_readable;
pi.closed = stream_fd_closed;
if (poller_add_item(po, &pi))
if (poller_add_item(rtpe_poller, &pi))
ilog(LOG_ERR, "Failed to add stream_fd to poller");
return sfd;


Loading…
Cancel
Save