ftest : debug bar_progress' variable dynamic&static alloc
This commit is contained in:
@@ -105,10 +105,16 @@ struct get_fds_arg{
|
|||||||
char * port ;/*service */
|
char * port ;/*service */
|
||||||
char * addrDistant;
|
char * addrDistant;
|
||||||
};
|
};
|
||||||
|
/*
|
||||||
void *y_get_fds_func(void *arg){
|
void *y_get_fds_func(void *arg){
|
||||||
struct get_fds_arg * argSock = (struct get_fds_arg*)arg;
|
struct get_fds_arg * argSock = (struct get_fds_arg*)arg;
|
||||||
struct pollfd *fds = argSock->fds;
|
struct pollfd *fds = argSock->fds;
|
||||||
|
char * port = argSock->port ;
|
||||||
|
char * addrDistant = argSock->addrDistant;
|
||||||
|
*/
|
||||||
|
|
||||||
|
void y_get_fds_func(struct pollfd * fds, char * port, char * addrDistant){
|
||||||
|
|
||||||
fds[v4].fd=-1; fds[v4].events = POLLIN;
|
fds[v4].fd=-1; fds[v4].events = POLLIN;
|
||||||
fds[v6].fd=-1; fds[v6].events = POLLIN;
|
fds[v6].fd=-1; fds[v6].events = POLLIN;
|
||||||
|
|
||||||
@@ -128,10 +134,11 @@ void *y_get_fds_func(void *arg){
|
|||||||
hints.ai_next = NULL;
|
hints.ai_next = NULL;
|
||||||
|
|
||||||
//status = getaddrinfo(NULL, argSock->port, &hints, &result);
|
//status = getaddrinfo(NULL, argSock->port, &hints, &result);
|
||||||
status = getaddrinfo(argSock->addrDistant, argSock->port, &hints, &result);
|
//status = getaddrinfo(argSock->addrDistant, argSock->port, &hints, &result);
|
||||||
|
status = getaddrinfo(addrDistant, port, &hints, &result);
|
||||||
if(status != 0){
|
if(status != 0){
|
||||||
fprintf(stderr, "getaddrinfo :%s\n", gai_strerror(status));
|
fprintf(stderr, "getaddrinfo :%s\n", gai_strerror(status));
|
||||||
return NULL;
|
return ;//NULL;
|
||||||
}
|
}
|
||||||
int af, optValueV6 = 1;
|
int af, optValueV6 = 1;
|
||||||
|
|
||||||
@@ -183,7 +190,7 @@ void *y_get_fds_func(void *arg){
|
|||||||
return NULL;
|
return NULL;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
return fds;
|
// return fds;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,13 +268,15 @@ void *y_pollSocketsFunc(void *arg){
|
|||||||
fprintf(stderr, " not enough allocatation for fds, we leave!");
|
fprintf(stderr, " not enough allocatation for fds, we leave!");
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct get_fds_arg argGET_addr, *arg_get;//=malloc(sizeof(struct get_fds_arg) );
|
// struct get_fds_arg argGET_addr, *arg_get;//=malloc(sizeof(struct get_fds_arg) );
|
||||||
arg_get = &argGET_addr;
|
// arg_get = &argGET_addr;
|
||||||
arg_get->fds = fds;
|
// arg_get->fds = fds;
|
||||||
arg_get->addrDistant = NULL;
|
// arg_get->addrDistant = NULL;
|
||||||
arg_get->port = argSock->port;
|
// arg_get->port = argSock->port;
|
||||||
|
// fds = (struct pollfd*) y_get_fds_func(arg_get);
|
||||||
|
|
||||||
fds = (struct pollfd*) y_get_fds_func(arg_get);
|
// fds = (struct pollfd*)
|
||||||
|
y_get_fds_func(fds, argSock->port, NULL);
|
||||||
|
|
||||||
if((fds[v4].fd==-1) || (fds[v6].fd==-1)){
|
if((fds[v4].fd==-1) || (fds[v6].fd==-1)){
|
||||||
fprintf(stderr, " v4 or v6 not listening, we leave!");
|
fprintf(stderr, " v4 or v6 not listening, we leave!");
|
||||||
|
|||||||
Binary file not shown.
@@ -68,6 +68,9 @@ char *default_timeunit="ms";
|
|||||||
char *default_savelog="log_all_tests";
|
char *default_savelog="log_all_tests";
|
||||||
char *default_bar_progress=" c";
|
char *default_bar_progress=" c";
|
||||||
|
|
||||||
|
bool bar_progress_has_to_be_freed = 0;
|
||||||
|
bool default_bar_progress_has_to_be_freed = 0;
|
||||||
|
|
||||||
//size_t width = 80;
|
//size_t width = 80;
|
||||||
|
|
||||||
char *colors_f[]={DEFAULT_K, GREEN_K, RED_K, YELLOW_K, BLUE_K, ""};
|
char *colors_f[]={DEFAULT_K, GREEN_K, RED_K, YELLOW_K, BLUE_K, ""};
|
||||||
@@ -272,16 +275,18 @@ void setup_variables_before_exec(){
|
|||||||
size_t len_bp = strlen(bar_progress);
|
size_t len_bp = strlen(bar_progress);
|
||||||
size_t len_db = strlen(default_bar_progress);
|
size_t len_db = strlen(default_bar_progress);
|
||||||
if( len_bp >= len_db ){
|
if( len_bp >= len_db ){
|
||||||
char tmp_bp[len_bp+1];
|
char *tmp_bp=malloc(len_bp+1);
|
||||||
strcpy(tmp_bp,bar_progress);
|
strcpy(tmp_bp,bar_progress);
|
||||||
tmp_bp[2]='u';
|
tmp_bp[2]='u';
|
||||||
bar_progress=tmp_bp;
|
bar_progress=tmp_bp;
|
||||||
|
bar_progress_has_to_be_freed = 1;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
char tmp_bp[len_bp+1];
|
char *tmp_bp=malloc(len_db+1);
|
||||||
strcpy(tmp_bp,default_bar_progress);
|
strcpy(tmp_bp,default_bar_progress);
|
||||||
tmp_bp[2]='u';
|
tmp_bp[2]='u';
|
||||||
default_bar_progress=tmp_bp;
|
default_bar_progress=tmp_bp;
|
||||||
|
default_bar_progress_has_to_be_freed = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -892,7 +897,7 @@ void bar_progress_test_(){
|
|||||||
struct func *tmp;
|
struct func *tmp;
|
||||||
size_t num_test=0;
|
size_t num_test=0;
|
||||||
|
|
||||||
do{
|
do{
|
||||||
tmp = current_fn;
|
tmp = current_fn;
|
||||||
//UNLOCK(mut_current_test);
|
//UNLOCK(mut_current_test);
|
||||||
if(tmp)
|
if(tmp)
|
||||||
@@ -1518,6 +1523,8 @@ void
|
|||||||
purge_tests()
|
purge_tests()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if(bar_progress_has_to_be_freed) free(bar_progress);
|
||||||
|
if(default_bar_progress_has_to_be_freed) free(default_bar_progress);
|
||||||
#if 1
|
#if 1
|
||||||
clear_all_func(&f_beging);
|
clear_all_func(&f_beging);
|
||||||
clear_all_falied_list(&failed_l);
|
clear_all_falied_list(&failed_l);
|
||||||
|
|||||||
Reference in New Issue
Block a user