summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main/devicestate.c16
-rw-r--r--main/manager.c2
-rw-r--r--pbx/pbx_dundi.c21
-rw-r--r--res/res_calendar.c2
-rw-r--r--res/res_crypto.c8
-rw-r--r--res/res_rtp_asterisk.c53
6 files changed, 44 insertions, 58 deletions
diff --git a/main/devicestate.c b/main/devicestate.c
index 2983ee992..faba144aa 100644
--- a/main/devicestate.c
+++ b/main/devicestate.c
@@ -214,6 +214,7 @@ static pthread_t change_thread = AST_PTHREADT_NULL;
/*! \brief Flag for the queue */
static ast_cond_t change_pending;
+static volatile int shuttingdown;
struct stasis_subscription *devstate_message_sub;
@@ -548,7 +549,7 @@ static void *do_devstate_changes(void *data)
{
struct state_change *next, *current;
- for (;;) {
+ while (!shuttingdown) {
/* This basically pops off any state change entries, resets the list back to NULL, unlocks, and processes each state change */
AST_LIST_LOCK(&state_changes);
if (AST_LIST_EMPTY(&state_changes))
@@ -626,6 +627,18 @@ static void devstate_change_cb(void *data, struct stasis_subscription *sub, stru
device_state->cachable, NULL);
}
+static void device_state_engine_cleanup(void)
+{
+ shuttingdown = 1;
+ AST_LIST_LOCK(&state_changes);
+ ast_cond_signal(&change_pending);
+ AST_LIST_UNLOCK(&state_changes);
+
+ if (change_thread != AST_PTHREADT_NULL) {
+ pthread_join(change_thread, NULL);
+ }
+}
+
/*! \brief Initialize the device state engine in separate thread */
int ast_device_state_engine_init(void)
{
@@ -634,6 +647,7 @@ int ast_device_state_engine_init(void)
ast_log(LOG_ERROR, "Unable to start device state change thread.\n");
return -1;
}
+ ast_register_cleanup(device_state_engine_cleanup);
return 0;
}
diff --git a/main/manager.c b/main/manager.c
index 455a49c4e..8478730c8 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -8512,6 +8512,8 @@ static void manager_shutdown(void)
manager_free_user(user);
}
acl_change_stasis_unsubscribe();
+
+ ast_free(manager_channelvars);
}
diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c
index 04da24788..51801f45f 100644
--- a/pbx/pbx_dundi.c
+++ b/pbx/pbx_dundi.c
@@ -5014,30 +5014,31 @@ static int load_module(void)
io = io_context_create();
sched = ast_sched_context_create();
- if (!io || !sched)
- return AST_MODULE_LOAD_DECLINE;
+ if (!io || !sched) {
+ goto declined;
+ }
- if (set_config("dundi.conf", &sin, 0))
- return AST_MODULE_LOAD_DECLINE;
+ if (set_config("dundi.conf", &sin, 0)) {
+ goto declined;
+ }
netsocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
if (netsocket < 0) {
ast_log(LOG_ERROR, "Unable to create network socket: %s\n", strerror(errno));
- return AST_MODULE_LOAD_DECLINE;
+ goto declined;
}
if (bind(netsocket, (struct sockaddr *) &sin, sizeof(sin))) {
ast_log(LOG_ERROR, "Unable to bind to %s port %d: %s\n",
ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), strerror(errno));
- return AST_MODULE_LOAD_DECLINE;
+ goto declined;
}
ast_set_qos(netsocket, tos, 0, "DUNDi");
if (start_network_thread()) {
ast_log(LOG_ERROR, "Unable to start network thread\n");
- close(netsocket);
- return AST_MODULE_LOAD_DECLINE;
+ goto declined;
}
ast_cli_register_multiple(cli_dundi, ARRAY_LEN(cli_dundi));
@@ -5050,6 +5051,10 @@ static int load_module(void)
ast_verb(2, "DUNDi Ready and Listening on %s port %d\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
return AST_MODULE_LOAD_SUCCESS;
+
+declined:
+ unload_module();
+ return AST_MODULE_LOAD_DECLINE;
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Distributed Universal Number Discovery (DUNDi)",
diff --git a/res/res_calendar.c b/res/res_calendar.c
index 5b911ca5b..264165470 100644
--- a/res/res_calendar.c
+++ b/res/res_calendar.c
@@ -1853,6 +1853,8 @@ static int unload_module(void)
ast_mutex_unlock(&refreshlock);
pthread_join(refresh_thread, NULL);
+ ast_sched_context_destroy(sched);
+
AST_LIST_LOCK(&techs);
AST_LIST_TRAVERSE_SAFE_BEGIN(&techs, tech, list) {
ast_unload_resource(tech->module, 0);
diff --git a/res/res_crypto.c b/res/res_crypto.c
index 78b8df209..168342791 100644
--- a/res/res_crypto.c
+++ b/res/res_crypto.c
@@ -652,13 +652,17 @@ static int load_module(void)
} else {
crypto_load(-1, -1);
}
+
+ /* This prevents dlclose from ever running, but allows CLI cleanup at shutdown. */
+ ast_module_shutdown_ref(ast_module_info->self);
return AST_MODULE_LOAD_SUCCESS;
}
static int unload_module(void)
{
- /* Can't unload this once we're loaded */
- return -1;
+ ast_cli_unregister_multiple(cli_crypto, ARRAY_LEN(cli_crypto));
+
+ return 0;
}
/* needs usecount semantics defined */
diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c
index 3c630fbe3..f6bf34211 100644
--- a/res/res_rtp_asterisk.c
+++ b/res/res_rtp_asterisk.c
@@ -444,7 +444,6 @@ static int ast_rtp_sendcng(struct ast_rtp_instance *instance, int level);
#ifdef HAVE_OPENSSL_SRTP
static int ast_rtp_activate(struct ast_rtp_instance *instance);
static void dtls_srtp_check_pending(struct ast_rtp_instance *instance, struct ast_rtp *rtp, int rtcp);
-static void dtls_srtp_flush_pending(struct ast_rtp_instance *instance, struct ast_rtp *rtp);
static void dtls_srtp_start_timeout_timer(struct ast_rtp_instance *instance, struct ast_rtp *rtp, int rtcp);
static void dtls_srtp_stop_timeout_timer(struct ast_rtp_instance *instance, struct ast_rtp *rtp, int rtcp);
#endif
@@ -1684,20 +1683,15 @@ static void ast_rtp_on_ice_complete(pj_ice_sess *ice, pj_status_t status)
if (rtp->rtcp) {
update_address_with_ice_candidate(rtp, AST_RTP_ICE_COMPONENT_RTCP, &rtp->rtcp->them);
}
+ }
#ifdef HAVE_OPENSSL_SRTP
- if (rtp->dtls.dtls_setup != AST_RTP_DTLS_SETUP_PASSIVE) {
- dtls_perform_handshake(instance, &rtp->dtls, 0);
- }
- else {
- dtls_srtp_flush_pending(instance, rtp); /* this flushes pending BIO for both rtp & rtcp as needed. */
- }
+ dtls_perform_handshake(instance, &rtp->dtls, 0);
- if (rtp->rtcp && rtp->rtcp->dtls.dtls_setup != AST_RTP_DTLS_SETUP_PASSIVE) {
- dtls_perform_handshake(instance, &rtp->rtcp->dtls, 1);
- }
-#endif
+ if (rtp->rtcp) {
+ dtls_perform_handshake(instance, &rtp->rtcp->dtls, 1);
}
+#endif
if (!strictrtp) {
return;
@@ -1892,23 +1886,6 @@ static void dtls_srtp_stop_timeout_timer(struct ast_rtp_instance *instance, stru
AST_SCHED_DEL_UNREF(rtp->sched, dtls->timeout_timer, ao2_ref(instance, -1));
}
-static void dtls_srtp_flush_pending(struct ast_rtp_instance *instance, struct ast_rtp *rtp)
-{
- struct dtls_details *dtls;
-
- dtls = &rtp->dtls;
- ast_mutex_lock(&dtls->lock);
- dtls_srtp_check_pending(instance, rtp, 0);
- ast_mutex_unlock(&dtls->lock);
-
- if (rtp->rtcp) {
- dtls = &rtp->rtcp->dtls;
- ast_mutex_lock(&dtls->lock);
- dtls_srtp_check_pending(instance, rtp, 1);
- ast_mutex_unlock(&dtls->lock);
- }
-}
-
static void dtls_srtp_check_pending(struct ast_rtp_instance *instance, struct ast_rtp *rtp, int rtcp)
{
struct dtls_details *dtls = !rtcp ? &rtp->dtls : &rtp->rtcp->dtls;
@@ -2141,8 +2118,6 @@ static int __rtp_recvfrom(struct ast_rtp_instance *instance, void *buf, size_t s
SSL_set_accept_state(dtls->ssl);
}
- ast_mutex_lock(&dtls->lock);
-
dtls_srtp_check_pending(instance, rtp, rtcp);
BIO_write(dtls->read_bio, buf, len);
@@ -2153,7 +2128,6 @@ static int __rtp_recvfrom(struct ast_rtp_instance *instance, void *buf, size_t s
unsigned long error = ERR_get_error();
ast_log(LOG_ERROR, "DTLS failure occurred on RTP instance '%p' due to reason '%s', terminating\n",
instance, ERR_reason_error_string(error));
- ast_mutex_unlock(&dtls->lock);
return -1;
}
@@ -2171,8 +2145,6 @@ static int __rtp_recvfrom(struct ast_rtp_instance *instance, void *buf, size_t s
dtls_srtp_start_timeout_timer(instance, rtp, rtcp);
}
- ast_mutex_unlock(&dtls->lock);
-
return res;
}
#endif
@@ -4862,20 +4834,7 @@ static void ast_rtp_remote_address_set(struct ast_rtp_instance *instance, struct
rtp_learning_seq_init(&rtp->rtp_source_learn, rtp->seqno);
}
-#ifdef HAVE_OPENSSL_SRTP
- /* Trigger pending outbound DTLS packets received before the address was set. Avoid unnecessary locking
- * by checking if we're passive. Without this, we only send the pending packets once a new SSL packet is
- * received in __rtp_recvfrom. If rtp->ice, this is instead done on_ice_complete
- */
-#ifdef HAVE_PJPROJECT
- if (rtp->ice) {
- return;
- }
-#endif
- if (rtp->dtls.dtls_setup == AST_RTP_DTLS_SETUP_PASSIVE) {
- dtls_srtp_flush_pending(instance, rtp);
- }
-#endif
+ return;
}
/*! \brief Write t140 redundacy frame