FreeCalypso > hg > themwi-system-sw
comparison sip-out/call_clear.c @ 154:e54b0a9e322f
beginning of themwi-sip-out
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 11 Oct 2022 23:04:01 -0800 |
parents | sip-in/call_clear.c@3a1f0e13a3ac |
children |
comparison
equal
deleted
inserted
replaced
153:99fd4ae573ae | 154:e54b0a9e322f |
---|---|
1 /* | |
2 * In this module we implement final clearing of calls, i.e., freeing | |
3 * of struct call, and all preliminary steps that need to happen | |
4 * toward this ultimate end state. | |
5 */ | |
6 | |
7 #include <sys/types.h> | |
8 #include <sys/socket.h> | |
9 #include <sys/time.h> | |
10 #include <netinet/in.h> | |
11 #include <stdio.h> | |
12 #include <stdint.h> | |
13 #include <stdlib.h> | |
14 #include <string.h> | |
15 #include <strings.h> | |
16 #include <syslog.h> | |
17 #include "../include/out_routes.h" | |
18 #include "call.h" | |
19 | |
20 extern struct call *call_list; | |
21 extern struct timeval cur_event_time; | |
22 | |
23 void | |
24 sip_mark_end_time(call, linger) | |
25 struct call *call; | |
26 unsigned linger; | |
27 { | |
28 call->sip_clear_time = cur_event_time.tv_sec + linger; | |
29 } | |
30 | |
31 void | |
32 check_dead_call(call) | |
33 struct call *call; | |
34 { | |
35 if (call->overall_state != OVERALL_STATE_TEARDOWN) | |
36 return; | |
37 if (call->mncc) | |
38 return; | |
39 if (call->mgw_state != MGW_STATE_NO_EXIST) | |
40 return; | |
41 if (call->mgw_xact) | |
42 return; | |
43 if (call->sip_call_exists) | |
44 call->overall_state = OVERALL_STATE_SIP_FINISH; | |
45 else | |
46 call->overall_state = OVERALL_STATE_GC; | |
47 } | |
48 | |
49 void | |
50 clear_dead_calls() | |
51 { | |
52 struct call *call, **pp; | |
53 | |
54 for (pp = &call_list; *pp; ) { | |
55 call = *pp; | |
56 if (call->overall_state == OVERALL_STATE_GC || | |
57 call->overall_state == OVERALL_STATE_SIP_FINISH && | |
58 call->sip_state >= SIP_STATE_ACCEPT_100 && | |
59 cur_event_time.tv_sec >= call->sip_clear_time) { | |
60 *pp = call->next; | |
61 free(call); | |
62 continue; | |
63 } | |
64 pp = &call->next; | |
65 } | |
66 } |