Browse code

- changed malloc status to LOG(L_INFO) - fixed a malloc(0) in tm/sip_msg.c/*cloner (new_uri)

Andrei Pelinescu-Onciul authored on 06/12/2001 23:43:46
Showing 8 changed files
... ...
@@ -35,7 +35,7 @@ NAME=ser
35 35
 #                  twice, trying to free a pointer alloc'ed with a different
36 36
 #                  malloc etc.)
37 37
 DEFS=-DNOCR -DMACROEATER -DDNS_IP_HACK  -DSHM_MEM \
38
-	 -DPKG_MALLOC -DDBG_QM_MALLOC 
38
+	 -DPKG_MALLOC -DNO_DEBUG -DDBG_QM_MALLOC 
39 39
 #-DEXTRA_DEBUG
40 40
 # -DUSE_SHM_MEM
41 41
 #-DNO_DEBUG 
... ...
@@ -330,11 +330,14 @@ static void sig_usr(int signo)
330 330
 		if (is_main)
331 331
 			destroy_modules();
332 332
 #ifdef PKG_MALLOC
333
+		LOG(L_INFO, "Memory status (pkg):\n");
333 334
 		pkg_status();
334 335
 #endif
335 336
 #ifdef SHM_MEM
336
-		if (is_main)
337
+		if (is_main){
338
+			LOG(L_INFO, "Memory status (shm):\n");
337 339
 			shm_status();
340
+		}
338 341
 #endif
339 342
 #ifdef SHM_MEM
340 343
 		if (is_main)
... ...
@@ -346,9 +349,11 @@ static void sig_usr(int signo)
346 346
 		dump_all_statistic();
347 347
 #endif
348 348
 #ifdef PKG_MALLOC
349
+		LOG(L_INFO, "Memory status (pkg):\n");
349 350
 		pkg_status();
350 351
 #endif
351 352
 #ifdef SHM_MEM
353
+		LOG(L_INFO, "Memory status (shm):\n");
352 354
 		shm_status();
353 355
 #endif
354 356
 	}
... ...
@@ -62,9 +62,12 @@ struct sip_msg* sip_msg_cloner( struct sip_msg *org_msg )
62 62
     }
63 63
 
64 64
     /* new_uri  ( str type )*/
65
-    if (!(new_msg->new_uri.s = (char*)sh_malloc( org_msg->new_uri.len )))
66
-	goto error;
67
-    memcpy( new_msg->new_uri.s , org_msg->new_uri.s , org_msg->new_uri.len );
65
+	if (org_msg->new_uri.s){ 
66
+		if (!(new_msg->new_uri.s = (char*)sh_malloc( org_msg->new_uri.len )))
67
+			goto error;
68
+		memcpy( new_msg->new_uri.s , org_msg->new_uri.s ,
69
+				org_msg->new_uri.len );
70
+	}
68 71
 
69 72
     /* add_rm ( struct lump* )  -> have to be changed!!!!!!! */
70 73
     new_msg->add_rm  = 0;
... ...
@@ -258,19 +258,20 @@ void qm_status(struct qm_block* qm)
258 258
 	struct qm_frag* f;
259 259
 	int i;
260 260
 
261
-	DBG("qm_status (%x):\n", qm);
262
-	DBG(" heap size= %d\n", qm->size);
263
-	DBG(" used= %d, used+overhead=%d, free=%d\n",
261
+	LOG(L_INFO, "qm_status (%x):\n", qm);
262
+	LOG(L_INFO, " heap size= %d\n", qm->size);
263
+	LOG(L_INFO, " used= %d, used+overhead=%d, free=%d\n",
264 264
 			qm->used, qm->real_used, qm->size-qm->real_used);
265
-	DBG(" max used (+overhead)= %d\n", qm->max_real_used);
265
+	LOG(L_INFO, " max used (+overhead)= %d\n", qm->max_real_used);
266 266
 	
267
-	DBG("dumping all fragments:\n");
267
+	LOG(L_INFO, "dumping all fragments:\n");
268 268
 	for (f=qm->first_frag, i=0;(char*)f<(char*)qm->last_frag_end;f=FRAG_NEXT(f)
269 269
 			,i++){
270
-		DBG("    %3d. %c  address=%x  size=%d\n", i, (f->u.is_free)?'a':'N',
270
+		LOG(L_INFO, "    %3d. %c  address=%x  size=%d\n", i, 
271
+				(f->u.is_free)?'a':'N',
271 272
 				(char*)f+sizeof(struct qm_frag), f->size);
272 273
 #ifdef DBG_QM_MALLOC
273
-		DBG("            %s from %s: %s(%d)\n",
274
+		LOG(L_INFO, "            %s from %s: %s(%d)\n",
274 275
 				(f->u.is_free)?"freed":"alloc'd", f->file, f->func, f->line);
275 276
 #endif
276 277
 	}
... ...
@@ -284,7 +285,7 @@ void qm_status(struct qm_block* qm)
284 284
 				(f->u.is_free)?"freed":"alloc'd", f->file, f->func, f->line);
285 285
 #endif
286 286
 	}
287
-	DBG("-----------------------------\n");
287
+	LOG(L_INFO, "-----------------------------\n");
288 288
 }
289 289
 
290 290
 
