... | ... |
@@ -27,6 +27,7 @@ |
27 | 27 |
#ifdef SHM_MEM |
28 | 28 |
#include "shm_mem.h" |
29 | 29 |
#endif |
30 |
+#include "sr_module.h" |
|
30 | 31 |
|
31 | 32 |
|
32 | 33 |
#include <signal.h> |
... | ... |
@@ -296,19 +297,20 @@ static void sig_usr(int signo) |
296 | 297 |
else |
297 | 298 |
printf("statistics dump to %s failed\n", stat_file ); |
298 | 299 |
#endif |
300 |
+ DPrint("INT received, program terminates\n"); |
|
301 |
+ DPrint("Thank you for flying ser\n"); |
|
302 |
+ /* WARNING: very dangerous, might be unsafe*/ |
|
303 |
+ destroy_modules(); |
|
299 | 304 |
#ifdef PKG_MALLOC |
300 | 305 |
pkg_status(); |
301 | 306 |
#endif |
302 | 307 |
#ifdef SHM_MEM |
303 | 308 |
shm_status(); |
304 | 309 |
#endif |
305 |
- DPrint("INT received, program terminates\n"); |
|
306 |
- DPrint("Thank you for flying ser\n"); |
|
307 |
- /* WARNING: very dangerous, might be unsafe*/ |
|
308 | 310 |
#ifdef SHM_MEM |
309 | 311 |
shm_mem_destroy(); |
310 |
- exit(0); |
|
311 | 312 |
#endif |
313 |
+ exit(0); |
|
312 | 314 |
} else if (signo==SIGUSR1) { /* statistic */ |
313 | 315 |
#ifdef STATS |
314 | 316 |
dump_all_statistic(); |
... | ... |
@@ -480,7 +480,7 @@ int t_on_reply_received( struct sip_msg *p_msg ) |
480 | 480 |
|
481 | 481 |
/* returns 1 if everything was OK or -1 for error |
482 | 482 |
*/ |
483 |
-int t_put_on_wait( struct sip_msg *p_msg ) |
|
483 |
+int t_put_on_wait( struct sip_msg *p_msg) |
|
484 | 484 |
{ |
485 | 485 |
struct timer_link *tl; |
486 | 486 |
unsigned int i; |
... | ... |
@@ -1221,7 +1221,7 @@ int t_build_and_send_ACK( struct cell *Trans, unsigned int branch, struct sip_ms |
1221 | 1221 |
|
1222 | 1222 |
/* sends the ACK message to the same destination as the INVITE */ |
1223 | 1223 |
udp_send( ack_buf, p-ack_buf, (struct sockaddr*)&(T->outbound_request[branch]->to) , sizeof(struct sockaddr_in) ); |
1224 |
- DBG("DEBUG: t_build_and_send_ACK: ACK sent\n",); |
|
1224 |
+ DBG("DEBUG: t_build_and_send_ACK: ACK sent\n"); |
|
1225 | 1225 |
|
1226 | 1226 |
/* free mem*/ |
1227 | 1227 |
if (ack_buf) free( ack_buf ); |
... | ... |
@@ -28,6 +28,7 @@ static int w_t_put_on_wait(struct sip_msg* msg, char* str, char* str2); |
28 | 28 |
static int fixup_t_forward(void** param, int param_no); |
29 | 29 |
static int fixup_t_forward_def(void** param, int param_no); |
30 | 30 |
static int fixup_t_send_reply(void** param, int param_no); |
31 |
+static void tm_destroy_module(); |
|
31 | 32 |
|
32 | 33 |
static struct module_exports nm_exports= { |
33 | 34 |
"tm_module", |
... | ... |
@@ -71,7 +72,8 @@ static struct module_exports nm_exports= { |
71 | 72 |
0 |
72 | 73 |
}, |
73 | 74 |
8, |
74 |
- (response_function) t_on_reply_received |
|
75 |
+ (response_function) t_on_reply_received, |
|
76 |
+ (destroy_function) tm_destroy_module |
|
75 | 77 |
}; |
76 | 78 |
|
77 | 79 |
|
... | ... |
@@ -214,12 +216,15 @@ static int w_t_send_reply(struct sip_msg* msg, char* str, char* str2) |
214 | 216 |
return t_send_reply(msg, (unsigned int) str, str2); |
215 | 217 |
} |
216 | 218 |
|
219 |
+ |
|
217 | 220 |
static int w_t_put_on_wait(struct sip_msg* msg, char* str, char* str2) |
218 | 221 |
{ |
219 | 222 |
return t_put_on_wait(msg); |
220 | 223 |
} |
221 | 224 |
|
222 | 225 |
|
223 |
- |
|
224 |
- |
|
226 |
+static void tm_destroy_module() |
|
227 |
+{ |
|
228 |
+ LOG(L_CRIT, "BUG: tm_destroy_module not implemented yet -FIX FIX FIX\n"); |
|
229 |
+} |
|
225 | 230 |
|
... | ... |
@@ -108,3 +108,13 @@ struct sr_module* find_module(void* f, int *i) |
108 | 108 |
} |
109 | 109 |
return 0; |
110 | 110 |
} |
111 |
+ |
|
112 |
+ |
|
113 |
+ |
|
114 |
+void destroy_modules() |
|
115 |
+{ |
|
116 |
+ struct sr_module* t; |
|
117 |
+ |
|
118 |
+ for(t=modules;t;t=t->next) |
|
119 |
+ if ((t->exports)&&(t->exports->destroy_f)) t->exports->destroy_f(); |
|
120 |
+} |
... | ... |
@@ -11,6 +11,7 @@ |
11 | 11 |
typedef int (*cmd_function)(struct sip_msg*, char*, char*); |
12 | 12 |
typedef int (*fixup_function)(void** param, int param_no); |
13 | 13 |
typedef int (*response_function)(struct sip_msg*); |
14 |
+typedef void (*destroy_function)(); |
|
14 | 15 |
|
15 | 16 |
struct module_exports{ |
16 | 17 |
char* name; /* null terminated module name */ |
... | ... |
@@ -22,7 +23,11 @@ struct module_exports{ |
22 | 23 |
int cmd_no; /* number of registered commands |
23 | 24 |
(size of cmd_{names,pointers}*/ |
24 | 25 |
response_function response_f; /* function used for responses, |
25 |
- returns yes or no */ |
|
26 |
+ returns yes or no; |
|
27 |
+ can be null */ |
|
28 |
+ destroy_function destroy_f; /*function called when the module should |
|
29 |
+ be "destroyed", e.g: on ser exit; |
|
30 |
+ can be null */ |
|
26 | 31 |
}; |
27 | 32 |
|
28 | 33 |
struct sr_module{ |
... | ... |
@@ -37,6 +42,7 @@ struct sr_module* modules; /* global module list*/ |
37 | 42 |
int load_module(char* path); |
38 | 43 |
cmd_function find_export(char* name, int param_no); |
39 | 44 |
struct sr_module* find_module(void *f, int* r); |
45 |
+void destroy_modules(); |
|
40 | 46 |
|
41 | 47 |
|
42 | 48 |
/* modules function prototypes: |