소스 검색

The fixup function prototypes of the config variables have been
extended with the group name.
All the fixup functions have been updated.

Miklos Tirpak 16 년 전
부모
커밋
33bfeb9da9
25개의 변경된 파일73개의 추가작업 그리고 63개의 파일을 삭제
  1. 2 2
      cfg.y
  2. 2 2
      cfg/cfg.h
  3. 14 8
      cfg/cfg_ctx.c
  4. 6 2
      cfg/cfg_struct.c
  5. 3 3
      cfg/cfg_struct.h
  6. 5 5
      dns_cache.c
  7. 4 4
      dns_cache.h
  8. 2 2
      doc/cfg.txt
  9. 1 1
      dprint.c
  10. 1 1
      dprint.h
  11. 2 2
      dst_blacklist.c
  12. 2 2
      dst_blacklist.h
  13. 1 1
      modules/tm/t_cancel.c
  14. 1 1
      modules/tm/t_cancel.h
  15. 1 1
      modules/tm/t_fwd.c
  16. 1 1
      modules/tm/t_fwd.h
  17. 1 1
      modules/tm/timer.c
  18. 1 1
      modules/tm/timer.h
  19. 1 1
      msg_translator.c
  20. 1 1
      msg_translator.h
  21. 2 2
      pt.c
  22. 2 2
      pt.h
  23. 4 4
      resolve.c
  24. 4 4
      resolve.h
  25. 9 9
      tcp_options.c

+ 2 - 2
cfg.y

@@ -1287,10 +1287,10 @@ assign_stm:
 	| UDP_MTU EQUAL NUMBER { default_core_cfg.udp_mtu=$3; }
 	| UDP_MTU EQUAL error { yyerror("number expected"); }
 	| FORCE_RPORT EQUAL NUMBER 
-		{ default_core_cfg.force_rport=$3; fix_global_req_flags(0); }
+		{ default_core_cfg.force_rport=$3; fix_global_req_flags(0, 0); }
 	| FORCE_RPORT EQUAL error { yyerror("boolean value expected"); }
 	| UDP_MTU_TRY_PROTO EQUAL proto
-		{ default_core_cfg.udp_mtu_try_proto=$3; fix_global_req_flags(0); }
+		{ default_core_cfg.udp_mtu_try_proto=$3; fix_global_req_flags(0, 0); }
 	| UDP_MTU_TRY_PROTO EQUAL error
 		{ yyerror("TCP, TLS, SCTP or UDP expected"); }
 	| cfg_var

+ 2 - 2
cfg/cfg.h

@@ -56,8 +56,8 @@
 /* variable is read-only */
 #define CFG_READONLY		(1U<<(2*CFG_INPUT_SHIFT+1))
 