291 291
new file mode 100644
... ...
@@ -0,0 +1,9 @@
0
+INVITE sip:foo@127.0.0.1:5061  SIP/2.0
1
+Via: SIP/2.0/UDP 127.0.0.1:5062
2
+From:  <sip:x@foo.bar>
3
+To: <sip:y@bar.foo>
4
+Call-ID: 9437892232b@foo.bar
5
+CSeq: 143 INVITE
6
+Contact:<sip:x@foo.bar>
7
+
8
+
0 9
new file mode 100644
... ...
@@ -0,0 +1,58 @@
0
+debug=9          # debug level (cmd line: -dddddddddd)
1
+check_via=yes     # (cmd. line: -v)
2
+dns=on           # (cmd. line: -r)
3
+rev_dns=yes      # (cmd. line: -R)
4
+fork=no          # (cmd. line: -D)
5
+#children=5
6
+log_stderror=yes # (cmd line: -E)
7
+#port=5080
8
+#listen=192.168.99.100
9
+loop_checks=1
10
+# for more info: sip_router -h
11
+
12
+#modules
13
+loadmodule "modules/print/print.so"
14
+loadmodule "modules/tm/tm.so"
15
+
16
+route{
17
+	#rewritehost("iptel.org");
18
+	log("trying forward to uri");
19
+#	forward(uri:host,uri:port);
20
+#	forward(127.0.0.1, 5090);
21
+	log("after forward");
22
+
23
+	if ( t_lookup_request()) {
24
+		print("\nFOUND REQUEST\n");
25
+		if ( method=="ACK" )	{
26
+			log("SER: ACK received -> t_release\n");
27
+			t_release();
28
+		} else {
29
+			t_retransmit_reply();
30
+			log("SER: yet another annoying retranmission\n");
31
+		};
32
+	} else {
33
+		print("\nbefore add transaction\n");
34
+		t_add_transaction();
35
+		print("\nafter add transaction\n");
36
+		if (method=="CANCEL") {
37
+			log("SER: new CANCEL\n");
38
+			# XXX ... it wants me to put status code in ""
39
+			t_send_reply( "200", "glad to cancel");
40
+		} else {
41
+		print("\nELSE if method\n");
42
+			log("SER: new transaction\n");
43
+			t_send_reply("100", "trying -- your call is important to us");
44
+		};
45
+		print("\nbefore rewrite host\n");
46
+		rewritehost("iptel.org");
47
+		# XXX ... it wants me to put port nr in ""
48
+		#t_forward("benetnash.fokus.gmd.de", "5080" );
49
+		#t_forward("iptel.org", "5060" );
50
+		print("\nbefore forward uri\n");
51
+		t_forward_uri();
52
+		# XXX ... it doesn't like default port numbers
53
+		# t_forward("fox.iptel.org" );
54
+		# XXX t_forward_uri ... not done yet
55
+	};
56
+		
57
+}
0 58
new file mode 100644
... ...
@@ -0,0 +1,50 @@
0
+debug=9          # debug level (cmd line: -dddddddddd)
1
+check_via=yes     # (cmd. line: -v)
2
+dns=on           # (cmd. line: -r)
3
+rev_dns=yes      # (cmd. line: -R)
4
+fork=no          # (cmd. line: -D)
5
+#children=5
6
+log_stderror=yes # (cmd line: -E)
7
+#port=5080
8
+#listen=192.168.99.100
9
+loop_checks=1
10
+# for more info: sip_router -h
11
+
12
+#modules
13
+loadmodule "modules/print/print.so"
14
+loadmodule "modules/tm/tm.so"
15
+
16
+route{
17
+	#rewritehost("iptel.org");
18
+#	forward(uri:host,uri:port);
19
+#	forward(127.0.0.1, 5090);
20
+
21
+	if ( t_lookup_request()) {
22
+		if ( method=="ACK" )	{
23
+			log("SER: ACK received -> t_release\n");
24
+			t_release();
25
+		} else {
26
+			t_retransmit_reply();
27
+#			log("SER: yet another annoying retranmission\n");
28
+		};
29
+	} else {
30
+		t_add_transaction();
31
+		if (method=="CANCEL") {
32
+			log("SER: new CANCEL\n");
33
+			# XXX ... it wants me to put status code in ""
34
+			t_send_reply( "200", "glad to cancel");
35
+		} else {
36
+			log("SER: new transaction\n");
37
+			t_send_reply("100", "trying -- your call is important to us");
38
+		};
39
+#		rewritehost("iptel.org");
40
+		# XXX ... it wants me to put port nr in ""
41
+		#t_forward("benetnash.fokus.gmd.de", "5080" );
42
+		#t_forward("iptel.org", "5060" );
43
+		t_forward_uri();
44
+		# XXX ... it doesn't like default port numbers
45
+		# t_forward("fox.iptel.org" );
46
+		# XXX t_forward_uri ... not done yet
47
+	};
48
+		
49
+}
... ...
@@ -240,7 +240,9 @@ again:
240 240
 	n=sendto(udp_sock, buf, len, 0, to, tolen);
241 241
 /*	n=sendto(udp_sock, buf, len, 0, &a2, sizeof(struct sockaddr_in) );*/
242 242
 	if (n==-1){
243
-		LOG(L_ERR, "ERROR: udp_send: sendto: %s\n", strerror(errno));
243
+		LOG(L_ERR, "ERROR: udp_send: sendto(sock,%x,%d,0,%x,%d): %s(%d)\n",
244
+				buf,len,to,tolen,
245
+				strerror(errno),errno);
244 246
 		if (errno==EINTR) goto again;
245 247
 		if (errno==EINVAL) LOG(L_CRIT,"CRITICAL: invalid sendtoparameters\n"
246 248
 			"one possible reason is the server is bound to localhost and\n"