Forráskód Böngészése

htable: removed useless mode param from ht_cell_value_add()

- it was used only once with mode=1
Daniel-Constantin Mierla 8 éve
szülő
commit
13f34f0eff
3 módosított fájl, 12 hozzáadás és 14 törlés
  1. 10 11
      src/modules/htable/ht_api.c
  2. 1 2
      src/modules/htable/ht_api.h
  3. 1 1
      src/modules/htable/ht_var.c

+ 10 - 11
src/modules/htable/ht_api.c

@@ -641,8 +641,7 @@ int ht_del_cell(ht_t *ht, str *name)
 	return 0;
 }
 
-ht_cell_t* ht_cell_value_add(ht_t *ht, str *name, int val, int mode,
-		ht_cell_t *old)
+ht_cell_t* ht_cell_value_add(ht_t *ht, str *name, int val, ht_cell_t *old)
 {
 	unsigned int idx;
 	unsigned int hid;
@@ -661,7 +660,7 @@ ht_cell_t* ht_cell_value_add(ht_t *ht, str *name, int val, int mode,
 	if(ht->htexpire>0)
 		now = time(NULL);
 	prev = NULL;
-	if(mode) ht_slot_lock(ht, idx);
+	ht_slot_lock(ht, idx);
 	it = ht->entries[idx].first;
 	while(it!=NULL && it->cellid < hid)
 	{
@@ -683,7 +682,7 @@ ht_cell_t* ht_cell_value_add(ht_t *ht, str *name, int val, int mode,
 					it->value.n = ht->initval.n;
 					/* increment will be done below */
 				} else {
-					if(mode) ht_slot_unlock(ht, idx);
+					ht_slot_unlock(ht, idx);
 					return NULL;
 				}
 			}
@@ -691,7 +690,7 @@ ht_cell_t* ht_cell_value_add(ht_t *ht, str *name, int val, int mode,
 			if(it->flags&AVP_VAL_STR)
 			{
 				/* string value cannot be incremented */
-				if(mode) ht_slot_unlock(ht, idx);
+				ht_slot_unlock(ht, idx);
 				return NULL;
 			} else {
 				it->value.n += val;
@@ -702,7 +701,7 @@ ht_cell_t* ht_cell_value_add(ht_t *ht, str *name, int val, int mode,
 					if(old->msize>=it->msize)
 					{
 						memcpy(old, it, it->msize);
-						if(mode) ht_slot_unlock(ht, idx);
+						ht_slot_unlock(ht, idx);
 						return old;
 					}
 				}
@@ -710,7 +709,7 @@ ht_cell_t* ht_cell_value_add(ht_t *ht, str *name, int val, int mode,
 				if(cell!=NULL)
 					memcpy(cell, it, it->msize);
 
-				if(mode) ht_slot_unlock(ht, idx);
+				ht_slot_unlock(ht, idx);
 				return cell;
 			}
 		}
@@ -720,7 +719,7 @@ ht_cell_t* ht_cell_value_add(ht_t *ht, str *name, int val, int mode,
 	/* add val if htable has an integer init value */
 	if(ht->flags!=PV_VAL_INT)
 	{
-		if(mode) ht_slot_unlock(ht, idx);
+		ht_slot_unlock(ht, idx);
 		return NULL;
 	}
 	isval.n = ht->initval.n + val;
@@ -728,7 +727,7 @@ ht_cell_t* ht_cell_value_add(ht_t *ht, str *name, int val, int mode,
 	if(it == NULL)
 	{
 		LM_ERR("cannot create new cell.\n");
-		if(mode) ht_slot_unlock(ht, idx);
+		ht_slot_unlock(ht, idx);
 		return NULL;
 	}
 	it->expire = now + ht->htexpire;
@@ -753,7 +752,7 @@ ht_cell_t* ht_cell_value_add(ht_t *ht, str *name, int val, int mode,
 		if(old->msize>=it->msize)
 		{
 			memcpy(old, it, it->msize);
-			if(mode) ht_slot_unlock(ht, idx);
+			ht_slot_unlock(ht, idx);
 			return old;
 		}
 	}
@@ -761,7 +760,7 @@ ht_cell_t* ht_cell_value_add(ht_t *ht, str *name, int val, int mode,
 	if(cell!=NULL)
 		memcpy(cell, it, it->msize);
 
-	if(mode) ht_slot_unlock(ht, idx);
+	ht_slot_unlock(ht, idx);
 	return cell;
 }
 

+ 1 - 2
src/modules/htable/ht_api.h

@@ -91,8 +91,7 @@ int ht_init_tables(void);
 int ht_destroy(void);
 int ht_set_cell(ht_t *ht, str *name, int type, int_str *val, int mode);
 int ht_del_cell(ht_t *ht, str *name);
-ht_cell_t* ht_cell_value_add(ht_t *ht, str *name, int val, int mode,
-		ht_cell_t *old);
+ht_cell_t* ht_cell_value_add(ht_t *ht, str *name, int val, ht_cell_t *old);
 
 int ht_dbg(void);
 ht_cell_t* ht_cell_pkg_copy(ht_t *ht, str *name, ht_cell_t *old);

+ 1 - 1
src/modules/htable/ht_var.c

@@ -331,7 +331,7 @@ int pv_get_ht_add(struct sip_msg *msg,  pv_param_t *param,
 		LM_ERR("cannot get $sht name\n");
 		return -1;
 	}
-	htc = ht_cell_value_add(hpv->ht, &htname, val, 1, _htc_local);
+	htc = ht_cell_value_add(hpv->ht, &htname, val, _htc_local);
 	if(_htc_local!=htc)
 	{
 		ht_cell_pkg_free(_htc_local);