浏览代码

- fixed alloc optimize to small
- nicer *malloc status

Andrei Pelinescu-Onciul 23 年之前
父节点
当前提交
0eb1315e1a
共有 8 个文件被更改,包括 26 次插入25 次删除
  1. 4 4
      Makefile.defs
  2. 1 1
      main.c
  3. 9 4
      mem/f_malloc.c
  4. 1 1
      mem/f_malloc.h
  5. 1 1
      mem/q_malloc.c
  6. 1 1
      mem/q_malloc.h
  7. 6 9
      modules/tm/sip_msg.c
  8. 3 4
      msg_parser.c

+ 4 - 4
Makefile.defs

@@ -9,7 +9,7 @@
 VERSION = 0
 PATCHLEVEL = 8
 SUBLEVEL = 6
-EXTRAVERSION = 2
+EXTRAVERSION = -3
 
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 OS = $(shell uname -s)
@@ -60,7 +60,7 @@ ARCH = $(shell uname -m |sed -e s/i.86/i386/ -e s/sun4u/sparc64/ )
 DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
 	 -DOS='"$(OS)"' -DCOMPILER='"$(CC_VER)"'\
 	 -DDNS_IP_HACK  -DPKG_MALLOC -DSHM_MEM  -DSHM_MMAP \
-	 -DUSE_SYNONIM #-DF_MALLOC \
+	 -DUSE_SYNONIM -DF_MALLOC \
 	 #-DEXTRA_DEBUG 
 	 #-DVQ_MALLOC  -DDBG_LOCK  #-DSTATS
 	 #-DDBG_QM_MALLOC #-DNO_DEBUG
@@ -73,11 +73,11 @@ DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
 
 # arh. specific definitions
 ifeq ($(ARCH), i386)
-#	DEFS+= -DFAST_LOCK
+	DEFS+= -DFAST_LOCK
 endif
 
 ifeq ($(ARCH), sparc64)
-#	DEFS+= -DFAST_LOCK
+	DEFS+= -DFAST_LOCK
 endif
 
 

+ 1 - 1
main.c

@@ -94,7 +94,7 @@ static char flags[]=
 static char help_msg[]= "\
 Usage: " NAME " -l address [-l address] [options]\n\
 Options:\n\
-    -c		 Perform loop checks and compute branches\n\
+    -c           Perform loop checks and compute branches\n\
     -f file      Configuration file (default " CFG_FILE ")\n\
     -p port      Listen on the specified port (default: 5060)\n\
     -l address   Listen on the specified address (multiple -l mean\n\

+ 9 - 4
mem/f_malloc.c

@@ -257,11 +257,10 @@ void fm_status(struct fm_block* qm)
 			qm->used, qm->real_used, qm->size-qm->real_used);
 	LOG(L_INFO, " max used (+overhead)= %d\n", qm->max_real_used);
 #endif
-	
+	/*
 	LOG(L_INFO, "dumping all fragments:\n");
 	for (f=qm->first_frag, i=0;((char*)f<(char*)qm->last_frag) && (i<10);
-			f=FRAG_NEXT(f)
-			,i++){
+			f=FRAG_NEXT(f), i++){
 		LOG(L_INFO, "    %3d. %c  address=%x  size=%d\n", i, 
 				(f->u.reserved)?'a':'N',
 				(char*)f+sizeof(struct fm_frag), f->size);
@@ -270,10 +269,14 @@ void fm_status(struct fm_block* qm)
 				(f->u.is_free)?"freed":"alloc'd", f->file, f->func, f->line);
 #endif
 	}
+*/
 	LOG(L_INFO, "dumping free list:\n");
 	for(h=0,i=0;h<F_HASH_SIZE;h++){
 		
-		for (f=qm->free_hash[h],j=0; f; f=f->u.nxt_free, i++, j++){
+		for (f=qm->free_hash[h],j=0; f; f=f->u.nxt_free, i++, j++)
+			if (j) LOG(L_INFO, "hash= %3d. fragments no.: %5d\n", h, j);
+		/*
+		{
 			LOG(L_INFO, "   %5d.[%3d:%3d] %c  address=%x  size=%d(%x)\n",
 					i, h, j,
 					(f->u.reserved)?'a':'N',
@@ -283,7 +286,9 @@ void fm_status(struct fm_block* qm)
 				(f->u.reserved)?"freed":"alloc'd", f->file, f->func, f->line);
 #endif
 		}
+	*/
 	}
+	LOG(L_INFO, "	Total: %6d fragments\n", i);
 	LOG(L_INFO, "-----------------------------\n");
 }
 

+ 1 - 1
mem/f_malloc.h

@@ -16,7 +16,7 @@
 
 
 
