[sr-dev] git:master: core: fixed overwriting mpath value given in command line via config

Daniel-Constantin Mierla miconda at gmail.com
Wed Oct 1 16:57:45 CEST 2014


Module: sip-router
Branch: master
Commit: e1e40d3a58bf3ed6c4f2df830e29d5468d7bee82
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=e1e40d3a58bf3ed6c4f2df830e29d5468d7bee82

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Wed Oct  1 16:53:44 2014 +0200

core: fixed overwriting mpath value given in command line via config

 - -L is in the group of options evaluated before config

---

 cfg.y     |   22 ++++++++++++++++------
 globals.h |    1 +
 main.c    |    2 ++
 3 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/cfg.y b/cfg.y
index 1e52289..2e7a6b4 100644
--- a/cfg.y
+++ b/cfg.y
@@ -1651,15 +1651,25 @@ module_stm:
 	}
 	| LOADMODULE error	{ yyerror("string expected"); }
 	| LOADPATH STRING {
-		DBG("loading modules under %s\n", $2);
-		printf("loading modules under %s\n", $2);
-		mods_dir = $2;
+		if(mods_dir_cmd==0) {
+			DBG("loading modules under %s\n", $2);
+			printf("loading modules under config path: %s\n", $2);
+			mods_dir = $2;
+		} else {
+			DBG("ignoring mod path given in config: %s\n", $2);
+			printf("loading modules under command line path: %s\n", mods_dir);
+		}
 	}
 	| LOADPATH error	{ yyerror("string expected"); }
 	| LOADPATH EQUAL STRING {
-		DBG("loading modules under %s\n", $3);
-		printf("loading modules under %s\n", $3);
-		mods_dir = $3;
+		if(mods_dir_cmd==0) {
+			DBG("loading modules under %s\n", $3);
+			printf("loading modules under config path: %s\n", $3);
+			mods_dir = $3;
+		} else {
+			DBG("ignoring mod path given in config: %s\n", $3);
+			printf("loading modules under command line path: %s\n", mods_dir);
+		}
 	}
 	| LOADPATH EQUAL error	{ yyerror("string expected"); }
 	| MODPARAM LPAREN STRING COMMA STRING COMMA STRING RPAREN {
diff --git a/globals.h b/globals.h
index 0e02c7c..76e7f35 100644
--- a/globals.h
+++ b/globals.h
@@ -44,6 +44,7 @@
 
 
 extern char* mods_dir;   /* directory with dyn. loadable modules */
+extern int mods_dir_cmd; /* marker if mods dir was set in command line */
 extern char* cfg_file;
 extern int config_check;
 extern char* stat_file;
diff --git a/main.c b/main.c
index be75335..8a566b0 100644
--- a/main.c
+++ b/main.c
@@ -337,6 +337,7 @@ int own_pgid = 0; /* whether or not we have our own pgid (and it's ok
 					 to use kill(0, sig) */
 
 char* mods_dir = MODS_DIR;  /* search path for dyn. loadable modules */
+int   mods_dir_cmd = 0; /* mods dir path set in command lin e*/
 
 char* cfg_file = 0;
 unsigned int maxbuffer = MAX_RECV_BUFFER_SIZE; /* maximum buffer size we do
@@ -1939,6 +1940,7 @@ int main(int argc, char** argv)
 					break;
 			case 'L':
 					mods_dir = optarg;
+					mods_dir_cmd = 1;
 					break;
 			case 'm':
 					shm_mem_size=strtol(optarg, &tmp, 10) * 1024 * 1024;




More information about the sr-dev mailing list