Browse code

- fixed some tm destroy segfaults (when init_modules is not called but destroy_modules is -- e.g. config error)

Andrei Pelinescu-Onciul authored on 27/06/2003 18:35:55
Showing 2 changed files
... ...
@@ -26,6 +26,11 @@
26 26
  * along with this program; if not, write to the Free Software 
27 27
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28 28
  */
29
+/*
30
+ * History:
31
+ * --------
32
+ *  2003-06-27  tm_stats & friends freed on exit only if non-null (andrei)
33
+ */
29 34
 
30 35
 
31 36
 #include "defs.h"
... ...
@@ -39,7 +44,7 @@
39 44
 #include "../../fifo_server.h"
40 45
 #include "../../pt.h"
41 46
 
42
-struct t_stats *tm_stats;
47
+struct t_stats *tm_stats=0;
43 48
 
44 49
 
45 50
 /* we don't worry about locking data during reads (unlike
... ...
@@ -147,10 +152,13 @@ int init_tm_stats(void)
147 152
 
148 153
 error4:
149 154
 	shm_free(tm_stats->s_client_transactions);
155
+	tm_stats->s_client_transactions=0;
150 156
 error3:
151 157
 	shm_free(tm_stats->s_transactions);
158
+	tm_stats->s_transactions=0;
152 159
 error2:
153 160
 	shm_free(tm_stats->s_waiting);
161
+	tm_stats->s_waiting=0;
154 162
 error1:
155 163
 	shm_free(tm_stats);
156 164
 error0:
... ...
@@ -159,8 +167,13 @@ error0:
159 167
 
160 168
 void free_tm_stats()
161 169
 {
162
-	shm_free(tm_stats->s_client_transactions);
163
-	shm_free(tm_stats->s_transactions);
164
-	shm_free(tm_stats->s_waiting);
165
-	shm_free(tm_stats);
170
+	if (tm_stats!=0){
171
+		if (tm_stats->s_client_transactions) 
172
+			shm_free(tm_stats->s_client_transactions);
173
+		if (tm_stats->s_transactions)
174
+			shm_free(tm_stats->s_transactions);
175
+		if (tm_stats->s_waiting)
176
+			shm_free(tm_stats->s_waiting);
177
+		shm_free(tm_stats);
178
+	}
166 179
 }
... ...
@@ -92,6 +92,11 @@
92 92
 	a REPLY_LOCK.
93 93
 
94 94
 */
95
+/*
96
+ * History:
97
+ * --------
98
+ *  2003-06-27  timers are not unlinked if timerlist is 0 (andrei)
99
+ */
95 100
 
96 101
 #include "defs.h"
97 102
 
... ...
@@ -114,7 +119,7 @@
114 119
 #include "t_cancel.h"
115 120
 
116 121
 
117
-static struct timer_table *timertable;
122
+static struct timer_table *timertable=0;
118 123
 
119 124
 int noisy_ctimer=0;
120 125
 
... ...
@@ -463,6 +468,7 @@ void unlink_timer_lists()
463 468
 	struct timer_link  *tl, *end, *tmp;
464 469
 	enum lists i;
465 470
 
471
+	if (timertable==0) return; /* nothing to do */
466 472
 	/* remember the DELETE LIST */
467 473
 	tl = timertable->timers[DELETE_LIST].first_tl.next_tl;
468 474
 	end = & timertable->timers[DELETE_LIST].last_tl;