-#define F_MALLOC_OPTIMIZE_FACTOR 10 /*used below */
+#define F_MALLOC_OPTIMIZE_FACTOR 11 /*used below */
 #define F_MALLOC_OPTIMIZE  (1<<F_MALLOC_OPTIMIZE_FACTOR)
 								/* size to optimize for,
 									(most allocs < this size),

+ 1 - 1
mem/q_malloc.c

@@ -417,7 +417,7 @@ void qm_status(struct qm_block* qm)
 		
 		for (f=qm->free_hash[h].head.u.nxt_free,j=0; 
 				f!=&(qm->free_hash[h].head); f=f->u.nxt_free, i++, j++);
-		if (j) LOG(L_INFO, "hash= %3d. fragments no.: %5d\n", h, j);
+			if (j) LOG(L_INFO, "hash= %3d. fragments no.: %5d\n", h, j);
 	}
 	LOG(L_INFO, "-----------------------------\n");
 }

+ 1 - 1
mem/q_malloc.h

@@ -18,7 +18,7 @@
 
 
 
-#define QM_MALLOC_OPTIMIZE_FACTOR 10 /*used below */
+#define QM_MALLOC_OPTIMIZE_FACTOR 11 /*used below */
 #define QM_MALLOC_OPTIMIZE  (1<<QM_MALLOC_OPTIMIZE_FACTOR)
 								/* size to optimize for,
 									(most allocs < this size),

+ 6 - 9
modules/tm/sip_msg.c

@@ -39,7 +39,6 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg )
    struct lump          *lump_chain, *lump_tmp, **lump_anchor, **lump_anchor2;
    struct lump_rpl    *rpl_lump, **rpl_lump_anchor;
    char                       *p,*foo;
-   int k1=0,k2=0,k3=0,k4=0,k5=0,k6=0;
 
 
    /*computing the length of entire sip_msg structure*/
@@ -83,17 +82,17 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg )
    else
       lump_chain = org_msg->repl_add_rm;
    while (lump_chain)
-   {  k1++;
+   {  
       len += lump_len( lump_chain );
       lump_tmp = lump_chain->before;
       while ( lump_tmp )
-      {  k2++;
+      {  
          len += lump_len( lump_tmp );
          lump_tmp = lump_tmp->before;
       }
       lump_tmp = lump_chain->after;
       while ( lump_tmp )
-      {  k3++;
+      {  
          len += lump_len( lump_tmp );
          lump_tmp = lump_tmp->after;
       }
@@ -271,13 +270,13 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg )
       lump_anchor = &(new_msg->repl_add_rm);
    }
    while (lump_chain)
-   {  k4++;
+   {  
       lump_clone( (*lump_anchor) , lump_chain , p );
       /*before list*/
       lump_tmp = lump_chain->before;
       lump_anchor2 = &((*lump_anchor)->before);
       while ( lump_tmp )
-      {  k5++;
+      {  
          lump_clone( (*lump_anchor2) , lump_tmp , p );
          lump_anchor2 = &((*lump_anchor2)->before);
          lump_tmp = lump_tmp->before;
@@ -286,7 +285,7 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg )
       lump_tmp = lump_chain->after;
       lump_anchor2 = &((*lump_anchor)->after);
       while ( lump_tmp )
-      {  k6++;
+      {  
          lump_clone( (*lump_anchor2) , lump_tmp , p );
          lump_anchor2 = &((*lump_anchor2)->after);
          lump_tmp = lump_tmp->after;
@@ -308,8 +307,6 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg )
        (*rpl_lump_anchor)->next=0;
        rpl_lump_anchor = &((*rpl_lump_anchor)->next);
    }
-    DBG("DEBUG:cloner (  %d < %d,%d> )  ---  ( %d < %d , %d > )\n",
-       k1,k2,k3,k4,k5,k6);
     DBG("DEBUG:cloner --------<%d>---------<%d>-------------\n",len,p-foo);
    return new_msg;
 }

+ 3 - 4
msg_parser.c

@@ -254,19 +254,18 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
 				goto error;
 			}
 			memset(to_b, 0, sizeof(struct to_body));
-			/*
 			hdr->body.s=tmp;
 			tmp=parse_to(tmp, end,to_b);
 			if (to_b->error==PARSE_ERROR){
 				LOG(L_ERR, "ERROR: get_hdr_field: bad to header\n");
 				pkg_free(to_b);
 				goto error;
-			}*/
-			hdr->parsed=to_b;/*
+			}
+			hdr->parsed=to_b;
 			hdr->body.len=tmp-hdr->body.s;
 			DBG("get_hdr_field: to <%s>: <%s>=[%d] <%c> [%d]\n",
 				hdr->name.s, to_b->body.s,to_b->body.len,*tmp,hdr->body.len);
-			break;*/
+			break;
 		case HDR_FROM:
 		case HDR_CALLID:
 		case HDR_CONTACT: