瀏覽代碼

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

 - -L is in the group of options evaluated before config
Daniel-Constantin Mierla 11 年之前
父節點
當前提交
e1e40d3a58
共有 3 個文件被更改,包括 19 次插入6 次删除
  1. 16 6
      cfg.y
  2. 1 0
      globals.h
  3. 2 0
      main.c

+ 16 - 6
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 {

+ 1 - 0
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;

+ 2 - 0
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;