Commit 8c32ec5c authored by yangjian's avatar yangjian

Comment logger , update amf

parent da01d740
......@@ -92,6 +92,7 @@ void amf_app::allRegistredModulesInit(const amf_modules& modules) {
void amf_app_task(void*) {
const task_id_t task_id = TASK_AMF_APP;
itti_inst->notify_task_ready(task_id);
// set_cpu(1);
do {
std::shared_ptr<itti_msg> shared_msg = itti_inst->receive_msg(task_id);
auto* msg = shared_msg.get();
......
......@@ -96,6 +96,7 @@ void amf_n1_task(void *);
void amf_n1_task(void *) {
const task_id_t task_id = TASK_AMF_N1;
itti_inst->notify_task_ready(task_id);
// set_cpu(2);
do {
std::shared_ptr<itti_msg> shared_msg = itti_inst->receive_msg(task_id);
auto *msg = shared_msg.get();
......@@ -1346,10 +1347,21 @@ void amf_n1::curl_http_client(std::string remoteUri, std::string Method,
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, msgBody.length());
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body_data);
}
// //*****************************************************************
// struct timeval tv1;
// struct timezone tz1;
// gettimeofday(&tv1,&tz1);
// long time_start = tv1.tv_sec*1000000 +tv1.tv_usec;
// std::cout << "*************** time["<< time_start <<"] amf_n1 http curl_easy_perform start ***********"<<std::endl;
// //#################################################################
res = curl_easy_perform(curl);
// //******************************************************************
// gettimeofday(&tv1,&tz1);
// long time_end = tv1.tv_sec*1000000 +tv1.tv_usec;
// std::cout << "*************** time["<< time_end <<"] amf_n1 http curl_easy_perform end ***********"<<std::endl;
// //###################################################################
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode);
// get the response
std::string response = *httpData.get();
std::string json_data_response = "";
......
......@@ -101,6 +101,7 @@ void amf_n11_task(void*);
void amf_n11_task(void*) {
const task_id_t task_id = TASK_AMF_N11;
itti_inst->notify_task_ready(task_id);
// set_cpu(4);
do {
std::shared_ptr<itti_msg> shared_msg = itti_inst->receive_msg(task_id);
auto* msg = shared_msg.get();
......@@ -554,7 +555,16 @@ void amf_n11::curl_http_client(
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, body.length());
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body_data);
// struct timeval tv1;
// struct timezone tz1;
// gettimeofday(&tv1,&tz1);
// long time_start = tv1.tv_sec*1000000 +tv1.tv_usec;
// std::cout << "*************** time["<< time_start <<"] amf_n11 http curl_easy_perform start ***********"<<std::endl;
res = curl_easy_perform(curl);
// gettimeofday(&tv1,&tz1);
// long time_end = tv1.tv_sec*1000000 +tv1.tv_usec;
// std::cout << "*************** time["<< time_end <<"] amf_n11 http curl_easy_perform end ***********"<<std::endl;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode);
// get cause from the response
......
......@@ -83,6 +83,7 @@ void amf_n2_task(void*);
void amf_n2_task(void* args_p) {
const task_id_t task_id = TASK_AMF_N2;
itti_inst->notify_task_ready(task_id);
// set_cpu(3);
do {
std::shared_ptr<itti_msg> shared_msg = itti_inst->receive_msg(task_id);
auto* msg = shared_msg.get();
......
......@@ -276,6 +276,8 @@ std::shared_ptr<itti_msg> itti_mw::receive_msg(task_id_t task_id) {
std::shared_ptr<itti_msg> msg =
itti_task_ctxts[task_id]->msg_queue.front();
itti_task_ctxts[task_id]->msg_queue.pop();
// std::cout << "*************** task_id ("<< task_id << ") queue_num = " << itti_task_ctxts[task_id]->msg_queue.size()<<"***********"<<std::endl;
return msg;
}
}
......
......@@ -243,7 +243,9 @@ asn_dec_rval_t NativeEnumerated_decode_aper(
}
ASN_DEBUG("Decoding %s as NativeEnumerated", td->name);
#if TEST0515_IS_ON
printf("test0515 Decoding %s as NativeEnumerated\n", td->name);
#endif
if (ct->flags & APC_EXTENSIBLE) {
int inext = per_get_few_bits(pd, 1);
......
......@@ -321,7 +321,9 @@ asn_dec_rval_t NativeInteger_decode_aper(
(void) opt_codec_ctx;
ASN_DEBUG("Decoding NativeInteger %s (APER)", td->name);
#if TEST0515_IS_ON
printf("test0515 Decoding NativeInteger %s (APER)\n", td->name);
#endif
if (!native) {
native = (long*) (*sptr = CALLOC(1, sizeof(*native)));
......
......@@ -1033,9 +1033,11 @@ asn_dec_rval_t CHOICE_decode_aper(
if (value < 0) ASN__DECODE_STARVED;
ASN_DEBUG(
"CHOICE %s got index %d in range %d", td->name, value, ct->range_bits);
#if TEST0515_IS_ON
printf(
"test0515 CHOICE %s got index %d in range %d\n", td->name, value,
ct->range_bits);
#endif
if (value > ct->upper_bound) ASN__DECODE_FAILED;
} else {
if (specs->ext_start == -1) ASN__DECODE_FAILED;
......@@ -1050,7 +1052,9 @@ asn_dec_rval_t CHOICE_decode_aper(
/* Set presence to be able to free it later */
_set_present_idx(st, specs->pres_offset, specs->pres_size, value + 1);
#if TEST1130_IS_ON
printf("test1130 decoding td->name %s set present %d\n", td->name, value + 1);
#endif
elm = &td->elements[value];
if (elm->flags & ATF_POINTER) {
/* Member is a pointer to another structure */
......@@ -1060,9 +1064,11 @@ asn_dec_rval_t CHOICE_decode_aper(
memb_ptr2 = &memb_ptr;
}
ASN_DEBUG("Discovered CHOICE %s encodes %s", td->name, elm->name);
#if TEST1130_IS_ON
printf(
"test1130 decoding element(%s) in td->name(%s), pointer(%p)\n", elm->name,
td->name, memb_ptr2);
#endif
if (ct && ct->range_bits >= 0) {
rv = elm->type->op->aper_decoder(
......@@ -1077,9 +1083,11 @@ asn_dec_rval_t CHOICE_decode_aper(
if (rv.code != RC_OK) {
ASN_DEBUG(
"Failed to decode %s in %s (CHOICE) %d", elm->name, td->name, rv.code);
#if TEST0515_IS_ON
printf(
"test0515 Failed to decode %s in %s (CHOICE) %d\n", elm->name, td->name,
rv.code);
#endif
}
return rv;
}
......@@ -1169,32 +1177,42 @@ int CHOICE_print(
const asn_CHOICE_specifics_t* specs =
(const asn_CHOICE_specifics_t*) td->specifics;
unsigned present;
#if TEST1130_IS_ON
if (!sptr)
printf("test1130 sptr null\n");
else
printf("test1130 OK\n");
#endif
if (!sptr) return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
/*
* Figure out which CHOICE element is encoded.
*/
present = _fetch_present_idx(sptr, specs->pres_offset, specs->pres_size);
#if TEST1130_IS_ON
printf("test1130 present %d, td->elements %d\n", present, td->elements_count);
#endif
/*
* Print that element.
*/
if (present > 0 && present <= td->elements_count) {
asn_TYPE_member_t* elm = &td->elements[present - 1];
#if TEST1130_IS_ON
printf("test1130 td_name %s, element_name %s\n", td->name, elm->name);
#endif
const void* memb_ptr;
if (elm->flags & ATF_POINTER) {
memb_ptr = *(const void* const*) ((const char*) sptr + elm->memb_offset);
#if TEST1130_IS_ON
printf("test1130 memb_ptr1 (%p)\n", memb_ptr);
#endif
if (!memb_ptr) return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
} else {
memb_ptr = (const void*) ((const char*) sptr + elm->memb_offset);
#if TEST1130_IS_ON
printf("test1130 memb_ptr2 (%p)\n", memb_ptr);
#endif
}
/* Print member's name and stuff */
......@@ -1207,7 +1225,9 @@ int CHOICE_print(
return elm->type->op->print_struct(
elm->type, memb_ptr, ilevel, cb, app_key);
} else {
#if TEST1130_IS_ON
printf("test1130 casued by present = %d\n", present);
#endif
return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
}
}
......
......@@ -932,10 +932,12 @@ int SEQUENCE_print(
asn_app_consume_bytes_f* cb, void* app_key) {
size_t edx;
int ret;
#if TEST1130_IS_ON
if (!sptr)
printf("test1130 memory not present %s \n", td->name);
else
printf("test1130 memory present %s \n", td->name);
#endif
if (!sptr) return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
/* Dump preamble */
......@@ -957,7 +959,9 @@ int SEQUENCE_print(
}
} else {
memb_ptr = (const void*) ((const char*) sptr + elm->memb_offset);
#if TEST1130_IS_ON
printf("test1130 element name(%s): mem_ptr(%p)\n", elm->name, memb_ptr);
#endif
}
/* Indentation */
......@@ -1498,7 +1502,9 @@ asn_dec_rval_t SEQUENCE_decode_aper(
}
ASN_DEBUG("Decoding %s as SEQUENCE (APER)", td->name);
#if TEST0515_IS_ON
printf("test0515 Decoding %s as SEQUENCE (APER)\n", td->name);
#endif
/* Handle extensions */
if (specs->first_extension < 0) {
......@@ -1532,7 +1538,9 @@ asn_dec_rval_t SEQUENCE_decode_aper(
*/
for (edx = 0; edx < td->elements_count; edx++) {
asn_TYPE_member_t* elm = &td->elements[edx];
#if TEST1130_IS_ON
printf("test1130 decoding element (%s)\n", elm->name);
#endif
void* memb_ptr; /* Pointer to the member */
void** memb_ptr2; /* Pointer to that pointer */
#if 0
......@@ -1572,9 +1580,11 @@ asn_dec_rval_t SEQUENCE_decode_aper(
ASN_DEBUG(
"Member %s->%s is optional, p=%d (%d->%d)", td->name, elm->name,
present, (int) opmd.nboff, (int) opmd.nbits);
#if TEST0515_IS_ON
printf(
"test0515 Member %s->%s is optional, p=%d (%d->%d)\n", td->name,
elm->name, present, (int) opmd.nboff, (int) opmd.nbits);
#endif
if (present == 0) {
/* This element is not present */
if (elm->default_value_set) {
......@@ -1593,7 +1603,9 @@ asn_dec_rval_t SEQUENCE_decode_aper(
/* Fetch the member from the stream */
ASN_DEBUG("Decoding member \"%s\" in %s", elm->name, td->name);
#if TEST0515_IS_ON
printf("test0515 Decoding member \"%s\" in %s\n", elm->name, td->name);
#endif
if (elm->flags & ATF_OPEN_TYPE) {
rv = OPEN_TYPE_aper_get(opt_codec_ctx, td, st, elm, pd);
......
......@@ -789,10 +789,12 @@ int SET_OF_print(
const asn_anonymous_set_* list = _A_CSET_FROM_VOID(sptr);
int ret;
int i;
#if TEST1130_IS_ON
if (!sptr)
printf("test1130 set_of_printf sptr null\n");
else
printf("test1130 set_of_printf OK\n");
#endif
if (!sptr) return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
/* Dump preamble */
......
......@@ -33,6 +33,7 @@ ber_tlv_tag_t asn_TYPE_outmost_tag(
*/
int asn_fprint(
FILE* stream, const asn_TYPE_descriptor_t* td, const void* struct_ptr) {
#if ASN_FPRINT_IS_ON
if (!stream) stream = stdout;
if (!td || !struct_ptr) {
errno = EINVAL;
......@@ -48,7 +49,7 @@ int asn_fprint(
if (_print2fp("\n", 1, stream)) {
return -1;
}
#endif
return fflush(stream);
}
......
......@@ -79,7 +79,9 @@ static asn_dec_rval_t uper_open_type_get_simple(
ASN__STACK_OVERFLOW_CHECK(ctx);
ASN_DEBUG("Getting open type %s...", td->name);
#if TEST1130_IS_ON
printf("test1130 decoding open type %s\n", td->name);
#endif
do {
chunk_bytes = uper_get_length(pd, -1, 0, &repeat);
......@@ -407,10 +409,14 @@ static asn_dec_rval_t aper_open_type_get_simple(
ASN__STACK_OVERFLOW_CHECK(ctx);
ASN_DEBUG("Getting open type %s...", td->name);
#if TEST0515_IS_ON
printf("test0515 Getting open type %s...\n", td->name);
#endif
do {
#if TEST1130_IS_ON
printf("test1130 while repeat1(%d)\n", repeat);
#endif
chunk_bytes = aper_get_length(pd, -1, -1, &repeat);
if (chunk_bytes < 0) {
FREEMEM(buf);
......@@ -431,14 +437,18 @@ static asn_dec_rval_t aper_open_type_get_simple(
ASN__DECODE_STARVED;
}
bufLen += chunk_bytes;
#if TEST1130_IS_ON
printf("test1130 while repeat2(%d)\n", repeat);
#endif
} while (repeat);
// ASN_DEBUG("Getting open type %s encoded in %ld bytes", td->name,
// (long)bufLen);
#if TEST1130_IS_ON
printf(
"test1130 Getting open type %s encoded in %ld bytes\n", td->name,
(long) bufLen);
#endif
memset(&spd, 0, sizeof(spd));
spd.buffer = buf;
......
......@@ -81,8 +81,6 @@ void PlmnId::getMnc(std::string& mnc) {
mnc = to_string(mnc_digit2);
mnc += to_string(mnc_digit3);
}
//mnc = to_string(m_mnc);
cout<<"################ MNC "<<mnc<<endl;
}
//------------------------------------------------------------------------------
......
......@@ -155,7 +155,8 @@ add_definitions(-DBSTRLIB_CAN_USE_STL=1 -DBSTRLIB_CAN_USE_IOSTREAM=1 -DBSTRLIB_T
if(STATIC_LINKING)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g -fstack-protector-all -DMALLOC_CHECK_=3 -DINFO_IS_ON=1 -DDEBUG_IS_ON=1 -DTRACE_IS_ON=1 -O0 -fno-omit-frame-pointer")
else (STATIC_LINKING)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g -fstack-protector-all -DMALLOC_CHECK_=3 -DINFO_IS_ON=1 -DDEBUG_IS_ON=1 -DTRACE_IS_ON=1 -O0 -fsanitize=address -fno-omit-frame-pointer")
#set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g -fstack-protector-all -DMALLOC_CHECK_=3 -DINFO_IS_ON=1 -DDEBUG_IS_ON=1 -DTRACE_IS_ON=1 -O0 -fsanitize=address -fno-omit-frame-pointer")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g -fstack-protector-all -DMALLOC_CHECK_=3 -DINFO_IS_ON=1 -O0 -fsanitize=address -fno-omit-frame-pointer")
endif(STATIC_LINKING)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -O2 -fno-omit-frame-pointer -s -DINFO_IS_ON=1 ")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS} -g -O2 -DINFO_IS_ON=1 ")
......@@ -164,7 +165,8 @@ set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS} -Os -s -DTRACE_IS_ON=1 -DDEBUG_IS
if(STATIC_LINKING)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -std=c++17 -g -fstack-protector-all -DMALLOC_CHECK_=3 -DINFO_IS_ON=1 -DDEBUG_IS_ON=1 -DTRACE_IS_ON=1 -O0 -fno-omit-frame-pointer")
else(STATIC_LINKING)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -std=c++17 -g -fstack-protector-all -DMALLOC_CHECK_=3 -DINFO_IS_ON=1 -DDEBUG_IS_ON=1 -DTRACE_IS_ON=1 -O0 -fsanitize=address -fno-omit-frame-pointer")
#set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -std=c++17 -g -fstack-protector-all -DMALLOC_CHECK_=3 -DINFO_IS_ON=1 -DDEBUG_IS_ON=1 -DTRACE_IS_ON=1 -O0 -fsanitize=address -fno-omit-frame-pointer")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -std=c++17 -g -fstack-protector-all -DMALLOC_CHECK_=3 -DINFO_IS_ON=1 -O0 -fsanitize=address -fno-omit-frame-pointer")
endif(STATIC_LINKING)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -std=c++17 -O2 -fno-omit-frame-pointer -s -DINFO_IS_ON=1")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} -std=c++17 -g -O2 -DINFO_IS_ON=1")
......
......@@ -48,6 +48,8 @@ extern "C" {
#include <iostream>
#include "thread_sched.hpp"
namespace sctp {
//------------------------------------------------------------------------------
......@@ -91,10 +93,13 @@ void sctp_server::start_receive(sctp_application* app) {
pthread_create(&thread_, NULL, sctp_receiver_thread, (void*) this);
}
//------------------------------------------------------------------------------
void* sctp_server::sctp_receiver_thread(void* arg) {
sctp_server* ptr = (sctp_server*) arg;
Logger::sctp().info("Create pthread to receive sctp message");
set_cpu(5);
int fdmax;
int clientsock;
fd_set master;
......
......@@ -24,7 +24,7 @@
\company Eurecom
\email: lionel.gauthier@eurecom.fr
*/
#include <iostream>
#include "thread_sched.hpp"
//------------------------------------------------------------------------------
......@@ -48,3 +48,24 @@ void util::thread_sched_params::apply(
"Could not set schedparam to ITTI task %d, err=%d", task_id, rc);
}
}
//------------------------------------------------------------------------------
int set_cpu(int cpu_num)
{
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
CPU_SET(cpu_num,&cpuset);
// int rc =pthread_setaffinity_np(threads[i].native_handle(),sizeof(cpu_set_t), &cpuset);
int rc =pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
if (rc != 0) {
std::cerr << "Error calling pthread_setaffinity_np: " << rc << "\n";
}
return rc;
}
\ No newline at end of file
......@@ -44,4 +44,7 @@ class thread_sched_params {
};
} // namespace util
int set_cpu(int cpu_num);
#endif /* FILE_THREAD_SCHED_HPP_SEEN */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment