diff --git a/daemon/call.c b/daemon/call.c index 92401f2fb..30a10e93a 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -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); } diff --git a/daemon/call.h b/daemon/call.h index ed6e26031..ec12136cb 100644 --- a/daemon/call.h +++ b/daemon/call.h @@ -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 *); diff --git a/daemon/main.c b/daemon/main.c index 73e1729d9..b258d4d05 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -1,3 +1,5 @@ +#include "main.h" + #include #include #include @@ -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 (;idxcallmaster->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;