[SR-Dev] [PATCH 2/2] port from kamailio, r4007

Andrei Pelinescu-Onciul andrei at iptel.org
Fri Apr 3 12:27:26 CEST 2009


On Apr 03, 2009 at 12:21, Henning Westerholt <henning.westerholt at 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 at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev



More information about the sr-dev mailing list