From 760a3bb7c7a1c874e49af20de187819587c8b40c Mon Sep 17 00:00:00 2001 From: fanasina Date: Sat, 18 Oct 2025 10:55:24 +0200 Subject: [PATCH] y_socket: remove some debug printf --- list_t/src/list_t/list_t.h | 4 +- y_socket_t/src/y_socket_t/y_file_handler.c | 143 +++++++++++---------- y_socket_t/src/y_socket_t/y_node_t.c | 10 +- y_socket_t/src/y_socket_t/y_socket_t.c | 24 ++-- 4 files changed, 95 insertions(+), 86 deletions(-) diff --git a/list_t/src/list_t/list_t.h b/list_t/src/list_t/list_t.h index ffcc05c..35b4935 100644 --- a/list_t/src/list_t/list_t.h +++ b/list_t/src/list_t/list_t.h @@ -360,14 +360,14 @@ GENERATE_LIST_ALL(TYPE_PTR) }\ struct list_##type * search_first_occ_from_begin_in_list_##type(struct main_list_##type *var_list, type value, int (*funcCmp)(type, type)){\ pthread_mutex_lock(var_list->mut_list);\ - printf("debug: cur_index change to 0");\ + /*printf("debug: cur_index change to 0");*/\ var_list->current_list = var_list->begin_list;\ pthread_mutex_unlock(var_list->mut_list);\ return search_first_occ_with_mov_from_curr_in_list_##type(var_list, value, funcCmp, local_increment_list_##type);\ }\ struct list_##type * search_first_occ_from_end_in_list_##type(struct main_list_##type *var_list, type value, int (*funcCmp)(type, type)){\ pthread_mutex_lock(var_list->mut_list);\ - printf("debug: cur_index change to end");\ + /*printf("debug: cur_index change to end");*/\ var_list->current_list = var_list->end_list;\ pthread_mutex_unlock(var_list->mut_list);\ return search_first_occ_with_mov_from_curr_in_list_##type(var_list, value, funcCmp, local_decrement_list_##type);\ diff --git a/y_socket_t/src/y_socket_t/y_file_handler.c b/y_socket_t/src/y_socket_t/y_file_handler.c index b22a534..07ebbf2 100644 --- a/y_socket_t/src/y_socket_t/y_file_handler.c +++ b/y_socket_t/src/y_socket_t/y_file_handler.c @@ -83,7 +83,7 @@ int funcCmp_y_ptr_HEADER_T_fn_nameid_mask(y_ptr_HEADER_T h1, y_ptr_HEADER_T h2){ //int count_match = 0; struct main_list_TYPE_SIZE_T * m_index_not_match = create_var_list_TYPE_SIZE_T(); int ret = 0; - printf("debug: size1=%ld vs size2=%ld\n",m_h1_nameid->size, m_h2_nameid->size); + ///printf("debug: size1=%ld vs size2=%ld\n",m_h1_nameid->size, m_h2_nameid->size); if(m_h1_nameid->size != m_h2_nameid->size) { ret = -2; }else{ @@ -91,10 +91,10 @@ int funcCmp_y_ptr_HEADER_T_fn_nameid_mask(y_ptr_HEADER_T h1, y_ptr_HEADER_T h2){ if(l_h1_->index != m_h1_nameid->size - 2){ if(strcmp(l_h1_->value->buf, l_h2_->value->buf )==0){ //++count_match ; - printf("debug: match [%ld] ! %s == %s !", l_h1_->index, l_h1_->value->buf, l_h2_->value->buf); + ///printf("debug: match [%ld] ! %s == %s !", l_h1_->index, l_h1_->value->buf, l_h2_->value->buf); } else{ - printf("debug: NOT match [%ld] ! %s != %s !", l_h1_->index, l_h1_->value->buf, l_h2_->value->buf); + ///printf("debug: NOT match [%ld] ! %s != %s !", l_h1_->index, l_h1_->value->buf, l_h2_->value->buf); push_back_list_TYPE_SIZE_T(m_index_not_match, l_h1_->index); } } @@ -103,6 +103,8 @@ int funcCmp_y_ptr_HEADER_T_fn_nameid_mask(y_ptr_HEADER_T h1, y_ptr_HEADER_T h2){ if(m_index_not_match->size) { + //debug +#if 0 for(struct list_y_ptr_STRING *l_h1_ = m_h1_nameid->end_list, *l_h2_ = m_h2_nameid->end_list; l_h1_ && l_h2_; l_h1_ = l_h1_->preview, l_h2_=l_h2_->preview){ for(struct list_TYPE_SIZE_T * l_in = m_index_not_match->begin_list; l_in; l_in=l_in->next){ @@ -111,6 +113,7 @@ int funcCmp_y_ptr_HEADER_T_fn_nameid_mask(y_ptr_HEADER_T h1, y_ptr_HEADER_T h2){ } } } +#endif ret = -1; } @@ -120,7 +123,7 @@ int funcCmp_y_ptr_HEADER_T_fn_nameid_mask(y_ptr_HEADER_T h1, y_ptr_HEADER_T h2){ purge_ptr_type_list_y_ptr_STRING(m_h1_nameid); purge_ptr_type_list_y_ptr_STRING(m_h2_nameid); free_all_var_list_TYPE_SIZE_T(m_index_not_match); - printf("check_if_in_ok_header_l_ ret=%d, %s ns %s\n",ret,h1->nameid, h2->nameid); + ///printf("check_if_in_ok_header_l_ ret=%d, %s ns %s\n",ret,h1->nameid, h2->nameid); } return ret; } @@ -144,21 +147,21 @@ long y_append_to_ok_header_l_(struct main_list_y_ptr_HEADER_T *m_ok_head_l_t, ch struct list_y_ptr_HEADER_T * l_ocate_header = search_first_occ_from_end_in_list_y_ptr_HEADER_T(m_ok_head_l_t, current_header, funcCmp_y_ptr_HEADER_T); if(l_ocate_header){ free_y_ptr_HEADER_T(current_header); - printf("debug: already in m_ok_head_l_t"); + ///printf("debug: already in m_ok_head_l_t"); return -1; // already in list } else{ push_back_list_y_ptr_HEADER_T(m_ok_head_l_t, current_header); - printf("debug: push_back_list_y_ptr_HEADER_T when l_ocate_header == NULL, m_head_l_t->size=%ld\n",m_ok_head_l_t->size); + ///printf("debug: push_back_list_y_ptr_HEADER_T when l_ocate_header == NULL, m_head_l_t->size=%ld\n",m_ok_head_l_t->size); return m_ok_head_l_t->size; } } #define TEST_DUPLICATE_SEQ()\ if(temp_curr->value->seq == cnt->seq){\ - printf("debug: index_nearest_seq=%ld: seq equal: doublon problem ? seq:%ld appuyer sur une touche\n", index_nearest_seq, cnt->seq);\ - free_y_ptr_MSG_CONTENT_T(cnt); \ + /*printf("debug: index_nearest_seq=%ld: seq equal: doublon problem ? seq:%ld appuyer sur une touche\n", index_nearest_seq, cnt->seq);\ + */free_y_ptr_MSG_CONTENT_T(cnt); \ /*getchar();*/\ return -2;\ } @@ -167,7 +170,7 @@ long y_append_content_to_header_l(struct main_list_y_ptr_HEADER_T *m_head_l_t, y y_ptr_HEADER_T current_header = create_y_ptr_HEADER_T(cnt->nameid, cnt->size_nameid, cnt->cmd_t); struct list_y_ptr_HEADER_T * l_ocate_header = search_first_occ_from_end_in_list_y_ptr_HEADER_T(m_head_l_t, current_header, funcCmp_y_ptr_HEADER_T); - printf("debug: search done, nameid:%s, #%ld\n",cnt->nameid, cnt->size_nameid); + ///printf("debug: search done, nameid:%s, #%ld\n",cnt->nameid, cnt->size_nameid); if(l_ocate_header){ free_y_ptr_HEADER_T(current_header); pthread_mutex_t *mut_m_content_l = l_ocate_header->value->m_content_l->mut_list; @@ -178,9 +181,9 @@ long y_append_content_to_header_l(struct main_list_y_ptr_HEADER_T *m_head_l_t, y if(begin_cnt == NULL){ pthread_mutex_unlock(mut_m_content_l); - printf("debug: current_cnt==NULL, size_ m_content_l=%ld cnt->seq=%ld, push_back_list_y_ptr_MSG_CONTENT_T\n", l_ocate_header->value->m_content_l->size, cnt->seq); + ///printf("debug: current_cnt==NULL, size_ m_content_l=%ld cnt->seq=%ld, push_back_list_y_ptr_MSG_CONTENT_T\n", l_ocate_header->value->m_content_l->size, cnt->seq); push_back_list_y_ptr_MSG_CONTENT_T(l_ocate_header->value->m_content_l, cnt); - printf("debug: after current_cnt==NULL, size_ m_content_l=%ld cnt->seq=%ld, push_back_list_y_ptr_MSG_CONTENT_T\n", l_ocate_header->value->m_content_l->size, cnt->seq); + ///printf("debug: after current_cnt==NULL, size_ m_content_l=%ld cnt->seq=%ld, push_back_list_y_ptr_MSG_CONTENT_T\n", l_ocate_header->value->m_content_l->size, cnt->seq); return 0; } long last_seq = end_cnt->value->seq; @@ -192,11 +195,11 @@ long y_append_content_to_header_l(struct main_list_y_ptr_HEADER_T *m_head_l_t, y struct list_y_ptr_MSG_CONTENT_T *temp_curr = NULL; - long from_current_seq = current_cnt->value->seq - cnt->seq; \ - size_t abs_cur_diff_seq = abs(from_current_seq); \ - size_t array_diff_seq[3] = {cnt->seq - begin_cnt->value->seq, abs_cur_diff_seq , end_cnt->value->seq - cnt->seq}; \ - size_t index_nearest_seq = ARG_MIN_ARRAY_TYPE_SIZE_T(array_diff_seq, 3);\ - if(index_nearest_seq == 0){\ + long from_current_seq = current_cnt->value->seq - cnt->seq; + size_t abs_cur_diff_seq = abs(from_current_seq); + size_t array_diff_seq[3] = {cnt->seq - begin_cnt->value->seq, abs_cur_diff_seq , end_cnt->value->seq - cnt->seq}; + size_t index_nearest_seq = ARG_MIN_ARRAY_TYPE_SIZE_T(array_diff_seq, 3); + if(index_nearest_seq == 0){ for(temp_curr = begin_cnt ;temp_curr && (temp_curr->value->seq < cnt->seq); temp_curr = temp_curr->next){} if(temp_curr){ l_ocate_header->value->m_content_l->current_list = temp_curr; @@ -208,7 +211,7 @@ long y_append_content_to_header_l(struct main_list_y_ptr_HEADER_T *m_head_l_t, y push_back_list_y_ptr_MSG_CONTENT_T(l_ocate_header->value->m_content_l, cnt); return 0; } - }\ + } else if(index_nearest_seq == 2){ for(temp_curr = end_cnt; temp_curr && temp_curr->value->seq > cnt->seq; temp_curr = temp_curr->preview) {} @@ -278,7 +281,7 @@ long y_append_content_to_header_l(struct main_list_y_ptr_HEADER_T *m_head_l_t, y else{ push_back_list_y_ptr_MSG_CONTENT_T(current_header->m_content_l, cnt); push_back_list_y_ptr_HEADER_T(m_head_l_t, current_header); - printf("debug: push_back_list_y_ptr_HEADER_T when l_ocate_header == NULL, m_head_l_t->size=%ld\n",m_head_l_t->size); + ///printf("debug: push_back_list_y_ptr_HEADER_T when l_ocate_header == NULL, m_head_l_t->size=%ld\n",m_head_l_t->size); return 0; } } @@ -289,14 +292,14 @@ long y_append_content_to_header_l_from_end(struct main_list_y_ptr_HEADER_T *m_he y_ptr_HEADER_T current_header = create_y_ptr_HEADER_T(cnt->nameid, cnt->size_nameid, cnt->cmd_t); struct list_y_ptr_HEADER_T * l_ocate_header = search_first_occ_from_begin_in_list_y_ptr_HEADER_T(m_head_l_t, current_header, funcCmp_y_ptr_HEADER_T); - printf("debug: search done, nameid:%s, #%ld\n",cnt->nameid, cnt->size_nameid); + ///printf("debug: search done, nameid:%s, #%ld\n",cnt->nameid, cnt->size_nameid); if(l_ocate_header){ free_y_ptr_HEADER_T(current_header); struct list_y_ptr_MSG_CONTENT_T * current_cnt = l_ocate_header->value->m_content_l->end_list; if(current_cnt == NULL){ - printf("debug: current_cnt==NULL, size_ m_content_l=%ld cnt->seq=%ld, push_back_list_y_ptr_MSG_CONTENT_T\n", l_ocate_header->value->m_content_l->size, cnt->seq); + ///printf("debug: current_cnt==NULL, size_ m_content_l=%ld cnt->seq=%ld, push_back_list_y_ptr_MSG_CONTENT_T\n", l_ocate_header->value->m_content_l->size, cnt->seq); push_back_list_y_ptr_MSG_CONTENT_T(l_ocate_header->value->m_content_l, cnt); - printf("debug: after current_cnt==NULL, size_ m_content_l=%ld cnt->seq=%ld, push_back_list_y_ptr_MSG_CONTENT_T\n", l_ocate_header->value->m_content_l->size, cnt->seq); + ///printf("debug: after current_cnt==NULL, size_ m_content_l=%ld cnt->seq=%ld, push_back_list_y_ptr_MSG_CONTENT_T\n", l_ocate_header->value->m_content_l->size, cnt->seq); return 0; } long last_seq = current_cnt->value->seq + 1; @@ -306,11 +309,11 @@ long y_append_content_to_header_l_from_end(struct main_list_y_ptr_HEADER_T *m_he } // cnt->seq < last_seq while(current_cnt){ - printf("debug: last_seq: %ld, cnt->seq=%ld, current_cnt->value->seq:%ld\n", last_seq, cnt->seq,current_cnt->value->seq); - if(cnt->seq == current_cnt->value->seq){ - printf("debug: equal last_seq: %ld, cnt->seq=%ld, current_cnt->value->seq:%ld\n", last_seq, cnt->seq,current_cnt->value->seq); + ///printf("debug: last_seq: %ld, cnt->seq=%ld, current_cnt->value->seq:%ld\n", last_seq, cnt->seq,current_cnt->value->seq); + ///if(cnt->seq == current_cnt->value->seq){ + ///printf("debug: equal last_seq: %ld, cnt->seq=%ld, current_cnt->value->seq:%ld\n", last_seq, cnt->seq,current_cnt->value->seq); //return -2; - } + ///} if(cnt->seq < last_seq && cnt->seq > current_cnt->value->seq){ /*if(cnt->seq > last_seq && cnt->seq < current_cnt->value->seq)*/ return insert_into_list_y_ptr_MSG_CONTENT_T(l_ocate_header->value->m_content_l, current_cnt->index + 1, cnt); @@ -322,14 +325,14 @@ long y_append_content_to_header_l_from_end(struct main_list_y_ptr_HEADER_T *m_he current_cnt = current_cnt->preview; } - printf("debug: some thing wrong here! last_seq: %ld, cnt->seq=%ld\n", last_seq, cnt->seq); + ///printf("debug: some thing wrong here! last_seq: %ld, cnt->seq=%ld\n", last_seq, cnt->seq); return -1; } else{ push_back_list_y_ptr_MSG_CONTENT_T(current_header->m_content_l, cnt); push_back_list_y_ptr_HEADER_T(m_head_l_t, current_header); - printf("debug: push_back_list_y_ptr_HEADER_T when l_ocate_header == NULL, m_head_l_t->size=%ld\n",m_head_l_t->size); + ///printf("debug: push_back_list_y_ptr_HEADER_T when l_ocate_header == NULL, m_head_l_t->size=%ld\n",m_head_l_t->size); return 0; } } @@ -339,23 +342,23 @@ long y_append_content_to_header_l_from_begin(struct main_list_y_ptr_HEADER_T *m_ y_ptr_HEADER_T current_header = create_y_ptr_HEADER_T(cnt->nameid, cnt->size_nameid, cnt->cmd_t); struct list_y_ptr_HEADER_T * l_ocate_header = search_first_occ_from_begin_in_list_y_ptr_HEADER_T(m_head_l_t, current_header, funcCmp_y_ptr_HEADER_T); - printf("debug: search done, nameid:%s, #%ld\n",cnt->nameid, cnt->size_nameid); + ///printf("debug: search done, nameid:%s, #%ld\n",cnt->nameid, cnt->size_nameid); if(l_ocate_header){ free_y_ptr_HEADER_T(current_header); struct list_y_ptr_MSG_CONTENT_T * current_cnt = l_ocate_header->value->m_content_l->begin_list; if(current_cnt == NULL){ - printf("debug: current_cnt==NULL, size_ m_content_l=%ld cnt->seq=%ld, push_back_list_y_ptr_MSG_CONTENT_T\n", l_ocate_header->value->m_content_l->size, cnt->seq); + ///printf("debug: current_cnt==NULL, size_ m_content_l=%ld cnt->seq=%ld, push_back_list_y_ptr_MSG_CONTENT_T\n", l_ocate_header->value->m_content_l->size, cnt->seq); push_back_list_y_ptr_MSG_CONTENT_T(l_ocate_header->value->m_content_l, cnt); - printf("debug: after current_cnt==NULL, size_ m_content_l=%ld cnt->seq=%ld, push_back_list_y_ptr_MSG_CONTENT_T\n", l_ocate_header->value->m_content_l->size, cnt->seq); + ///printf("debug: after current_cnt==NULL, size_ m_content_l=%ld cnt->seq=%ld, push_back_list_y_ptr_MSG_CONTENT_T\n", l_ocate_header->value->m_content_l->size, cnt->seq); return 0; } long last_seq = -1; while(current_cnt){ - printf("debug: last_seq: %ld, cnt->seq=%ld, current_cnt->value->seq:%ld\n", last_seq, cnt->seq,current_cnt->value->seq); - if(cnt->seq == current_cnt->value->seq){ + ///printf("debug: last_seq: %ld, cnt->seq=%ld, current_cnt->value->seq:%ld\n", last_seq, cnt->seq,current_cnt->value->seq); + /*if(cnt->seq == current_cnt->value->seq){ printf("debug: equal last_seq: %ld, cnt->seq=%ld, current_cnt->value->seq:%ld\n", last_seq, cnt->seq,current_cnt->value->seq); //return -2; - } + }*/ if(cnt->seq > last_seq && cnt->seq < current_cnt->value->seq){ return insert_into_list_y_ptr_MSG_CONTENT_T(l_ocate_header->value->m_content_l, current_cnt->index, cnt); }else if(current_cnt->next==NULL){ @@ -366,14 +369,14 @@ long y_append_content_to_header_l_from_begin(struct main_list_y_ptr_HEADER_T *m_ current_cnt = current_cnt->next; } - printf("debug: some thing wrong here! last_seq: %ld, cnt->seq=%ld\n", last_seq, cnt->seq); + ///printf("debug: some thing wrong here! last_seq: %ld, cnt->seq=%ld\n", last_seq, cnt->seq); return -1; } else{ push_back_list_y_ptr_MSG_CONTENT_T(current_header->m_content_l, cnt); push_back_list_y_ptr_HEADER_T(m_head_l_t, current_header); - printf("debug: push_back_list_y_ptr_HEADER_T when l_ocate_header == NULL, m_head_l_t->size=%ld\n",m_head_l_t->size); + ///printf("debug: push_back_list_y_ptr_HEADER_T when l_ocate_header == NULL, m_head_l_t->size=%ld\n",m_head_l_t->size); return 0; } } @@ -381,29 +384,29 @@ long y_append_content_to_header_l_from_begin(struct main_list_y_ptr_HEADER_T *m_ struct list_y_ptr_HEADER_T * check_if_all_contents_done_from_headers(struct main_list_y_ptr_HEADER_T *m_head_l_t, y_ptr_MSG_CONTENT_T cnt){ y_ptr_HEADER_T current_header = create_y_ptr_HEADER_T(cnt->nameid, cnt->size_nameid, cnt->cmd_t); - printf("debug: check_if_all_contents_done_from_headers, begin search\n"); + ///printf("debug: check_if_all_contents_done_from_headers, begin search\n"); struct list_y_ptr_HEADER_T * l_ocate_header = search_first_occ_from_begin_in_list_y_ptr_HEADER_T (m_head_l_t, current_header, funcCmp_y_ptr_HEADER_T); - printf("debug: check_if_all_contents_done_from_headers, search done\n"); + ///printf("debug: check_if_all_contents_done_from_headers, search done\n"); free_y_ptr_HEADER_T(current_header); if(l_ocate_header){ - printf("debug: check_if_all_contents_done_from_headers, l_ocate_header->index=%ld\n",l_ocate_header->index); + ///printf("debug: check_if_all_contents_done_from_headers, l_ocate_header->index=%ld\n",l_ocate_header->index); if(l_ocate_header->value->m_content_l){ - struct list_y_ptr_MSG_CONTENT_T *end_list = l_ocate_header->value->m_content_l->end_list; - printf("debug: check_if_all_contents_done_from_headers, l_ocate_header->m_content_l->size=%ld,\n",l_ocate_header->value->m_content_l->size); - if(end_list){ - printf("debug: check_if_all_contents_done_from_headers, end->eof=%d, end->seq=%ld, end->index = %ld\n",end_list->value->eof, end_list->value->seq, end_list->index); - // check if all contents are done! - if(end_list->value->eof && end_list->value->seq == end_list->index){ - return l_ocate_header; - } - }else{ - printf("debug: check_if_all_contents_done_from_headers, end_list==NULL\n"); - - } - }else{ + struct list_y_ptr_MSG_CONTENT_T *end_list = l_ocate_header->value->m_content_l->end_list; + ///printf("debug: check_if_all_contents_done_from_headers, l_ocate_header->m_content_l->size=%ld,\n",l_ocate_header->value->m_content_l->size); + if(end_list){ + ///printf("debug: check_if_all_contents_done_from_headers, end->eof=%d, end->seq=%ld, end->index = %ld\n",end_list->value->eof, end_list->value->seq, end_list->index); + // check if all contents are done! + if(end_list->value->eof && end_list->value->seq == end_list->index){ + return l_ocate_header; + } + }/*else{ + printf("debug: check_if_all_contents_done_from_headers, end_list==NULL\n"); + + }*/ + }/*else{ printf("debug: check_if_all_contents_done_from_headers, l_ocate_header->value->m_content_l==NULL\n"); - } + }*/ } return NULL; @@ -428,12 +431,12 @@ int remove_content_from_headers(struct main_list_y_ptr_HEADER_T *m_head_l_t, y_p return 0; } else{ - printf("some thing wrong here: EOF:%d seq_end:%ld, size m_content_l :%ld\n",end_list->value->eof, end_list->value->seq, l_ocate_header->value->m_content_l->size); + ///printf("some thing wrong here: EOF:%d seq_end:%ld, size m_content_l :%ld\n",end_list->value->eof, end_list->value->seq, l_ocate_header->value->m_content_l->size); return 1; } } else{ - printf("\n%s is not in header list\n",cnt->nameid); + ///printf("\n%s is not in header list\n",cnt->nameid); return -1; } } @@ -577,9 +580,9 @@ for(int tour_i=0;(tour_i<4) && (check_if_in_ok_header_l_(argS->m_ok_head_l_t, na retread + len_local_header_ ){ fprintf(stderr, "Error sending response to %s\n",tempAddr); - }else{ + }/*else{ printf("debug: sending response to < %s > seq=[%ld] ",tempAddr,seq); - } + }*/ ++seq; len_local_header_ = sprintf(buf_send, "{ \"cmd\" : \"post file %s\", \"seq\" : %ld , \"tm\" : \"%ld\" }",filename, seq, timeid); @@ -598,7 +601,7 @@ for(int tour_i=0;(tour_i<4) && (check_if_in_ok_header_l_(argS->m_ok_head_l_t, na } close(fd_file); - printf("debug: fd=%d closed: filename=%s, for %s\n",fd_file,filename, tempAddr); + ///printf("debug: fd=%d closed: filename=%s, for %s\n",fd_file,filename, tempAddr); size_t delay = 4000000; printf("debug: wait %ld before checking, in tour:%d\n",delay, tour_i); @@ -661,11 +664,11 @@ void* y_send_buf_for_all_(void* arg){ len_buf_send ){ fprintf(stderr, "Error sending %s to %s\n", tempAddr, buf_send); - }else{ + }/*else{ printf("debug: sending [%s] -> < %s >",buf_send,tempAddr); - } + }*/ - printf("debug: for index = %ld\n",local_list_current->index); + ///printf("debug: for index = %ld\n",local_list_current->index); } @@ -794,13 +797,13 @@ void receve_from_node(struct pollfd *fds, struct main_list_y_ptr_HEADER_T *m_hea if(js_seq_v){ if(js_seq_v->type.object.value->code_type == jstype_number){ size_t seq_local = (long)(js_seq_v->type.object.value->type.number); - printf("debug: \n*********seq_local=%ld ***\n\n",seq_local); + ///printf("debug: \n*********seq_local=%ld ***\n\n",seq_local); struct js_value *js_eof_v = get_js_value_of_key("EOF", js_header_v ); if(js_eof_v){ // size_m_str = seq_local; eof=1; - printf("debug: \n****************************end of file ***\n\n"); + ///printf("debug: \n****************************end of file ***\n\n"); //printf("debug: \n****************************end of file ***\n%s\n**********************************\n",buf_loc); } @@ -817,7 +820,7 @@ void receve_from_node(struct pollfd *fds, struct main_list_y_ptr_HEADER_T *m_hea size_nameid = sprintf(nameid, "%s_%s_%s_%s",name_f /*filename*/, srcAddr, value_of_(js_dst_v)->type.string, timeid/*value_of_(js_tm_v)->type.string*/); #endif size_nameid = sprintf(nameid, "%s_%s_%s",name_f, srcAddr, /*value_of_(js_dst_v)->type.string,*/ value_of_(js_tm_v)->type.string); - printf("debug: nameid = %s\n", nameid); + ///printf("debug: nameid = %s\n", nameid); //int intTimeid = atoi(timeid); @@ -839,7 +842,7 @@ void receve_from_node(struct pollfd *fds, struct main_list_y_ptr_HEADER_T *m_hea while(tmpCnt_l){ write(fd_file, tmpCnt_l->value->content, tmpCnt_l->value->size_content); - printf("debug: nameid:%s seq = %ld eof %d\n\n%s\n",tmpCnt_l->value->nameid, tmpCnt_l->value->seq, tmpCnt_l->value->eof, tmpCnt_l->value->content); + ///printf("debug: nameid:%s seq = %ld eof %d\n\n%s\n",tmpCnt_l->value->nameid, tmpCnt_l->value->seq, tmpCnt_l->value->eof, tmpCnt_l->value->content); tmpCnt_l=tmpCnt_l->next; } close(fd_file); @@ -865,24 +868,24 @@ void receve_from_node(struct pollfd *fds, struct main_list_y_ptr_HEADER_T *m_hea */ } - }else{ + }/*else{ printf("debug: tm missing!"); - } + }*/ /*} else{ printf("debug: dst missing!"); }*/ - } + }/* else{ printf("debug: \n SSSSSSSSSSSSSSSEEEEEEEEEEEEEEQQQQQQQQQQQQQ type:%d \n",js_seq_v->type.object.value->code_type); - } + }*/ - }else{ + }/*else{ printf("debug: \n NNNNNNNNNNNNNNNNOOOOOOOOOOOOOSSSSSSSSSSSSSSSEEEEEEEEEEEEEEQQQQQQQQQQQQQ :type header : %d \n",js_header_v->code_type); - } + }*/ }else{ printf("debug: \n NO CMD :type header : %d \n",js_header_v->code_type); diff --git a/y_socket_t/src/y_socket_t/y_node_t.c b/y_socket_t/src/y_socket_t/y_node_t.c index 021fa4b..9df0ea6 100644 --- a/y_socket_t/src/y_socket_t/y_node_t.c +++ b/y_socket_t/src/y_socket_t/y_node_t.c @@ -21,7 +21,7 @@ void init_len_list_y_NODE_T(struct main_list_y_NODE_T *listNodes){ } int y_NODE_T_cmp(y_NODE_T nodeA, y_NODE_T nodeB){ -#if 1 +#if 0 char addrA[65]; char addrB[65]; set_addr_str_from_node(addrA, nodeA); @@ -34,7 +34,7 @@ int y_NODE_T_cmp(y_NODE_T nodeA, y_NODE_T nodeB){ //ret = nodeA.addr_len - nodeB.addr_len; //if(ret == 0){ - printf("debug: ++++++++++++ lenA=%d, lenB=%d\n", nodeA.addr_len , nodeB.addr_len); + ///printf("debug: ++++++++++++ lenA=%d, lenB=%d\n", nodeA.addr_len , nodeB.addr_len); ret = nodeA.addr.ss_family - nodeB.addr.ss_family; if(ret == 0){ if(nodeA.addr.ss_family == AF_INET){ @@ -208,7 +208,7 @@ void* update_nodes(void* arg) } } push_back_list_y_NODE_T(nodes, node); - printf("debug: // /// // // update_nodes local_addr=%d\n",node.local_addr ); + ///printf("debug: // /// // // update_nodes local_addr=%d\n",node.local_addr ); } if(if_addr) freeifaddrs(if_addr); @@ -234,7 +234,7 @@ size_t set_addr_str_from_node(char *tempAddr, y_NODE_T node) { } size_t ret_len = strlen(tempAddr); - printf("debug: c_af=%d, ret_len=%ld, addr=%s\n",c_af, ret_len,tempAddr); + ///printf("debug: c_af=%d, ret_len=%ld, addr=%s\n",c_af, ret_len,tempAddr); return ret_len; } @@ -255,7 +255,7 @@ int export_nodes_to_file(char * file_nodes_name, struct main_list_y_NODE_T *node buffer_addr[len_addr++]='\n'; buffer_addr[len_addr]='\0'; write(fd_file, buffer_addr, len_addr); - printf("debug: [#%d] buffer_addr=|%s|[index:%ld]\n",len_addr,buffer_addr,tmp_nd->index); + ///printf("debug: [#%d] buffer_addr=|%s|[index:%ld]\n",len_addr,buffer_addr,tmp_nd->index); tmp_nd=tmp_nd->next; memset(buffer_addr,0,65); } diff --git a/y_socket_t/src/y_socket_t/y_socket_t.c b/y_socket_t/src/y_socket_t/y_socket_t.c index 3b20c4b..c03c642 100644 --- a/y_socket_t/src/y_socket_t/y_socket_t.c +++ b/y_socket_t/src/y_socket_t/y_socket_t.c @@ -138,7 +138,10 @@ void y_socket_get_fds(struct pollfd * fds, char * port, char * addrDistant){ if(bind(fds[af].fd, rp->ai_addr, rp->ai_addrlen)==-1){ close(fds[af].fd); fds[af].fd=-1; - }else{ + } +///debug print addr local : don't work really +#if 0 + else{ char tempAddr[BUF_SIZE]={0}; if(af_array[af]==AF_INET){ if(NULL == inet_ntop(AF_INET, @@ -155,6 +158,8 @@ void y_socket_get_fds(struct pollfd * fds, char * port, char * addrDistant){ } printf("\n\ndebug: ADDR_LOCAL v%d:%s\n\n", 2*af+4,tempAddr); } +#endif + #if 0 int flags = fcntl(fds[af].fd, F_GETFL); flags |= O_NONBLOCK; @@ -202,6 +207,7 @@ void* y_socket_handler_(void *arg){ struct js_value *js_cmd = get_js_value_of_key("cmd", js_header ); if(js_cmd && js_cmd->type.object.value->code_type == jstype_string){ /** */ + /* struct js_value *js_seq = get_js_value_of_key("seq", js_header ); if(js_seq){ size_t seq_local = (long)(js_seq->type.object.value->type.number); @@ -209,7 +215,7 @@ void* y_socket_handler_(void *arg){ }else{ printf("debug: \n HANDLER header no seq\n"); - } + }*/ /* */ char * buf = js_cmd->type.object.value->type.string; size_t len_buf=strlen(buf); @@ -481,7 +487,7 @@ void *y_socket_poll_fds(void *arg){ /// } if(check_y_socket_go_on(argSock) && m_str){ - printf("debug: call handle_buf_socket_rec\n"); + ///printf("debug: call handle_buf_socket_rec\n"); handle_buf_socket_rec(m_ok_head_l_t,m_head_l_t, /*m_var,*/ m_str, node, workers, argx, list_arg, arg); m_str=NULL; @@ -510,7 +516,7 @@ void *y_socket_poll_fds(void *arg){ cmd[index_str++]=buf[index_buf]; } cmd[index_str]='\0'; - printf("debug : index_str= %d; cmd=[%s]\n",index_str, cmd); + ///printf("debug : index_str= %d; cmd=[%s]\n",index_str, cmd); index_str=0; while((index_buf < buf_len) && (buf[index_buf]==' ')){++index_buf;} @@ -525,12 +531,12 @@ void *y_socket_poll_fds(void *arg){ msg_buf[index_str++]=buf[index_buf]; msg_buf[index_str++]='\0';*/ - printf("debug : index_str=%d, dst_addr=[%s]\n", index_str, dst_addr); + ///printf("debug : index_str=%d, dst_addr=[%s]\n", index_str, dst_addr); #endif if(/*check_y_socket_go_on(argSock) &&*/ strncmp(cmd, "sendto", 6)==0){ - printf("debug : sendto match, dst_addr=[%s]\n", dst_addr); + ///printf("debug : sendto match, dst_addr=[%s]\n", dst_addr); if(strcmp(dst_addr, "all" ) == 0){ struct arg_send_file *argS = malloc(sizeof(struct arg_send_file)); argS->fds=fds; @@ -553,20 +559,20 @@ void *y_socket_poll_fds(void *arg){ } else if(set_addr_y_NODE_T_from_str_addr(&node, dst_addr)){ - printf("debug : set_addr_y_NODE_T done\n"); + ///printf("debug : set_addr_y_NODE_T done\n"); set_port_y_NODE_T_from_str_port(&node, argSock->port); update_nodes(node, argSock->nodes); af=(node.addr.ss_family == AF_INET6); - printf("debug : af = AF_INET=%d, af = AF_INET6=%d, vs af=[%d]\n",AF_INET, AF_INET6, af); + ///printf("debug : af = AF_INET=%d, af = AF_INET6=%d, vs af=[%d]\n",AF_INET, AF_INET6, af); //node.addr_len = sizeof(struct sockaddr_storage); //node.addr_len = sizeof(node.addr); if(sendto(fds[af].fd, buf+index_buf , buf_len-index_buf, 0, (struct sockaddr*)(&(node.addr)), node.addr_len ) == -1){ - printf("message erreur sendto : %s, error :%d\n\n",buf,errno); + fprintf(stderr,"message erreur sendto : %s, error :%d\n\n",buf,errno); perror("sendto:"); close(fds[af].fd); return NULL;