Browse code

fifo, script callbacks and timer release pkg mem from cleanup; note that it affects only the main process

Jiri Kuthan authored on 29/03/2003 02:30:35
Showing 7 changed files
... ...
@@ -53,8 +53,9 @@
53 53
  *
54 54
  * History:
55 55
  * --------
56
- *  2003-01-29  new built-in fifo commands: arg and pwd (jiri)
56
+ *  2003-03-29  destroy pkg mem introduced (jiri)
57 57
  *  2003-03-19  replaced all mallocs/frees w/ pkg_malloc/pkg_free (andrei)
58
+ *  2003-01-29  new built-in fifo commands: arg and pwd (jiri)
58 59
  */
59 60
 
60 61
 
... ...
@@ -135,6 +136,19 @@ int register_fifo_cmd(fifo_cmd f, char *cmd_name, void *param)
135 136
 	return 1;
136 137
 }
137 138
 
139
+void destroy_fifo()
140
+{
141
+	struct fifo_command *c, *foo;
142
+
143
+	c=cmd_list;
144
+
145
+	while(c) {
146
+		foo=c->next;
147
+		pkg_free(c);
148
+		c=foo;
149
+	}
150
+}
151
+
138 152
 
139 153
 int read_line( char *b, int max, FILE *stream, int *read )
140 154
 {
... ...
@@ -84,5 +84,7 @@ FILE *open_reply_pipe( char *pipe_name );
84 84
 /* tell FIFO client an error occured via reply pipe */
85 85
 void fifo_reply( char *reply_fifo, char *reply_fmt, ... );
86 86
 
87
+/* memory deallocation */
88
+void destroy_fifo();
87 89
 
88 90
 #endif
... ...
@@ -29,6 +29,7 @@
29 29
  * 2002-01-29  argc/argv globalized via my_{argc|argv} (jiri)
30 30
  * 2003-01-23  mhomed added (jiri)
31 31
  * 2003-03-19  replaced all malloc/frees w/ pkg_malloc/pkg_free (andrei)
32
+ * 2003-03-29  pkg cleaners for fifo and script callbacks introduced (jiri)
32 33
  *
33 34
  */
34 35
 
... ...
@@ -80,6 +81,7 @@
80 81
 #include "name_alias.h"
81 82
 #include "hash_func.h"
82 83
 #include "pt.h"
84
+#include "script_cb.h"
83 85
 #ifdef USE_TCP
84 86
 #include "tcp_init.h"
85 87
 #endif
... ...
@@ -355,6 +357,8 @@ void cleanup(show_status)
355 357
 	destroy_tcp();
356 358
 #endif
357 359
 	destroy_timer();
360
+	destroy_fifo();
361
+	destroy_script_cb();
358 362
 #ifdef PKG_MALLOC
359 363
 	if (show_status){
360 364
 		LOG(memlog, "Memory status (pkg):\n");
... ...
@@ -31,6 +31,7 @@
31 31
  */
32 32
 /* History:
33 33
  * --------
34
+ *  2003-03-29  cleaning pkg allocation introduced (jiri)
34 35
  *  2003-03-19  replaced all mallocs/frees w/ pkg_malloc/pkg_free (andrei)
35 36
  */
36 37
 
... ...
@@ -72,6 +73,16 @@ int register_script_cb( cb_function f, callback_t t, void *param )
72 73
 	return 1;
73 74
 }
74 75
 
76
+void destroy_script_cb()
77
+{
78
+	struct script_cb *cb, *foo;
79
+
80
+	cb=pre_cb;
81
+	while(cb) { foo=cb->next;pkg_free(cb);cb=foo; }
82
+	cb=post_cb;
83
+	while(cb) { foo=cb->next;pkg_free(cb);cb=foo; }
84
+}
85
+
75 86
 int exec_pre_cb( struct sip_msg *msg)
76 87
 {
77 88
 	struct script_cb *i;
... ...
@@ -46,5 +46,6 @@ struct script_cb{
46 46
 int register_script_cb( cb_function f, callback_t t, void *param );
47 47
 int exec_pre_cb( struct sip_msg *msg);
48 48
 void exec_post_cb( struct sip_msg *msg);
49
+void destroy_script_cb();
49 50
 
50 51
 
... ...
@@ -30,6 +30,7 @@
30 30
  *               find_export_param, find_module (andrei)
31 31
  *  2003-03-19  replaced all mallocs/frees w/ pkg_malloc/pkg_free (andrei)
32 32
  *  2003-03-19  Support for flags in find_export (janakj)
33
+ *  2003-03-29  cleaning pkg_mallocs introduced (jiri)
33 34
  */
34 35
 
35 36
 
... ...
@@ -266,10 +267,15 @@ struct sr_module* find_module(void* f, cmd_export_t  **c)
266 267
 
267 268
 void destroy_modules()
268 269
 {
269
-	struct sr_module* t;
270
-
271
-	for(t=modules;t;t=t->next)
272
-		if  ((t->exports)&&(t->exports->destroy_f)) t->exports->destroy_f();
270
+	struct sr_module* t, *foo;
271
+
272
+	t=modules;
273
+	while(t) {
274
+		foo=t->next;
275
+		if ((t->exports)&&(t->exports->destroy_f)) t->exports->destroy_f();
276
+		pkg_free(t);
277
+		t=foo;
278
+	}
273 279
 	modules=0;
274 280
 }
275 281
 
... ...
@@ -27,6 +27,7 @@
27 27
 /* History:
28 28
  * --------
29 29
  *  2003-03-19  replaced all the mallocs/frees w/ pkg_malloc/pkg_free (andrei)
30
+ *  2003-03-29  cleaning pkg_mallocs introduced (jiri)
30 31
  */
31 32
 
32 33
 
... ...
@@ -72,6 +73,8 @@ int init_timer()
72 73
 
73 74
 void destroy_timer()
74 75
 {
76
+	struct sr_timer* t, *foo;
77
+
75 78
 	if (jiffies){
76 79
 #ifdef SHM_MEM
77 80
 		shm_free(jiffies); jiffies=0;
... ...
@@ -79,6 +82,13 @@ void destroy_timer()
79 82
 		pkg_free(jiffies); jiffies=0;
80 83
 #endif
81 84
 	}
85
+
86
+	t=timer_list;
87
+	while(t) {
88
+		foo=t->next;
89
+		pkg_free(t);
90
+		t=foo;
91
+	}
82 92
 }
83 93
 
84 94