summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2021-01-03 09:43:22 +0100
committerAndreas Eversberg <jolly@eversberg.eu>2021-01-03 09:43:22 +0100
commit9569b2591e8b92db1b45c13afda26b4068e05c88 (patch)
tree6972c81ec06c2f17aa99fbfb9f8665f70babeab3
parentab8fef45d6bc4ca53b71fa82c52c8df73fea0a7f (diff)
Bug: Fixed shutdown of Sofia stack
-rw-r--r--src/sip/sip.c17
-rw-r--r--src/sip/sip.h1
2 files changed, 17 insertions, 1 deletions
diff --git a/src/sip/sip.c b/src/sip/sip.c
index c9d4d46..59cf21f 100644
--- a/src/sip/sip.c
+++ b/src/sip/sip.c
@@ -1428,6 +1428,15 @@ static void sip_message(nua_event_t event, int status, char const *phrase, nua_t
call_t *call;
PDEBUG(DSIP, DEBUG_DEBUG, "Event %d from SIP stack received (handle=%p)\n", event, nh);
+
+ switch (event) {
+ case nua_r_shutdown:
+ sip_ep->shutdown_complete = 1;
+ break;
+ default:
+ ;
+ }
+
if (!nh)
return;
@@ -1760,8 +1769,14 @@ void sip_endpoint_destroy(sip_endpoint_t *sip_ep)
stun_handle_destroy(sip_ep->stun_handle);
if (sip_ep->register_handle)
nua_handle_destroy(sip_ep->register_handle);
- if (sip_ep->su_root)
+ if (sip_ep->su_root) {
+ nua_shutdown(sip_ep->nua);
+ while (!sip_ep->shutdown_complete) {
+ su_root_step(sip_ep->su_root, 0);
+ usleep(1000);
+ }
su_root_destroy(sip_ep->su_root);
+ }
if (sip_ep->nua)
nua_destroy(sip_ep->nua);
free(sip_ep);
diff --git a/src/sip/sip.h b/src/sip/sip.h
index 37b8b8f..a1ca7bb 100644
--- a/src/sip/sip.h
+++ b/src/sip/sip.h
@@ -75,6 +75,7 @@ typedef struct sip_endpoint {
su_root_t *su_root;
nua_t *nua;
nua_handle_t *register_handle;
+ int shutdown_complete;
/* register process */
char remote_contact[256];