- when only module.so is given to loadmodule and mpath is set, try mpath/module/module.so if mpath/module.so is not found - useful when runing from sources tree - small adaptions because of renames in kamailio
--- cfg.y | 31 +++++++++++++++++++++++++++---- 1 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/cfg.y b/cfg.y index 44074ab..22a7b74 100644 --- a/cfg.y +++ b/cfg.y @@ -104,6 +104,8 @@ #include <stdarg.h> #include <sys/types.h> #include <sys/socket.h> +#include <sys/stat.h> +#include <unistd.h> #include <netinet/in.h> #include <arpa/inet.h> #include <string.h> @@ -226,6 +228,7 @@ static int case_check_default(struct case_stms* stms); static char *mpath=NULL; static char mpath_buf[256]; static int mpath_len = 0; +static struct stat statf;
%}
@@ -1385,11 +1388,31 @@ cfg_var: } | ID DOT ID EQUAL error { yyerror("number or string expected"); } ; -module_stm: - LOADMODULE STRING { - if(*$2!='/' && mpath!=NULL && strlen($2)+mpath_len<255) - { +module_stm: LOADMODULE STRING { + if(*$2!='/' && mpath!=NULL && strlen($2)+mpath_len<255) { strcpy(mpath_buf+mpath_len, $2); + if (stat(mpath_buf, &statf) == -1) { + i_tmp = strlen(mpath_buf); + if(strchr($2, '/')==NULL && + strncmp(mpath_buf+i_tmp-3, ".so", 3)==0) + { + if(i_tmp+strlen($2)<255) + { + strcpy(mpath_buf+i_tmp-3, "/"); + strcpy(mpath_buf+i_tmp-2, $2); + if (stat(mpath_buf, &statf) == -1) { + mpath_buf[mpath_len]='\0'; + LOG(L_ERR, "module '%s' not found in '%s'\n", + $2, mpath_buf); + yyerror("failed to load module"); + } + } else { + yyerror("failed to load module - path too long"); + } + } else { + yyerror("failed to load module - not found"); + } + } DBG("loading module %s\n", mpath_buf); if (load_module(mpath_buf)!=0){ yyerror("failed to load module");
On Apr 03, 2009 at 12:21, Henning Westerholt henning.westerholt@1und1.de wrote:
- when only module.so is given to loadmodule and mpath is set, try mpath/module/module.so if mpath/module.so is not found
- useful when runing from sources tree
- small adaptions because of renames in kamailio
How is this different from loadpath?
We already have loadpath that does something similar (one difference is that the module must not end in .so if loadpath is to be applied).
Andrei
cfg.y | 31 +++++++++++++++++++++++++++---- 1 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/cfg.y b/cfg.y index 44074ab..22a7b74 100644 --- a/cfg.y +++ b/cfg.y @@ -104,6 +104,8 @@ #include <stdarg.h> #include <sys/types.h> #include <sys/socket.h> +#include <sys/stat.h> +#include <unistd.h> #include <netinet/in.h> #include <arpa/inet.h> #include <string.h> @@ -226,6 +228,7 @@ static int case_check_default(struct case_stms* stms); static char *mpath=NULL; static char mpath_buf[256]; static int mpath_len = 0; +static struct stat statf;
%}
@@ -1385,11 +1388,31 @@ cfg_var: } | ID DOT ID EQUAL error { yyerror("number or string expected"); } ; -module_stm:
- LOADMODULE STRING {
if(*$2!='/' && mpath!=NULL && strlen($2)+mpath_len<255)
{
+module_stm: LOADMODULE STRING {
if(*$2!='/' && mpath!=NULL && strlen($2)+mpath_len<255) { strcpy(mpath_buf+mpath_len, $2);
if (stat(mpath_buf, &statf) == -1) {
i_tmp = strlen(mpath_buf);
if(strchr($2, '/')==NULL &&
strncmp(mpath_buf+i_tmp-3, ".so", 3)==0)
{
if(i_tmp+strlen($2)<255)
{
strcpy(mpath_buf+i_tmp-3, "/");
strcpy(mpath_buf+i_tmp-2, $2);
if (stat(mpath_buf, &statf) == -1) {
mpath_buf[mpath_len]='\0';
LOG(L_ERR, "module '%s' not found in '%s'\n",
$2, mpath_buf);
yyerror("failed to load module");
}
} else {
yyerror("failed to load module - path too long");
}
} else {
yyerror("failed to load module - not found");
}
} DBG("loading module %s\n", mpath_buf); if (load_module(mpath_buf)!=0){ yyerror("failed to load module");
-- 1.5.6.5
sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
On Friday 03 April 2009, Andrei Pelinescu-Onciul wrote:
- when only module.so is given to loadmodule and mpath is set, try mpath/module/module.so if mpath/module.so is not found
- useful when runing from sources tree
- small adaptions because of renames in kamailio
How is this different from loadpath?
We already have loadpath that does something similar (one difference is that the module must not end in .so if loadpath is to be applied).
Hi Andrei,
i was not aware of this loadpath stuff, even if i noticed it in the parser. I've searched for this on iptel.org in the documentation search and also with google, but did not found something. Is there a reference somewhere of this SER core parameters, for the future?
I've tested the loadpath, there is one difference. If you specify
loadpath "modules/" loadmodule "tm"
It will only try to load "modules/tm.so". This patchs added supports that it also tries to load "modules/tm/tm.so" if its not found in the first location, which is really handy if you run kamailio from a source tree. It necessary to change it to use the loadpath, though.
Cheers,
Henning
Henning,
On 03-04 13:25, Henning Westerholt wrote:
On Friday 03 April 2009, Andrei Pelinescu-Onciul wrote:
- when only module.so is given to loadmodule and mpath is set, try mpath/module/module.so if mpath/module.so is not found
- useful when runing from sources tree
- small adaptions because of renames in kamailio
How is this different from loadpath?
We already have loadpath that does something similar (one difference is that the module must not end in .so if loadpath is to be applied).
Hi Andrei,
i was not aware of this loadpath stuff, even if i noticed it in the parser. I've searched for this on iptel.org in the documentation search and also with google, but did not found something. Is there a reference somewhere of this SER core parameters, for the future?
See the main configuration file in etc/ser-oob.cfg, that file is using it.
I've tested the loadpath, there is one difference. If you specify
loadpath "modules/" loadmodule "tm"
It will only try to load "modules/tm.so". This patchs added supports that it also tries to load "modules/tm/tm.so" if its not found in the first location, which is really handy if you run kamailio from a source tree. It necessary to
loadpath does that too, see sr_module.c:load_module
Jan.
On Friday 03 April 2009, Jan Janak wrote:
I've tested the loadpath, there is one difference. If you specify
loadpath "modules/" loadmodule "tm"
It will only try to load "modules/tm.so". This patchs added supports that it also tries to load "modules/tm/tm.so" if its not found in the first location, which is really handy if you run kamailio from a source tree. It necessary to
loadpath does that too, see sr_module.c:load_module
Jan,
the code is enclosed in a EXTRA_DEBUG define, this is probably the reason that my test fail. Perhaps we can make the EXTRA_DEBUG case the default, and remove the #else case?
Cheers,
Henning
On 03-04 13:42, Henning Westerholt wrote:
On Friday 03 April 2009, Jan Janak wrote:
I've tested the loadpath, there is one difference. If you specify
loadpath "modules/" loadmodule "tm"
It will only try to load "modules/tm.so". This patchs added supports that it also tries to load "modules/tm/tm.so" if its not found in the first location, which is really handy if you run kamailio from a source tree. It necessary to
loadpath does that too, see sr_module.c:load_module
Jan,
the code is enclosed in a EXTRA_DEBUG define, this is probably the reason that my test fail. Perhaps we can make the EXTRA_DEBUG case the default, and remove the #else case?
Ahh, you are right, I didn't notice this because I was looking at another version of this file where the EXTRA_DEBUG is gone. Yes, I agree that this should be made default, feel free to remove the EXTRA_DEBUG
Jan.
On Friday 03 April 2009, Jan Janak wrote:
the code is enclosed in a EXTRA_DEBUG define, this is probably the reason that my test fail. Perhaps we can make the EXTRA_DEBUG case the default, and remove the #else case?
Ahh, you are right, I didn't notice this because I was looking at another version of this file where the EXTRA_DEBUG is gone. Yes, I agree that this should be made default, feel free to remove the EXTRA_DEBUG
done, works now.
Henning