Browse code

- added fm_realloc (now only vm_ misses realloc) - cosmetic fixes in ip_addr (print_ip changed)

Andrei Pelinescu-Onciul authored on 06/07/2003 18:43:16
Showing 13 changed files
... ...
@@ -40,7 +40,7 @@ export makefile_defs
40 40
 VERSION = 0
41 41
 PATCHLEVEL = 8
42 42
 SUBLEVEL =   12
43
-EXTRAVERSION = dev-t06
43
+EXTRAVERSION = dev-t07
44 44
 
45 45
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
46 46
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")
... ...
@@ -272,7 +272,9 @@ DEFS+= $(extra_defs) \
272 272
 	 -DUSE_IPV6 \
273 273
 	 -DUSE_TCP \
274 274
 	 -DDISABLE_NAGLE \
275
-	 -DDBG_QM_MALLOC \
275
+	 -DF_MALLOC \
276
+	# -DDBG_F_MALLOC \
277
+	# -DDBG_QM_MALLOC \
276 278
 	 #-DF_MALLOC \
277 279
 	 #-DNO_DEBUG \
278 280
 	 #-DNO_LOG
... ...
@@ -3,7 +3,7 @@ $Id$
3 3
 ( - todo, x - done)
4 4
 
5 5
 release:
6
-- fix kill(0, SIGTERM) on startup error (will kill also the launching shell
6
+x fix kill(0, SIGTERM) on startup error (will kill also the launching shell
7 7
  if non-interactive)
8 8
 - fix modules destroy (some modules will try to free uninitialized resources
9 9
    if modules_init was not called first)
... ...
@@ -93,24 +93,29 @@ error:
93 93
 
94 94
 
95 95
 
96
-void print_ip(struct ip_addr* ip)
96
+void print_ip(char* p, struct ip_addr* ip, char *s)
97 97
 {
98 98
 	switch(ip->af){
99 99
 		case AF_INET:
100
-			DBG("%d.%d.%d.%d",	ip->u.addr[0],
100
+			DBG("%s%d.%d.%d.%d%s", (p)?p:"",
101
+								ip->u.addr[0],
101 102
 								ip->u.addr[1],
102 103
 								ip->u.addr[2],
103
-								ip->u.addr[3]);
104
+								ip->u.addr[3],
105
+								(s)?s:""
106
+								);
104 107
 			break;
105 108
 		case AF_INET6:
106
-			DBG("%x:%x:%x:%x:%x:%x:%x:%x",	htons(ip->u.addr16[0]),
109
+			DBG("%s%x:%x:%x:%x:%x:%x:%x:%x%s", (p)?p:"",
110
+											htons(ip->u.addr16[0]),
107 111
 											htons(ip->u.addr16[1]),
108 112
 											htons(ip->u.addr16[2]),
109 113
 											htons(ip->u.addr16[3]),
110 114
 											htons(ip->u.addr16[4]),
111 115
 											htons(ip->u.addr16[5]),
112 116
 											htons(ip->u.addr16[6]),
113
-											htons(ip->u.addr16[7])
117
+											htons(ip->u.addr16[7]),
118
+											(s)?s:""
114 119
 				);
115 120
 			break;
116 121
 		default:
... ...
@@ -153,5 +158,5 @@ void print_net(struct net* net)
153 153
 		LOG(L_WARN, "ERROR: print net: null pointer\n");
154 154
 		return;
155 155
 	}
156
-	print_ip(&net->ip); DBG("/"); print_ip(&net->mask);
156
+	print_ip("", &net->ip, "/"); print_ip("", &net->mask, "");
157 157
 }
... ...
@@ -157,7 +157,7 @@ struct dest_info{
157 157
 struct net* mk_net(struct ip_addr* ip, struct ip_addr* mask);
158 158
 struct net* mk_net_bitlen(struct ip_addr* ip, unsigned int bitlen);
159 159
 
160
-void print_ip(struct ip_addr* ip);
160
+void print_ip(char* prefix, struct ip_addr* ip, char* suffix);
161 161
 void stdout_print_ip(struct ip_addr* ip);
162 162
 void print_net(struct net* net);
163 163
 
... ...
@@ -24,11 +24,18 @@
24 24
  * along with this program; if not, write to the Free Software 
25 25
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26 26
  */
27
+/*
28
+ * History:
29
+ * --------
30
+ *              created by andrei
31
+ *  2003-07-06  added fm_realloc (andrei)
32
+ */
27 33
 
28 34
 
29 35
 #if !defined(q_malloc) && !(defined VQ_MALLOC)  && (defined F_MALLOC)
30 36
 
31 37
 #include <string.h>
38
+#include <stdlib.h>
32 39
 
33 40
 #include "f_malloc.h"
34 41
 #include "../dprint.h"
... ...
@@ -107,7 +114,42 @@ static inline void fm_insert_free(struct fm_block* qm, struct fm_frag* frag)
107 107
 
108 108
 
109 109
 
110
-/* init malloc and return a qm_block*/
110
+ /* size should be already rounded-up */
111
+static inline
112
+#ifdef DBG_F_MALLOC 
113
+void fm_split_frag(struct fm_block* qm, struct fm_frag* frag,unsigned int size,
114
+					char* file, char* func, unsigned int line)
115
+#else
116
+void fm_split_frag(struct fm_block* qm, struct fm_frag* frag,unsigned int size)
117
+#endif
118
+{
119
+	unsigned int rest;
120
+	struct fm_frag* n;
121
+	
122
+	rest=frag->size-size;
123
+	if (rest>(FRAG_OVERHEAD+MIN_FRAG_SIZE)){
124
+		frag->size=size;
125
+		/*split the fragment*/
126
+		n=FRAG_NEXT(frag);
127
+		n->size=rest-FRAG_OVERHEAD;
128
+#ifdef DBG_F_MALLOC
129
+		qm->real_used+=FRAG_OVERHEAD;
130
+		/* frag created by malloc, mark it*/
131
+		n->file=file;
132
+		n->func="frag. from fm_malloc";
133
+		n->line=line;
134
+		n->check=ST_CHECK_PATTERN;
135
+#endif
136
+		/* reinsert n in free list*/
137
+		fm_insert_free(qm, n);
138
+	}else{
139
+		/* we cannot split this fragment any more => alloc all of it*/
140
+	}
141
+}
142
+
143
+
144
+
145
+/* init malloc and return a fm_block*/
111 146
 struct fm_block* fm_malloc_init(char* address, unsigned int size)
112 147
 {
113 148
 	char* start;
... ...
@@ -170,12 +212,10 @@ void* fm_malloc(struct fm_block* qm, unsigned int size)
170 170
 {
171 171
 	struct fm_frag** f;
172 172
 	struct fm_frag* frag;
173
-	struct fm_frag* n;
174
-	unsigned int rest;
175 173
 	int hash;
176 174
 	
177 175
 #ifdef DBG_F_MALLOC
178
-	DBG("fm_malloc(%x, %d) called from %s: %s(%d)\n", qm, size, file, func,
176
+	DBG("fm_malloc(%p, %d) called from %s: %s(%d)\n", qm, size, file, func,
179 177
 			line);
180 178
 #endif
181 179
 	/*size must be a multiple of 8*/
... ...
@@ -199,28 +239,12 @@ found:
199 199
 	/* detach it from the free list*/
200 200
 	frag=*f;
201 201
 	*f=frag->u.nxt_free;
202
+	frag->u.nxt_free=0; /* mark it as 'taken' */
202 203
 	
203 204
 	/*see if we'll use full frag, or we'll split it in 2*/
204
-	rest=frag->size-size;
205
-	if (rest>(FRAG_OVERHEAD+MIN_FRAG_SIZE)){
206
-		frag->size=size;
207
-		/*split the fragment*/
208
-		n=FRAG_NEXT(frag);
209
-		n->size=rest-FRAG_OVERHEAD;
210
-#ifdef DBG_F_MALLOC
211
-		qm->real_used+=FRAG_OVERHEAD;
212
-		/* frag created by malloc, mark it*/
213
-		n->file=file;
214
-		n->func="frag. from qm_malloc";
215
-		n->line=line;
216
-		n->check=ST_CHECK_PATTERN;
217
-#endif
218
-		/* reinsert n in free list*/
219
-		fm_insert_free(qm, n);
220
-	}else{
221
-		/* we cannot split this fragment any more => alloc all of it*/
222
-	}
205
+	
223 206
 #ifdef DBG_F_MALLOC
207
+	fm_split_frag(qm, frag, size, file, func, line);
224 208
 	qm->real_used+=frag->size;
225 209
 	qm->used+=frag->size;
226 210
 
... ...
@@ -231,8 +255,10 @@ found:
231 231
 	frag->func=func;
232 232
 	frag->line=line;
233 233
 	frag->check=ST_CHECK_PATTERN;
234
-	DBG("fm_malloc(%x, %d) returns address %x \n", qm, size,
234
+	DBG("fm_malloc(%p, %d) returns address %p \n", qm, size,
235 235
 		(char*)frag+sizeof(struct fm_frag));
236
+#else
237
+	fm_split_frag(qm, frag, size);
236 238
 #endif
237 239
 	return (char*)frag+sizeof(struct fm_frag);
238 240
 }
... ...
@@ -250,9 +276,9 @@ void fm_free(struct fm_block* qm, void* p)
250 250
 	unsigned int size;
251 251
 
252 252
 #ifdef DBG_F_MALLOC
253
-	DBG("fm_free(%x, %x), called from %s: %s(%d)\n", qm, p, file, func, line);
253
+	DBG("fm_free(%p, %p), called from %s: %s(%d)\n", qm, p, file, func, line);
254 254
 	if (p>(void*)qm->last_frag || p<(void*)qm->first_frag){
255
-		LOG(L_CRIT, "BUG: fm_free: bad pointer %x (out of memory block!) - "
255
+		LOG(L_CRIT, "BUG: fm_free: bad pointer %p (out of memory block!) - "
256 256
 				"aborting\n", p);
257 257
 		abort();
258 258
 	}
... ...
@@ -263,7 +289,7 @@ void fm_free(struct fm_block* qm, void* p)
263 263
 	}
264 264
 	f=(struct fm_frag*) ((char*)p-sizeof(struct fm_frag));
265 265
 #ifdef DBG_F_MALLOC
266
-	DBG("fm_free: freeing block alloc'ed from %s: %s(%d)\n", f->file, f->func,
266
+	DBG("fm_free: freeing block alloc'ed from %s: %s(%ld)\n", f->file, f->func,
267 267
 			f->line);
268 268
 #endif
269 269
 	size=f->size;
... ...
@@ -279,6 +305,131 @@ void fm_free(struct fm_block* qm, void* p)
279 279
 }
280 280
 
281 281
 
282
+#ifdef DBG_F_MALLOC
283
+void* fm_realloc(struct fm_block* qm, void* p, unsigned int size,
284
+					char* file, char* func, unsigned int line)
285
+#else
286
+void* fm_realloc(struct fm_block* qm, void* p, unsigned int size)
287
+#endif
288
+{
289
+	struct fm_frag *f;
290
+	struct fm_frag **pf;
291
+	unsigned int diff;
292
+	unsigned int orig_size;
293
+	struct fm_frag *n;
294
+	void *ptr;
295
+	
296
+#ifdef DBG_F_MALLOC
297
+	DBG("fm_realloc(%p, %p, %d) called from %s: %s(%d)\n", qm, p, size,
298
+			file, func, line);
299
+	if (p>(void*)qm->last_frag || p<(void*)qm->first_frag){
300
+		LOG(L_CRIT, "BUG: fm_free: bad pointer %p (out of memory block!) - "
301
+				"aborting\n", p);
302
+		abort();
303
+	}
304
+#endif
305
+	if (size==0) {
306
+		if (p)
307
+#ifdef DBG_F_MALLOC
308
+			fm_free(qm, p, file, func, line);
309
+#else
310
+			fm_free(qm, p);
311
+#endif
312
+		return 0;
313
+	}
314
+	if (p==0)
315
+#ifdef DBG_F_MALLOC
316
+		return fm_malloc(qm, size, file, func, line);
317
+#else
318
+		return fm_malloc(qm, size);
319
+#endif
320
+	f=(struct fm_frag*) ((char*)p-sizeof(struct fm_frag));
321
+#ifdef DBG_F_MALLOC
322
+	DBG("fm_realloc: realloc'ing frag %p alloc'ed from %s: %s(%ld)\n",
323
+			f, f->file, f->func, f->line);
324
+#endif
325
+	size=ROUNDUP(size);
326
+	orig_size=f->size;
327
+	if (f->size > size){
328
+		/* shrink */
329
+#ifdef DBG_F_MALLOC
330
+		DBG("fm_realloc: shrinking from %ld to %d\n", f->size, size);
331
+		fm_split_frag(qm, f, size, file, "frag. from fm_realloc", line);
332
+		qm->real_used-=(orig_size-f->size);
333
+		qm->used-=(orig_size-f->size);
334
+#else
335
+		fm_split_frag(qm, f, size);
336
+#endif
337
+	}else if (f->size<size){
338
+		/* grow */
339
+#ifdef DBG_F_MALLOC
340
+		DBG("fm_realloc: growing from %ld to %d\n", f->size, size);
341
+#endif
342
+		diff=size-f->size;
343
+		n=FRAG_NEXT(f);
344
+		if (((char*)n < (char*)qm->last_frag) && 
345
+				(n->u.nxt_free)&&((n->size+FRAG_OVERHEAD)>=diff)){
346
+			/* join  */
347
+			/* detach n from the free list */
348
+			pf=&(qm->free_hash[GET_HASH(n->size)]);
349
+			/* find it */
350
+			for(;(*pf)&&(*pf!=n); pf=&((*pf)->u.nxt_free));
351
+			if (*pf==0){
352
+				/* not found, bad! */
353
+				LOG(L_CRIT, "BUG: fm_realloc: could not find %p in free "
354
+						"list (hash=%ld)\n", n, GET_HASH(n->size));
355
+				abort();
356
+			}
357
+			/* detach */
358
+			*pf=n->u.nxt_free;
359
+			/* join */
360
+			f->size+=n->size+FRAG_OVERHEAD;
361
+		#ifdef DBG_F_MALLOC
362
+			qm->real_used-=FRAG_OVERHEAD;
363
+		#endif
364
+			/* split it if necessary */
365
+			if (f->size > size){
366
+		#ifdef DBG_F_MALLOC
367
+				fm_split_frag(qm, f, size, file, "fragm. from fm_realloc",
368
+						line);
369
+		#else
370
+				fm_split_frag(qm, f, size);
371
+		#endif
372
+			}
373
+		#ifdef DBG_F_MALLOC
374
+			qm->real_used+=(f->size-orig_size);
375
+			qm->used+=(f->size-orig_size);
376
+		#endif
377
+		}else{
378
+			/* could not join => realloc */
379
+	#ifdef DBG_F_MALLOC
380
+			ptr=fm_malloc(qm, size, file, func, line);
381
+	#else
382
+			ptr=fm_malloc(qm, size);
383
+	#endif
384
+			if (ptr)
385
+				/* copy, need by libssl */
386
+				memcpy(ptr, p, orig_size);
387
+	#ifdef DBG_F_MALLOC
388
+				fm_free(qm, p, file, func, line);
389
+	#else
390
+				fm_free(qm, p);
391
+	#endif
392
+				p=ptr;
393
+			}
394
+	}else{
395
+		/* do nothing */
396
+#ifdef DBG_F_MALLOC
397
+		DBG("fm_realloc: doing nothing, same size: %ld - %d\n", f->size, size);
398
+#endif
399
+	}
400
+#ifdef DBG_F_MALLOC
401
+	DBG("fm_realloc: returning %p\n", p);
402
+#endif
403
+	return p;
404
+}
405
+
406
+
282 407
 
283 408
 void fm_status(struct fm_block* qm)
284 409
 {
... ...
@@ -118,6 +118,13 @@ void  fm_free(struct fm_block*, void* p, char* file, char* func,
118 118
 void  fm_free(struct fm_block*, void* p);
119 119
 #endif
120 120
 
121
+#ifdef DBG_F_MALLOC
122
+void*  fm_realloc(struct fm_block*, void* p, unsigned int size, 
123
+					char* file, char* func, unsigned int line);
124
+#else
125
+void*  fm_realloc(struct fm_block*, void* p, unsigned int size);
126
+#endif
127
+
121 128
 void  fm_status(struct fm_block*);
122 129
 
123 130
 
... ...
@@ -42,6 +42,17 @@
42 42
 #include "../config.h"
43 43
 #include "../dprint.h"
44 44
 
45
+/* fix debug defines, DBG_F_MALLOC <=> DBG_QM_MALLOC */
46
+#ifdef F_MALLOC
47
+	#ifdef DBG_F_MALLOC
48
+		#ifndef DBG_QM_MALLOC
49
+			#define DBG_QM_MALLOC
50
+		#endif
51
+	#elif defined(DBG_QM_MALLOC)
52
+		#define DBG_F_MALLOC
53
+	#endif
54
+#endif
55
+
45 56
 #ifdef PKG_MALLOC
46 57
 #	ifdef VQ_MALLOC
47 58
 #		include "vq_malloc.h"
... ...
@@ -66,11 +77,14 @@
66 66
 				__FUNCTION__, __LINE__)
67 67
 #			define pkg_free(p)   vqm_free(mem_block, (p), __FILE__,  \
68 68
 				__FUNCTION__, __LINE__)
69
+#			warn "no proper realloc implementation, use another mem. alloc"
69 70
 #		elif defined F_MALLOC
70 71
 #			define pkg_malloc(s) fm_malloc(mem_block, (s),__FILE__, \
71 72
 				__FUNCTION__, __LINE__)
72 73
 #			define pkg_free(p)   fm_free(mem_block, (p), __FILE__,  \
73 74
 				__FUNCTION__, __LINE__)
75
+#			define pkg_realloc(p, s) fm_realloc(mem_block, (p), (s),__FILE__, \
76
+				__FUNCTION__, __LINE__)
74 77
 #		else
75 78
 #			define pkg_malloc(s) qm_malloc(mem_block, (s),__FILE__, \
76 79
 				__FUNCTION__, __LINE__)
... ...
@@ -85,6 +99,7 @@
85 85
 #			define pkg_free(p)   vqm_free(mem_block, (p))
86 86
 #		elif defined F_MALLOC
87 87
 #			define pkg_malloc(s) fm_malloc(mem_block, (s))
88
+#			define pkg_realloc(p, s) fm_realloc(mem_block, (p), (s))
88 89
 #			define pkg_free(p)   fm_free(mem_block, (p))
89 90
 #		else
90 91
 #			define pkg_malloc(s) qm_malloc(mem_block, (s))
... ...
@@ -268,7 +268,7 @@ static inline struct qm_frag* qm_find_free(struct qm_block* qm,
268 268
 
269 269
 
270 270
 /* returns 0 on success, -1 on error;
271
- * new_size < size & rounduped already!*/
271
+ * new_size < size & rounded-up already!*/
272 272
 static inline
273 273
 #ifdef DBG_QM_MALLOC
274 274
 int split_frag(struct qm_block* qm, struct qm_frag* f, unsigned int new_size,
... ...
@@ -64,11 +64,13 @@
64 64
 #	define MY_FREE vqm_free
65 65
 #	define MY_STATUS vqm_status
66 66
 #	define  shm_malloc_init vqm_malloc_init
67
+#	warn "no proper vq_realloc implementantion, try another memory allocator"
67 68
 #elif defined F_MALLOC
68 69
 #	include "f_malloc.h"
69 70
 	extern struct fm_block* shm_block;
70 71
 #	define MY_MALLOC fm_malloc
71 72
 #	define MY_FREE fm_free
73
+#	define MY_REALLOC fm_realloc
72 74
 #	define MY_STATUS fm_status
73 75
 #	define  shm_malloc_init fm_malloc_init
74 76
 #else
... ...
@@ -96,6 +98,18 @@ void shm_mem_destroy();
96 96
 #define shm_lock()    lock_get(mem_lock)
97 97
 #define shm_unlock()  lock_release(mem_lock)
98 98
 
99
+/* fix DBG MALLOC stuff */
100
+
101
+/* fix debug defines, DBG_F_MALLOC <=> DBG_QM_MALLOC */
102
+#ifdef F_MALLOC
103
+	#ifdef DBG_F_MALLOC
104
+		#ifndef DBG_QM_MALLOC
105
+			#define DBG_QM_MALLOC
106
+		#endif
107
+	#elif defined(DBG_QM_MALLOC)
108
+		#define DBG_F_MALLOC
109
+	#endif
110
+#endif
99 111
 
100 112
 
101 113
 #ifdef DBG_QM_MALLOC
... ...
@@ -370,9 +370,8 @@ inline static int comp_ip(struct ip_addr* ip, void* param, int op, int subtype)
370 370
 			 * !!??!! review: remove this? */
371 371
 			he=rev_resolvehost(ip);
372 372
 			if (he==0){
373
-				DBG( "comp_ip: could not rev_resolve ip address: ");
374
-				print_ip(ip);
375
-				DBG("\n");
373
+				print_ip( "comp_ip: could not rev_resolve ip address: ",
374
+							ip, "\n");
376 375
 				ret=0;
377 376
 			}else{
378 377
 				/*  compare with primary host name */
... ...
@@ -184,7 +184,7 @@ void print_expr(struct expr* exp)
184 184
 					print_net((struct net*)exp->r.param);
185 185
 					break;
186 186
 			case IP_ST:
187
-					print_ip((struct ip_addr*)exp->r.param);
187
+					print_ip("", (struct ip_addr*)exp->r.param, "");
188 188
 					break;
189 189
 			case ACTIONS_ST:
190 190
 					print_action((struct action*)exp->r.param);
... ...
@@ -328,7 +328,7 @@ void print_action(struct action* a)
328 328
 					DBG("%lu",t->p1.number);
329 329
 					break;
330 330
 			case IP_ST:
331
-					print_ip((struct ip_addr*)t->p1.data);
331
+					print_ip("", (struct ip_addr*)t->p1.data, "");
332 332
 					break;
333 333
 			case EXPR_ST:
334 334
 					print_expr((struct expr*)t->p1.data);
... ...
@@ -147,6 +147,8 @@ struct tcp_connection* tcpconn_new(int sock, union sockaddr_union* su,
147 147
 		c->rcv.dst_ip=ba->address;
148 148
 		c->rcv.dst_port=ba->port_no;
149 149
 	}
150
+	print_ip("tcpconn_new: new tcp connection: ", &c->rcv.src_ip, "\n");
151
+	DBG(     "tcpconn_new: on port %d, type %d\n", c->rcv.src_port, type);
150 152
 	init_tcp_req(&c->req);
151 153
 	c->id=connection_id++;
152 154
 	c->rcv.proto_reserved1=0; /* this will be filled before receive_message*/
... ...
@@ -313,15 +315,15 @@ struct tcp_connection* _tcpconn_find(int id, struct ip_addr* ip, int port)
313 313
 	unsigned hash;
314 314
 	
315 315
 #ifdef EXTRA_DEBUG
316
-	DBG("tcpconn_find: %d ",id ); print_ip(ip); DBG(" %d\n", port);
316
+	DBG("tcpconn_find: %d  port %d\n",id, port);
317
+	print_ip("tcpconn_find: ip ", ip, "\n");
317 318
 #endif
318 319
 	if (id){
319 320
 		hash=tcp_id_hash(id);
320 321
 		for (c=tcpconn_id_hash[hash]; c; c=c->id_next){
321 322
 #ifdef EXTRA_DEBUG
322
-			DBG("c=%p, c->id=%d, ip=",c, c->id);
323
-			print_ip(&c->rcv.src_ip);
324
-			DBG(" port=%d\n", c->rcv.src_port);
323
+			DBG("c=%p, c->id=%d, port=%d\n",c, c->id, c->rcv.src_port);
324
+			print_ip("ip=", &c->rcv.src_ip, "\n");
325 325
 #endif
326 326
 			if ((id==c->id)&&(c->state!=S_CONN_BAD)) return c;
327 327
 		}
... ...
@@ -329,9 +331,8 @@ struct tcp_connection* _tcpconn_find(int id, struct ip_addr* ip, int port)
329 329
 		hash=tcp_addr_hash(ip, port);
330 330
 		for (c=tcpconn_addr_hash[hash]; c; c=c->next){
331 331
 #ifdef EXTRA_DEBUG
332
-			DBG("c=%p, c->id=%d, ip=",c, c->id);
333
-			print_ip(&c->rcv.src_ip);
334
-			DBG(" port=%d\n", c->rcv.src_port);
332
+			DBG("c=%p, c->id=%d, port=%d\n",c, c->id, c->rcv.src_port);
333
+			print_ip("ip=",&c->rcv.src_ip,"\n");
335 334
 #endif
336 335
 			if ( (c->state!=S_CONN_BAD) && (port==c->rcv.src_port) &&
337 336
 					(ip_addr_cmp(ip, &c->rcv.src_ip)) )
... ...
@@ -450,16 +450,16 @@ again:
450 450
 					  "buf:\n%.*s\nparsed:\n%.*s\n", req->state, req->error,
451 451
 					  (int)(req->pos-req->buf), req->buf,
452 452
 					  (int)(req->parsed-req->start), req->start);
453
-			DBG("- received from: port %d, ip -", con->rcv.src_port);
454
-			print_ip(&con->rcv.src_ip); DBG("-\n");
453
+			DBG("- received from: port %d\n", con->rcv.src_port);
454
+			print_ip("- received from: ip ",&con->rcv.src_ip, "\n");
455 455
 			resp=CONN_ERROR;
456 456
 			goto end_req;
457 457
 		}
458 458
 		if (req->complete){
459 459
 #ifdef EXTRA_DEBUG
460 460
 			DBG("tcp_read_req: end of header part\n");
461
-			DBG("- received from: port %d, ip - ", con->rcv.src_port);
462
-			print_ip(&con->rcv.src_ip); DBG("-\n");
461
+			DBG("- received from: port %d\n", con->rcv.src_port);
462
+			print_ip("- received from: ip ", &con->rcv.src_ip, "\n");
463 463
 			DBG("tcp_read_req: headers:\n%.*s.\n",
464 464
 					(int)(req->body-req->start), req->start);
465 465
 #endif