-typedef int (*cfg_on_change)(void *, str *, void **);
-typedef void (*cfg_on_set_child)(str *);
+typedef int (*cfg_on_change)(void *, str *, str *, void **);
+typedef void (*cfg_on_set_child)(str *, str *);
 
 /* strutrure to be used by the module interface */
 typedef struct _cfg_def {

+ 14 - 8
cfg/cfg_ctx.c

@@ -258,7 +258,7 @@ int cfg_set_now(cfg_ctx_t *ctx, str *group_name, str *var_name,
 	cfg_mapping_t	*var;
 	void		*p, *v;
 	cfg_block_t	*block = NULL;
-	str		s;
+	str		s, s2;
 	char		*old_string = NULL;
 	char		**replaced = NULL;
 	cfg_child_cb_t	*child_cb = NULL;
@@ -300,6 +300,7 @@ int cfg_set_now(cfg_ctx_t *ctx, str *group_name, str *var_name,
 		There is no need to set a temporary cfg handle,
 		becaue a single variable is changed */
 		if (var->def->on_change_cb(*(group->handle),
+						group_name,
 						var_name,
 						&v) < 0) {
 			LOG(L_ERR, "ERROR: cfg_set_now(): fixup failed\n");
@@ -311,9 +312,11 @@ int cfg_set_now(cfg_ctx_t *ctx, str *group_name, str *var_name,
 	if (var->def->on_set_child_cb) {
 		/* get the name of the variable from the internal struct,
 		because var_name may be freed before the callback needs it */
-		s.s = var->def->name;
-		s.len = var->name_len;
-		child_cb = cfg_child_cb_new(&s,
+		s.s = group->name;
+		s.len = group->name_len;
+		s2.s = var->def->name;
+		s2.len = var->name_len;
+		child_cb = cfg_child_cb_new(&s, &s2,
 					var->def->on_set_child_cb);
 		if (!child_cb) {
 			LOG(L_ERR, "ERROR: cfg_set_now(): not enough shm memory\n");
@@ -579,6 +582,7 @@ int cfg_set_delayed(cfg_ctx_t *ctx, str *group_name, str *var_name,
 		}
 			
 		if (var->def->on_change_cb(temp_handle,
+						group_name,
 						var_name,
 						&v) < 0) {
 			LOG(L_ERR, "ERROR: cfg_set_delayed(): fixup failed\n");
@@ -711,7 +715,7 @@ int cfg_commit(cfg_ctx_t *ctx)
 	cfg_child_cb_t	*child_cb_last = NULL;
 	int	size;
 	void	*p;
-	str	s;
+	str	s, s2;
 
 	if (!ctx) {
 		LOG(L_ERR, "ERROR: cfg_commit(): context is undefined\n");
@@ -740,9 +744,11 @@ int cfg_commit(cfg_ctx_t *ctx)
 
 
 		if (changed->var->def->on_set_child_cb) {
-			s.s = changed->var->def->name;
-			s.len = changed->var->name_len;
-			child_cb = cfg_child_cb_new(&s,
+			s.s = changed->group->name;
+			s.len = changed->group->name_len;
+			s2.s = changed->var->def->name;
+			s2.len = changed->var->name_len;
+			child_cb = cfg_child_cb_new(&s, &s2,
 					changed->var->def->on_set_child_cb);
 			if (!child_cb) goto error0;
 

+ 6 - 2
cfg/cfg_struct.c

@@ -317,7 +317,7 @@ int cfg_init(void)
 	This stucture will be the entry point for the child processes, and
 	will be freed later, when none of the processes refers to it */
 	*cfg_child_cb_first = *cfg_child_cb_last =
-		cfg_child_cb_new(NULL, NULL);
+		cfg_child_cb_new(NULL, NULL, NULL);
 
 	if (!*cfg_child_cb_first) goto error;
 
@@ -552,7 +552,7 @@ void cfg_install_global(cfg_block_t *block, char **replaced,
 }
 
 /* creates a structure for a per-child process callback */
-cfg_child_cb_t *cfg_child_cb_new(str *name, cfg_on_set_child cb)
+cfg_child_cb_t *cfg_child_cb_new(str *gname, str *name, cfg_on_set_child cb)
 {
 	cfg_child_cb_t	*cb_struct;
 
@@ -562,6 +562,10 @@ cfg_child_cb_t *cfg_child_cb_new(str *name, cfg_on_set_child cb)
 		return NULL;
 	}
 	memset(cb_struct, 0, sizeof(cfg_child_cb_t));
+	if (gname) {
+		cb_struct->gname.s = gname->s;
+		cb_struct->gname.len = gname->len;
+	}
 	if (name) {
 		cb_struct->name.s = name->s;
 		cb_struct->name.len = name->len;

+ 3 - 3
cfg/cfg_struct.h

@@ -98,7 +98,7 @@ typedef struct _cfg_block {
 typedef struct _cfg_child_cb {
 	atomic_t		refcnt; /* number of child processes
 					referring to the element */
-	str			name;	/* name of the variable that has changed */
+	str			gname, name;	/* name of the variable that has changed */
 	cfg_on_set_child	cb;	/* callback function that has to be called */
 
 	struct _cfg_child_cb	*next;
@@ -232,7 +232,7 @@ static inline void cfg_update_local(void)
 			}
 		}
 		/* execute the callback */
-		cfg_child_cb->cb(&cfg_child_cb->name);
+		cfg_child_cb->cb(&cfg_child_cb->gname, &cfg_child_cb->name);
 	}
 }
 
@@ -280,7 +280,7 @@ void cfg_install_global(cfg_block_t *block, char **replaced,
 			cfg_child_cb_t *cb_first, cfg_child_cb_t *cb_last);
 
 /* creates a structure for a per-child process callback */
-cfg_child_cb_t *cfg_child_cb_new(str *name, cfg_on_set_child cb);
+cfg_child_cb_t *cfg_child_cb_new(str *gname, str *name, cfg_on_set_child cb);
 
 /* free the memory allocated for a child cb list */
 void cfg_child_cb_free(cfg_child_cb_t *child_cb_first);

+ 5 - 5
dns_cache.c

@@ -265,7 +265,7 @@ void destroy_dns_cache()
 }
 
 /* set the value of dns_flags */
-void fix_dns_flags(str *name)
+void fix_dns_flags(str *gname, str *name)
 {
 	/* restore the original value of dns_cache_flags first
 	 * (DNS_IPV4_ONLY may have been set only because dns_try_ipv6
@@ -300,7 +300,7 @@ void fix_dns_flags(str *name)
 /* fixup function for use_dns_failover
  * verifies that use_dns_cache is set to 1
  */
-int use_dns_failover_fixup(void *handle, str *name, void **val)
+int use_dns_failover_fixup(void *handle, str *gname, str *name, void **val)
 {
 	if ((int)(long)(*val) && !cfg_get(core, handle, use_dns_cache)) {
 		LOG(L_ERR, "ERROR: use_dns_failover_fixup(): "
@@ -314,7 +314,7 @@ int use_dns_failover_fixup(void *handle, str *name, void **val)
 /* fixup function for use_dns_cache
  * verifies that dns_cache_init is set to 1
  */
-int use_dns_cache_fixup(void *handle, str *name, void **val)
+int use_dns_cache_fixup(void *handle, str *gname, str *name, void **val)
 {
 	if ((int)(long)(*val) && !dns_cache_init) {
 		LOG(L_ERR, "ERROR: use_dns_cache_fixup(): "
@@ -332,7 +332,7 @@ int use_dns_cache_fixup(void *handle, str *name, void **val)
 }
 
 /* KByte to Byte conversion */
-int dns_cache_max_mem_fixup(void *handle, str *name, void **val)
+int dns_cache_max_mem_fixup(void *handle, str *gname, str *name, void **val)
 {
 	unsigned int    u;
 
@@ -407,7 +407,7 @@ int init_dns_cache()
 	if (default_core_cfg.use_dns_cache==0)
 		default_core_cfg.use_dns_failover=0; /* cannot work w/o dns_cache support */
 	/* fix flags */
-	fix_dns_flags(NULL);
+	fix_dns_flags(NULL, NULL);
 
 	dns_timer_h=timer_alloc();
 	if (dns_timer_h==0){

+ 4 - 4
dns_cache.h

@@ -178,10 +178,10 @@ struct dns_srv_handle{
 
 const char* dns_strerror(int err);
 
-void fix_dns_flags(str *name);
-int use_dns_failover_fixup(void *handle, str *name, void **val);
-int use_dns_cache_fixup(void *handle, str *name, void **val);
-int dns_cache_max_mem_fixup(void *handle, str *name, void **val);
+void fix_dns_flags(str *gname, str *name);
+int use_dns_failover_fixup(void *handle, str *gname, str *name, void **val);
+int use_dns_cache_fixup(void *handle, str *gname, str *name, void **val);
+int dns_cache_max_mem_fixup(void *handle, str *gname, str *name, void **val);
 int init_dns_cache();
 #ifdef USE_DNS_CACHE_STATS
 int init_dns_cache_stats(int iproc_num);

+ 2 - 2
doc/cfg.txt

@@ -129,7 +129,7 @@ Each row consists of the following items:
   handle within the fixup function. String and str values are cloned to
   shm memory by the framework. The callback type is:
 
-  typedef int (*cfg_on_change)(void *temp_handle, str *var_name, void **value);
+  typedef int (*cfg_on_change)(void *temp_handle, str *group_name, str *var_name, void **value);
 
 - per-child process callback function (optional) that is called by each child
   process separately, after the new values have been committed, and the
@@ -137,7 +137,7 @@ Each row consists of the following items:
   longer be used by the process. (Useful for fix-ups that cannot be done
   in shm memory, for example regexp compilation.)
 
-  typedef void (*cfg_on_set_child)(str *var_name);
+  typedef void (*cfg_on_set_child)(str *group_name, str *var_name);
 
 - description of the variable
 

+ 1 - 1
dprint.c

@@ -83,7 +83,7 @@ int str2facility(char *s)
 }
 
 /* fixup function for log_facility cfg parameter */
-int log_facility_fixup(void *handle, str *name, void **val)
+int log_facility_fixup(void *handle, str *gname, str *name, void **val)
 {
 	int	i;
 

+ 1 - 1
dprint.h

@@ -108,7 +108,7 @@ extern volatile int dprint_crit;
 #endif
 
 int str2facility(char *s);
-int log_facility_fixup(void *handle, str *name, void **val);
+int log_facility_fixup(void *handle, str *gname, str *name, void **val);
 
 
 /*

+ 2 - 2
dst_blacklist.c

@@ -1176,7 +1176,7 @@ void dst_blst_add(rpc_t* rpc, void* ctx)
 /* fixup function for use_dst_blacklist
  * verifies that dst_blacklist_init is set to 1
  */
-int use_dst_blacklist_fixup(void *handle, str *name, void **val)
+int use_dst_blacklist_fixup(void *handle, str *gname, str *name, void **val)
 {
 	if ((int)(long)(*val) && !dst_blacklist_init) {
 		LOG(L_ERR, "ERROR: use_dst_blacklist_fixup(): "
@@ -1188,7 +1188,7 @@ int use_dst_blacklist_fixup(void *handle, str *name, void **val)
 }
 
 /* KByte to Byte conversion */
-int blst_max_mem_fixup(void *handle, str *name, void **val)
+int blst_max_mem_fixup(void *handle, str *gname, str *name, void **val)
 {
 	unsigned int	u;
 

+ 2 - 2
dst_blacklist.h

@@ -116,8 +116,8 @@ int dst_blacklist_del(struct dest_info* si, struct sip_msg* msg);
  */
 void dst_blst_flush(void);
 
-int use_dst_blacklist_fixup(void *handle, str *name, void **val);
+int use_dst_blacklist_fixup(void *handle, str *gname, str *name, void **val);
 /* KByte to Byte conversion */
-int blst_max_mem_fixup(void *handle, str *name, void **val);
+int blst_max_mem_fixup(void *handle, str *gname, str *name, void **val);
 
 #endif

+ 1 - 1
modules/tm/t_cancel.c

@@ -392,7 +392,7 @@ int cancel_b_flags_get(unsigned int* f, int m)
 
 /* fixup function for the default cancel branch method/flags
  * (called by the configuration framework) */
-int cancel_b_flags_fixup(void* handle, str* name, void** val)
+int cancel_b_flags_fixup(void* handle, str* gname, str* name, void** val)
 {
 	unsigned int m,f;
 	int ret;

+ 1 - 1
modules/tm/t_cancel.h

@@ -115,7 +115,7 @@ inline short static should_cancel_branch( struct cell *t, int b, int noreply )
 
 const char* rpc_cancel_doc[2];
 void rpc_cancel(rpc_t* rpc, void* c);
-int cancel_b_flags_fixup(void* handle, str* name, void** val);
+int cancel_b_flags_fixup(void* handle, str* gname, str* name, void** val);
 int cancel_b_flags_get(unsigned int* f, int m);
 
 #endif

+ 1 - 1
modules/tm/t_fwd.c

@@ -1297,7 +1297,7 @@ int t_replicate(struct sip_msg *p_msg,  struct proxy_l *proxy, int proto )
 }
 
 /* fixup function for reparse_on_dns_failover modparam */
-int reparse_on_dns_failover_fixup(void *handle, str *name, void **val)
+int reparse_on_dns_failover_fixup(void *handle, str *gname, str *name, void **val)
 {
 #ifdef USE_DNS_FAILOVER
 	if ((int)(long)(*val) && mhomed) {

+ 1 - 1
modules/tm/t_fwd.h

@@ -76,7 +76,7 @@ int t_send_branch( struct cell *t, int branch, struct sip_msg* p_msg ,
 					struct proxy_l * proxy, int lock_replies);
 int t_relay_cancel(struct sip_msg* p_msg);
 
-int reparse_on_dns_failover_fixup(void *handle, str *name, void **val);
+int reparse_on_dns_failover_fixup(void *handle, str *gname, str *name, void **val);
 
 #endif
 

+ 1 - 1
modules/tm/timer.c

@@ -233,7 +233,7 @@ error:
 /* fixup function for the timer values
  * (called by the configuration framework)
  */
-int timer_fixup(void *handle, str *name, void **val)
+int timer_fixup(void *handle, str *gname, str *name, void **val)
 {
 	ticks_t	t;
 

+ 1 - 1
modules/tm/timer.h

@@ -79,7 +79,7 @@ extern struct msgid_var user_noninv_max_lifetime;
 
 
 extern int tm_init_timers();
-int timer_fixup(void *handle, str *name, void **val);
+int timer_fixup(void *handle, str *gname, str *name, void **val);
 
 ticks_t wait_handler(ticks_t t, struct timer_ln *tl, void* data);
 ticks_t retr_buf_handler(ticks_t t, struct timer_ln *tl, void* data);

+ 1 - 1
msg_translator.c

@@ -162,7 +162,7 @@ static unsigned int global_req_flags=0;
 /** per process fixup function for global_req_flags.
   * It should be called from the configuration framework.
   */
-void fix_global_req_flags( str* name)
+void fix_global_req_flags(str* gname, str* name)
 {
 	global_req_flags=0;
 	switch(cfg_get(core, core_cfg, udp_mtu_try_proto)){

+ 1 - 1
msg_translator.h

@@ -150,6 +150,6 @@ char * build_all( struct sip_msg* msg, int adjust_clen,
 			struct dest_info* send_info);
 
 /** cfg framework fixup */
-void fix_global_req_flags( str* name);
+void fix_global_req_flags(str* gname, str* name);
 
 #endif

+ 2 - 2
pt.c

@@ -522,7 +522,7 @@ end:
  * Per-child process callback that is called
  * when mem_dump_pkg cfg var is changed.
  */
-void mem_dump_pkg_cb(str *name)
+void mem_dump_pkg_cb(str *gname, str *name)
 {
 	int	old_memlog;
 
@@ -545,7 +545,7 @@ void mem_dump_pkg_cb(str *name)
  * fixup function that is called
  * when mem_dump_shm cfg var is set.
  */
-int mem_dump_shm_fixup(void *handle, str *name, void **val)
+int mem_dump_shm_fixup(void *handle, str *gname, str *name, void **val)
 {
 	int	old_memlog;
 

+ 2 - 2
pt.h

@@ -101,11 +101,11 @@ int fork_tcp_process(int child_id,char *desc,int r,int *reader_fd_1);
 #endif
 
 #ifdef PKG_MALLOC
-void mem_dump_pkg_cb(str *name);
+void mem_dump_pkg_cb(str *gname, str *name);
 #endif
 
 #ifdef SHM_MEM
-int mem_dump_shm_fixup(void *handle, str *name, void **val);
+int mem_dump_shm_fixup(void *handle, str *gname, str *name, void **val);
 #endif
 
 #endif

+ 4 - 4
resolve.c

@@ -159,7 +159,7 @@ int resolv_init()
  * This function must be called by each child process whenever
  * a resolver option changes
  */
-void resolv_reinit(str *name)
+void resolv_reinit(str *gname, str *name)
 {
 	_resolv_init();
 
@@ -173,14 +173,14 @@ void resolv_reinit(str *name)
 /* fixup function for dns_reinit variable
  * (resets the variable to 0)
  */
-int dns_reinit_fixup(void *handle, str *name, void **val)
+int dns_reinit_fixup(void *handle, str *gname, str *name, void **val)
 {
 	*val = (void *)(long)0;
 	return 0;
 }
 
 /* wrapper function to recalculate the naptr protocol preferences */
-void reinit_naptr_proto_prefs(str *name)
+void reinit_naptr_proto_prefs(str *gname, str *name)
 {
 #ifdef USE_NAPTR
 	init_naptr_proto_prefs();
@@ -190,7 +190,7 @@ void reinit_naptr_proto_prefs(str *name)
 /* fixup function for dns_try_ipv6
  * verifies that SER really listens on an ipv6 interface
  */
-int dns_try_ipv6_fixup(void *handle, str *name, void **val)
+int dns_try_ipv6_fixup(void *handle, str *gname, str *name, void **val)
 {
 	if ((int)(long)(*val) && !(socket_types & SOCKET_T_IPV6)) {
 		LOG(L_ERR, "ERROR: dns_try_ipv6_fixup(): "

+ 4 - 4
resolve.h

@@ -408,10 +408,10 @@ skip_ipv4:
 int resolv_init();
 
 /* callback/fixup functions executed by the configuration framework */
-void resolv_reinit(str *name);
-int dns_reinit_fixup(void *handle, str *name, void **val);
-int dns_try_ipv6_fixup(void *handle, str *name, void **val);
-void reinit_naptr_proto_prefs(str *name);
+void resolv_reinit(str *gname, str *name);
+int dns_reinit_fixup(void *handle, str *gname, str *name, void **val);
+int dns_try_ipv6_fixup(void *handle, str *gname, str *name, void **val);
+void reinit_naptr_proto_prefs(str *gname, str *name);
 
 #ifdef DNS_WATCHDOG_SUPPORT
 /* callback function that is called by the child processes

+ 9 - 9
tcp_options.c

@@ -65,10 +65,10 @@ struct cfg_group_tcp tcp_default_cfg;
 
 
 
-static int fix_connect_to(void* cfg_h, str* name, void** val);
-static int fix_send_to(void* cfg_h, str* name, void** val);
-static int fix_con_lt(void* cfg_h, str* name, void** val);
-static int fix_max_conns(void* cfg_h, str* name, void** val);
+static int fix_connect_to(void* cfg_h, str* gname, str* name, void** val);
+static int fix_send_to(void* cfg_h, str* gname, str* name, void** val);
+static int fix_con_lt(void* cfg_h, str* gname, str* name, void** val);
+static int fix_max_conns(void* cfg_h, str* gname, str* name, void** val);
 
 
 
@@ -216,7 +216,7 @@ static void fix_timeout(char* name, int* to, int default_val, unsigned max_val)
 
 
 
-static int fix_connect_to(void* cfg_h, str* name, void** val)
+static int fix_connect_to(void* cfg_h, str* gname, str* name, void** val)
 {
 	int v;
 	v=(int)(long)*val;
@@ -227,7 +227,7 @@ static int fix_connect_to(void* cfg_h, str* name, void** val)
 }
 
 
-static int fix_send_to(void* cfg_h, str* name, void** val)
+static int fix_send_to(void* cfg_h, str* gname, str* name, void** val)
 {
 	int v;
 	v=(int)(long)*val;
@@ -241,7 +241,7 @@ static int fix_send_to(void* cfg_h, str* name, void** val)
 }
 
 
-static int fix_con_lt(void* cfg_h, str* name, void** val)
+static int fix_con_lt(void* cfg_h, str* gname, str* name, void** val)
 {
 	int v;
 	v=S_TO_TICKS((int)(long)*val);
@@ -252,7 +252,7 @@ static int fix_con_lt(void* cfg_h, str* name, void** val)
 }
 
 
-static int fix_max_conns(void* cfg_h, str* name, void** val)
+static int fix_max_conns(void* cfg_h, str* gname, str* name, void** val)
 {
 	int v;
 	v=(int)(long)*val;
@@ -288,7 +288,7 @@ static int tcp_cfg_def_fix(char* name, int* val)
 				if (c->on_change_cb){
 					s.s=c->name;
 					s.len=strlen(s.s);
-					return c->on_change_cb(&tcp_default_cfg, &s, (void*)val);
+					return c->on_change_cb(&tcp_default_cfg, NULL, &s, (void*)val);
 				}
 			}
 			return 0;