changeset 111:7a4d4b8d5f04

sip-in call clearing: unlink and free implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 28 Sep 2022 18:45:16 -0800
parents c1c94b7fc2e2
children 6aa63cf4620a
files sip-in/call_clear.c sip-in/main.c
diffstat 2 files changed, 26 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/sip-in/call_clear.c	Wed Sep 28 18:37:19 2022 -0800
+++ b/sip-in/call_clear.c	Wed Sep 28 18:45:16 2022 -0800
@@ -44,3 +44,20 @@
 		return;
 	call->overall_state = OVERALL_STATE_DEAD_SIP;
 }
+
+void
+clear_dead_sip_calls()
+{
+	struct call *call, **pp;
+
+	for (pp = &call_list; *pp; ) {
+		call = *pp;
+		if (call->overall_state == OVERALL_STATE_DEAD_SIP &&
+		    call->sip_clear_time >= cur_event_time.tv_sec) {
+			*pp = call->next;
+			free(call);
+			continue;
+		}
+		pp = &call->next;
+	}
+}
--- a/sip-in/main.c	Wed Sep 28 18:37:19 2022 -0800
+++ b/sip-in/main.c	Wed Sep 28 18:45:16 2022 -0800
@@ -75,15 +75,15 @@
 			exit(1);
 		}
 		gettimeofday(&cur_event_time, 0);
-		if (rc == 0) {
+		if (rc) {
+			if (gsm_is_connected && FD_ISSET(gsm_socket, &fds))
+				gsm_socket_select();
+			if (mgw_is_connected && FD_ISSET(mgw_socket, &fds))
+				mgw_socket_select();
+			if (FD_ISSET(sip_socket, &fds))
+				sip_socket_select();
+		} else if (need_retrans)
 			run_periodic_retrans();
-			continue;
-		}
-		if (gsm_is_connected && FD_ISSET(gsm_socket, &fds))
-			gsm_socket_select();
-		if (mgw_is_connected && FD_ISSET(mgw_socket, &fds))
-			mgw_socket_select();
-		if (FD_ISSET(sip_socket, &fds))
-			sip_socket_select();
+		clear_dead_sip_calls();
 	}
 }