Fixed faulty searching for matching filter directive
This commit was SVN r21177.
Этот коммит содержится в:
родитель
4ff860db1f
Коммит
3f83c94328
@ -245,4 +245,5 @@
|
|||||||
5.4.9
|
5.4.9
|
||||||
- install header files to 'PREFIX/include/vampirtrace' by default to
|
- install header files to 'PREFIX/include/vampirtrace' by default to
|
||||||
avoid conflicts with the OpenMPI integrated version of VT
|
avoid conflicts with the OpenMPI integrated version of VT
|
||||||
|
- fixed faulty searching for matching filter directive
|
||||||
|
|
||||||
|
@ -13,22 +13,21 @@
|
|||||||
#define STRBUF_SIZE 0x400 /* buffer size for strings */
|
#define STRBUF_SIZE 0x400 /* buffer size for strings */
|
||||||
#define MAX_LINE_LEN 0x20000 /* max file line length */
|
#define MAX_LINE_LEN 0x20000 /* max file line length */
|
||||||
|
|
||||||
/* data structure for region call limits */
|
/* data structure for fitler assignments */
|
||||||
|
|
||||||
typedef struct RFG_FilterCLimits_struct
|
typedef struct RFG_FilterAssigns_struct
|
||||||
{
|
{
|
||||||
int32_t climit; /* call limit */
|
int32_t climit; /* call limit */
|
||||||
uint32_t npattern; /* number of assigned pattern */
|
char* pattern; /* pattern */
|
||||||
char** pattern; /* array of assigned pattern */
|
} RFG_FilterAssigns;
|
||||||
} RFG_FilterCLimits;
|
|
||||||
|
|
||||||
struct RFG_Filter_struct
|
struct RFG_Filter_struct
|
||||||
{
|
{
|
||||||
char* deffile; /* name of filter definition file */
|
char* deffile; /* name of filter definition file */
|
||||||
int32_t default_call_limit; /* default call limit */
|
int32_t default_call_limit; /* default call limit */
|
||||||
|
|
||||||
uint32_t nclimits; /* number of call limit assignments */
|
uint32_t nassigns; /* number of filter assignments */
|
||||||
RFG_FilterCLimits* climits; /* array of call limit assignments */
|
RFG_FilterAssigns* assigns; /* array of filter assignments */
|
||||||
};
|
};
|
||||||
|
|
||||||
RFG_Filter* RFG_Filter_init()
|
RFG_Filter* RFG_Filter_init()
|
||||||
@ -46,8 +45,8 @@ RFG_Filter* RFG_Filter_init()
|
|||||||
ret->deffile = NULL;
|
ret->deffile = NULL;
|
||||||
ret->default_call_limit = -1;
|
ret->default_call_limit = -1;
|
||||||
|
|
||||||
ret->nclimits = 0;
|
ret->nassigns = 0;
|
||||||
ret->climits = NULL;
|
ret->assigns = NULL;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -55,7 +54,6 @@ RFG_Filter* RFG_Filter_init()
|
|||||||
int RFG_Filter_free( RFG_Filter* filter )
|
int RFG_Filter_free( RFG_Filter* filter )
|
||||||
{
|
{
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
uint32_t j;
|
|
||||||
|
|
||||||
if( !filter ) return 0;
|
if( !filter ) return 0;
|
||||||
|
|
||||||
@ -66,15 +64,10 @@ int RFG_Filter_free( RFG_Filter* filter )
|
|||||||
|
|
||||||
/* free array of call limit assignments */
|
/* free array of call limit assignments */
|
||||||
|
|
||||||
for( i = 0; i < filter->nclimits; i++ )
|
for( i = 0; i < filter->nassigns; i++ )
|
||||||
{
|
free( filter->assigns[i].pattern );
|
||||||
for( j = 0; j < filter->climits[i].npattern; j++ )
|
|
||||||
free( filter->climits[i].pattern[j] );
|
|
||||||
|
|
||||||
free( filter->climits[i].pattern );
|
free( filter->assigns );
|
||||||
}
|
|
||||||
|
|
||||||
free( filter->climits );
|
|
||||||
|
|
||||||
/* free self */
|
/* free self */
|
||||||
|
|
||||||
@ -228,7 +221,7 @@ int RFG_Filter_readDefFile( RFG_Filter* filter )
|
|||||||
/* add call limit assignment */
|
/* add call limit assignment */
|
||||||
|
|
||||||
if( strlen( pattern ) > 0 )
|
if( strlen( pattern ) > 0 )
|
||||||
RFG_Filter_addCLimit( filter, climit, pattern );
|
RFG_Filter_add( filter, pattern, climit );
|
||||||
|
|
||||||
} while( ( p = strtok( 0, ";" ) ) );
|
} while( ( p = strtok( 0, ";" ) ) );
|
||||||
|
|
||||||
@ -248,67 +241,26 @@ int RFG_Filter_readDefFile( RFG_Filter* filter )
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RFG_Filter_addCLimit( RFG_Filter* filter, int32_t climit,
|
int RFG_Filter_add( RFG_Filter* filter, const char* pattern,
|
||||||
const char* pattern )
|
int32_t climit )
|
||||||
{
|
{
|
||||||
uint32_t i;
|
|
||||||
RFG_FilterCLimits* entry = NULL;
|
|
||||||
|
|
||||||
if( !filter || !pattern ) return 0;
|
if( !filter || !pattern ) return 0;
|
||||||
|
|
||||||
/* search call limit assignment by call limit */
|
/* enlarge array of filter assignments */
|
||||||
|
|
||||||
for( i = 0; i < filter->nclimits; i++ )
|
filter->assigns =
|
||||||
{
|
(RFG_FilterAssigns*)realloc( filter->assigns,
|
||||||
if( filter->climits[i].climit == climit )
|
( filter->nassigns + 1 )
|
||||||
{
|
* sizeof( RFG_FilterAssigns ) );
|
||||||
entry = &(filter->climits[i]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* if no entry found, then allocate new call limit assignment entry */
|
if( filter->assigns == NULL )
|
||||||
|
|
||||||
if( !entry )
|
|
||||||
{
|
|
||||||
if( !filter->climits )
|
|
||||||
{
|
|
||||||
filter->climits =
|
|
||||||
( RFG_FilterCLimits* )malloc( sizeof( RFG_FilterCLimits ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
filter->climits =
|
|
||||||
(RFG_FilterCLimits* )realloc( filter->climits,
|
|
||||||
( filter->nclimits + 1 )
|
|
||||||
* sizeof( RFG_FilterCLimits ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( filter->climits == NULL )
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
entry = &(filter->climits[filter->nclimits++]);
|
/* add new filter assignment */
|
||||||
entry->climit = climit;
|
|
||||||
entry->npattern = 0;
|
|
||||||
entry->pattern = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* add pattern to call limit */
|
filter->assigns[filter->nassigns].climit = climit;
|
||||||
|
filter->assigns[filter->nassigns].pattern = strdup( pattern );
|
||||||
if( !entry->pattern )
|
filter->nassigns++;
|
||||||
{
|
|
||||||
entry->pattern = ( char** )malloc( sizeof( char * ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
entry->pattern = ( char** )realloc( entry->pattern,
|
|
||||||
( entry->npattern + 1 )
|
|
||||||
* sizeof( char * ) );
|
|
||||||
}
|
|
||||||
if( entry->pattern == NULL )
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
entry->pattern[entry->npattern++] = strdup( pattern );
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -317,26 +269,23 @@ int RFG_Filter_get( RFG_Filter* filter, const char* rname,
|
|||||||
int32_t* r_climit )
|
int32_t* r_climit )
|
||||||
{
|
{
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
uint32_t j;
|
|
||||||
|
|
||||||
if( !filter || !rname ) return 0;
|
if( !filter || !rname ) return 0;
|
||||||
|
|
||||||
/* search for matching pattern by region name */
|
/* search for matching pattern by region name */
|
||||||
|
|
||||||
for( i = 0; i < filter->nclimits; i++ )
|
for( i = 0; i < filter->nassigns; i++ )
|
||||||
{
|
{
|
||||||
for( j = 0; j < filter->climits[i].npattern; j++ )
|
if( fnmatch( filter->assigns[i].pattern, rname, 0 ) == 0 )
|
||||||
{
|
{
|
||||||
if( fnmatch( filter->climits[i].pattern[j], rname, 0 ) == 0 )
|
*r_climit = filter->assigns[i].climit;
|
||||||
{
|
break;
|
||||||
*r_climit = filter->climits[i].climit;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return default call limit, if no matching pattern found */
|
/* return default call limit, if no matching pattern found */
|
||||||
|
|
||||||
|
if( i == filter->nassigns )
|
||||||
*r_climit = filter->default_call_limit;
|
*r_climit = filter->default_call_limit;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -20,9 +20,9 @@ int RFG_Filter_setDefaultCallLimit( RFG_Filter* filter, int32_t limit );
|
|||||||
/* reads filter definition file */
|
/* reads filter definition file */
|
||||||
int RFG_Filter_readDefFile( RFG_Filter* filter );
|
int RFG_Filter_readDefFile( RFG_Filter* filter );
|
||||||
|
|
||||||
/* adds call limit assignment */
|
/* adds filter assignment */
|
||||||
int RFG_Filter_addCLimit( RFG_Filter* filter, int32_t climit,
|
int RFG_Filter_add( RFG_Filter* filter, const char* pattern,
|
||||||
const char* pattern );
|
int32_t climit );
|
||||||
|
|
||||||
/* gets call limit by region name */
|
/* gets call limit by region name */
|
||||||
int RFG_Filter_get( RFG_Filter* filter, const char* rname,
|
int RFG_Filter_get( RFG_Filter* filter, const char* rname,
|
||||||
|
Загрузка…
Ссылка в новой задаче
Block a user