... | ... |
@@ -3,10 +3,10 @@ $Id$ |
3 | 3 |
( - todo, x - done) |
4 | 4 |
|
5 | 5 |
release: |
6 |
-- resolver should resolve [ipv6] |
|
6 |
+x resolver should resolve [ipv6] |
|
7 | 7 |
- remove parse_uri debugging info |
8 | 8 |
- fix DBG("<%.*s>", len, _null_) |
9 |
-- add -t, -w, -u -g equivalents to the config file |
|
9 |
+x add -t, -w, -u -g equivalents to the config file |
|
10 | 10 |
x force add rport : force_rport() |
11 | 11 |
- kill all the fprintf |
12 | 12 |
see also tcp & tm |
... | ... |
@@ -24,6 +24,12 @@ |
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-04-14 more debugging added in DBG_QM_MALLOC mode (andrei) |
|
32 |
+ */ |
|
27 | 33 |
|
28 | 34 |
|
29 | 35 |
#if !defined(q_malloc) && !(defined VQ_MALLOC) && !(defined F_MALLOC) |
... | ... |
@@ -97,23 +103,29 @@ inline static int big_hash_idx(int s) |
97 | 103 |
static void qm_debug_frag(struct qm_block* qm, struct qm_frag* f) |
98 | 104 |
{ |
99 | 105 |
if (f->check!=ST_CHECK_PATTERN){ |
100 |
- LOG(L_CRIT, "BUG: qm_*: fragm. %p beginning overwritten(%lx)!\n", |
|
101 |
- f, f->check); |
|
106 |
+ LOG(L_CRIT, "BUG: qm_*: fragm. %p (address %p) " |
|
107 |
+ "beginning overwritten(%lx)!\n", |
|
108 |
+ f, (char*)f+sizeof(struct qm_frag), |
|
109 |
+ f->check); |
|
102 | 110 |
qm_status(qm); |
103 | 111 |
abort(); |
104 | 112 |
}; |
105 | 113 |
if ((FRAG_END(f)->check1!=END_CHECK_PATTERN1)|| |
106 | 114 |
(FRAG_END(f)->check2!=END_CHECK_PATTERN2)){ |
107 |
- LOG(L_CRIT, "BUG: qm_*: fragm. %p end overwritten(%lx, %lx)!\n", |
|
108 |
- f, FRAG_END(f)->check1, FRAG_END(f)->check2); |
|
115 |
+ LOG(L_CRIT, "BUG: qm_*: fragm. %p (address %p)" |
|
116 |
+ " end overwritten(%lx, %lx)!\n", |
|
117 |
+ f, (char*)f+sizeof(struct qm_frag), |
|
118 |
+ FRAG_END(f)->check1, FRAG_END(f)->check2); |
|
109 | 119 |
qm_status(qm); |
110 | 120 |
abort(); |
111 | 121 |
} |
112 | 122 |
if ((f>qm->first_frag)&& |
113 | 123 |
((PREV_FRAG_END(f)->check1!=END_CHECK_PATTERN1) || |
114 | 124 |
(PREV_FRAG_END(f)->check2!=END_CHECK_PATTERN2) ) ){ |
115 |
- LOG(L_CRIT, "BUG: qm_*: prev. fragm. tail overwritten(%lx, %lx)[%p]!\n" |
|
116 |
- ,PREV_FRAG_END(f)->check1, PREV_FRAG_END(f)->check2, f); |
|
125 |
+ LOG(L_CRIT, "BUG: qm_*: prev. fragm. tail overwritten(%lx, %lx)[%p:%p]!" |
|
126 |
+ "\n", |
|
127 |
+ PREV_FRAG_END(f)->check1, PREV_FRAG_END(f)->check2, f, |
|
128 |
+ (char*)f+sizeof(struct qm_frag)); |
|
117 | 129 |
qm_status(qm); |
118 | 130 |
abort(); |
119 | 131 |
} |
... | ... |
@@ -227,9 +239,14 @@ static inline void qm_detach_free(struct qm_block* qm, struct qm_frag* frag) |
227 | 239 |
} |
228 | 240 |
|
229 | 241 |
|
230 |
- |
|
242 |
+#ifdef DBG_QM_MALLOC |
|
243 |
+static inline struct qm_frag* qm_find_free(struct qm_block* qm, |
|
244 |
+ unsigned int size, |
|
245 |
+ unsigned int *count) |
|
246 |
+#else |
|
231 | 247 |
static inline struct qm_frag* qm_find_free(struct qm_block* qm, |
232 |
- unsigned int size) |
|
248 |
+ unsigned int size) |
|
249 |
+#endif |
|
233 | 250 |
{ |
234 | 251 |
int hash; |
235 | 252 |
struct qm_frag* f; |
... | ... |
@@ -237,6 +254,9 @@ static inline struct qm_frag* qm_find_free(struct qm_block* qm, |
237 | 254 |
for (hash=GET_HASH(size); hash<QM_HASH_SIZE; hash++){ |
238 | 255 |
for (f=qm->free_hash[hash].head.u.nxt_free; |
239 | 256 |
f!=&(qm->free_hash[hash].head); f=f->u.nxt_free){ |
257 |
+#ifdef DBG_QM_MALLOC |
|
258 |
+ *count+=1; /* *count++ generates a warning with gcc 2.9* -Wall */ |
|
259 |
+#endif |
|
240 | 260 |
if (f->size>=size) return f; |
241 | 261 |
} |
242 | 262 |
/*try in a bigger bucket*/ |
... | ... |
@@ -271,7 +291,11 @@ void* qm_malloc(struct qm_block* qm, unsigned int size) |
271 | 291 |
if (size>(qm->size-qm->real_used)) return 0; |
272 | 292 |
|
273 | 293 |
/*search for a suitable free frag*/ |
294 |
+#ifdef DBG_QM_MALLOC |
|
295 |
+ if ((f=qm_find_free(qm, size, &list_cntr))!=0){ |
|
296 |
+#else |
|
274 | 297 |
if ((f=qm_find_free(qm, size))!=0){ |
298 |
+#endif |
|
275 | 299 |
/* we found it!*/ |
276 | 300 |
/*detach it from the free list*/ |
277 | 301 |
#ifdef DBG_QM_MALLOC |
... | ... |
@@ -319,8 +343,9 @@ void* qm_malloc(struct qm_block* qm, unsigned int size) |
319 | 343 |
f->check=ST_CHECK_PATTERN; |
320 | 344 |
/* FRAG_END(f)->check1=END_CHECK_PATTERN1; |
321 | 345 |
FRAG_END(f)->check2=END_CHECK_PATTERN2;*/ |
322 |
- DBG("qm_malloc(%p, %d) returns address %p on %d -th hit\n", qm, size, |
|
323 |
- (char*)f+sizeof(struct qm_frag), list_cntr ); |
|
346 |
+ DBG("qm_malloc(%p, %d) returns address %p frag. %p (size=%ld) on %d -th" |
|
347 |
+ " hit\n", |
|
348 |
+ qm, size, (char*)f+sizeof(struct qm_frag), f, f->size, list_cntr ); |
|
324 | 349 |
#endif |
325 | 350 |
return (char*)f+sizeof(struct qm_frag); |
326 | 351 |
} |
... | ... |
@@ -363,8 +388,8 @@ void qm_free(struct qm_block* qm, void* p) |
363 | 388 |
f->file, f->func, f->line); |
364 | 389 |
abort(); |
365 | 390 |
} |
366 |
- DBG("qm_free: freeing block alloc'ed from %s: %s(%ld)\n", f->file, f->func, |
|
367 |
- f->line); |
|
391 |
+ DBG("qm_free: freeing frag. %p alloc'ed from %s: %s(%ld)\n", |
|
392 |
+ f, f->file, f->func, f->line); |
|
368 | 393 |
#endif |
369 | 394 |
size=f->size; |
370 | 395 |
qm->used-=size; |
... | ... |
@@ -429,9 +454,9 @@ void qm_status(struct qm_block* qm) |
429 | 454 |
for (f=qm->first_frag, i=0;(char*)f<(char*)qm->last_frag_end;f=FRAG_NEXT(f) |
430 | 455 |
,i++){ |
431 | 456 |
if (! f->u.is_free){ |
432 |
- LOG(memlog, " %3d. %c address=%p size=%ld\n", i, |
|
457 |
+ LOG(memlog, " %3d. %c address=%p frag=%p size=%ld\n", i, |
|
433 | 458 |
(f->u.is_free)?'a':'N', |
434 |
- (char*)f+sizeof(struct qm_frag), f->size); |
|
459 |
+ (char*)f+sizeof(struct qm_frag), f, f->size); |
|
435 | 460 |
#ifdef DBG_QM_MALLOC |
436 | 461 |
LOG(memlog, " %s from %s: %s(%ld)\n", |
437 | 462 |
(f->u.is_free)?"freed":"alloc'd", f->file, f->func, f->line); |