diff --git a/cache/test/cache_evbase_benchmark.cpp b/cache/test/cache_evbase_benchmark.cpp index 8caba74..6e50d02 100644 --- a/cache/test/cache_evbase_benchmark.cpp +++ b/cache/test/cache_evbase_benchmark.cpp @@ -406,7 +406,7 @@ int main(int argc, char **argv) return -1; } - runtime_log = MESA_create_runtime_log_handle("./runtime.log", 10); + runtime_log = (void *)MESA_create_runtime_log_handle("./runtime.log", 10); if(NULL==runtime_log) { return -1; diff --git a/cache/test/cache_evbase_test.cpp b/cache/test/cache_evbase_test.cpp index cd65513..0af88e8 100644 --- a/cache/test/cache_evbase_test.cpp +++ b/cache/test/cache_evbase_test.cpp @@ -205,7 +205,7 @@ int main(int argc, char **argv) future_promise_library_init(NULL); - runtime_log = MESA_create_runtime_log_handle("./runtime.log", 10); + runtime_log = (void *)MESA_create_runtime_log_handle("./runtime.log", 10); if(NULL==runtime_log) { return -1; @@ -314,7 +314,7 @@ int main(int argc, char **argv) }*/ sleep(1); } - if(runing_over==2) //GETʱ³¬Ê±É¾³ý£¬À´²»¼° + if(runing_over==2) //GETʱ��ʱɾ���������� { sleep(5); } diff --git a/cache/test/tango_cache_test.cpp b/cache/test/tango_cache_test.cpp index e89d8f4..b29fa9d 100644 --- a/cache/test/tango_cache_test.cpp +++ b/cache/test/tango_cache_test.cpp @@ -414,7 +414,7 @@ int main(int crgc, char **arg) future_promise_library_init(NULL); - runtime_log = MESA_create_runtime_log_handle("./runtime.log", 10); + runtime_log = (void *)MESA_create_runtime_log_handle("./runtime.log", 10); if(NULL==runtime_log) { return -1; diff --git a/common/include/tfe_utils.h b/common/include/tfe_utils.h index e4d409c..baaefb8 100644 --- a/common/include/tfe_utils.h +++ b/common/include/tfe_utils.h @@ -50,14 +50,14 @@ extern bool g_print_to_stderr; #define TFE_LOG_ERROR(handler, fmt, ...) \ do { if(g_print_to_stderr) fprintf(stderr, fmt "\n" , ##__VA_ARGS__); \ - MESA_handle_runtime_log(handler, RLOG_LV_FATAL, __FUNCTION__, fmt, ##__VA_ARGS__); } while(0) + MESA_handle_runtime_log((struct log_handle_t *)handler, RLOG_LV_FATAL, __FUNCTION__, fmt, ##__VA_ARGS__); } while(0) #define TFE_LOG_INFO(handler, fmt, ...) \ do { if(g_print_to_stderr) fprintf(stderr, fmt "\n", ##__VA_ARGS__); \ - MESA_handle_runtime_log(handler, RLOG_LV_INFO, __FUNCTION__, fmt, ##__VA_ARGS__); } while(0) \ + MESA_handle_runtime_log((struct log_handle_t *)handler, RLOG_LV_INFO, __FUNCTION__, fmt, ##__VA_ARGS__); } while(0) \ #define TFE_LOG_DEBUG(handler, fmt, ...) \ -do { MESA_handle_runtime_log(handler, RLOG_LV_DEBUG, __FUNCTION__, fmt, ##__VA_ARGS__); } while(0) \ +do { MESA_handle_runtime_log((struct log_handle_t *)handler, RLOG_LV_DEBUG, __FUNCTION__, fmt, ##__VA_ARGS__); } while(0) \ #define CHECK_OR_EXIT(condition, fmt, ...) \ do { if(!(condition)) { TFE_LOG_ERROR(g_default_logger, fmt, ##__VA_ARGS__); exit(EXIT_FAILURE); } } while(0) \ diff --git a/common/src/tfe_ctrl_packet.cpp b/common/src/tfe_ctrl_packet.cpp index 206eb96..c9bd977 100644 --- a/common/src/tfe_ctrl_packet.cpp +++ b/common/src/tfe_ctrl_packet.cpp @@ -79,14 +79,20 @@ struct mpack_mmap_id2type static int fqdn_id_set_cmsg(struct ctrl_pkt_parser *handler, mpack_node_t node, int table_index) { + char empty_str[4] = {0}; uint32_t fqdn_val[8] = {0}; uint32_t array_cnt = mpack_node_array_length(node); tfe_cmsg_set(handler->cmsg, TFE_CMSG_FQDN_CAT_ID_NUM, (const unsigned char *)&array_cnt, sizeof(uint32_t)); - for (uint32_t i = 0; i < array_cnt; i++) { - fqdn_val[i] = mpack_node_u32(mpack_node_array_at(node, i)); + if (array_cnt > 0) { + for (uint32_t i = 0; i < array_cnt; i++) { + fqdn_val[i] = mpack_node_u32(mpack_node_array_at(node, i)); + } + tfe_cmsg_set(handler->cmsg, TFE_CMSG_FQDN_CAT_ID_VAL, (const unsigned char*)fqdn_val, array_cnt * sizeof(uint32_t)); + } + else { + tfe_cmsg_set(handler->cmsg, TFE_CMSG_FQDN_CAT_ID_VAL, (const unsigned char *)empty_str, 0); } - tfe_cmsg_set(handler->cmsg, TFE_CMSG_FQDN_CAT_ID_VAL, (const unsigned char*)fqdn_val, array_cnt * sizeof(uint32_t)); return 0; } @@ -124,6 +130,7 @@ static int proxy_parse_messagepack(mpack_node_t node, void *ctx, void *logger) { int ret = 0; uint64_t value = 0; + char empty_str[4] = {0}; char cmsg_str[256] = {0}; struct ctrl_pkt_parser *handler = (struct ctrl_pkt_parser *)ctx; @@ -152,10 +159,11 @@ static int proxy_parse_messagepack(mpack_node_t node, void *ctx, void *logger) tfe_cmsg_set(handler->cmsg, mpack_table[i].type, (const unsigned char *)&value, mpack_table[i].size); break; case mpack_type_str: - snprintf(cmsg_str, sizeof(cmsg_str), mpack_node_str(ptr), mpack_node_strlen(ptr)); + mpack_node_copy_cstr(ptr, cmsg_str, sizeof(cmsg_str)); tfe_cmsg_set(handler->cmsg, mpack_table[i].type, (const unsigned char *)cmsg_str, mpack_node_strlen(ptr)); break; case mpack_type_nil: + tfe_cmsg_set(handler->cmsg, mpack_table[i].type, (const unsigned char *)empty_str, 0); break; case mpack_type_array: switch(mpack_table[i].array_index) diff --git a/platform/src/acceptor_kni_v4.cpp b/platform/src/acceptor_kni_v4.cpp index a405357..05e5d43 100644 --- a/platform/src/acceptor_kni_v4.cpp +++ b/platform/src/acceptor_kni_v4.cpp @@ -163,7 +163,7 @@ error_out: struct acceptor_kni_v4 *acceptor_kni_v4_create(struct tfe_proxy *proxy, const char *profile) { void *packet_io_logger = NULL; - packet_io_logger = MESA_create_runtime_log_handle("packet_io", RLOG_LV_DEBUG); + packet_io_logger = (void *)MESA_create_runtime_log_handle("packet_io", RLOG_LV_DEBUG); assert(packet_io_logger != NULL); g_packet_io_logger = packet_io_logger; diff --git a/platform/src/proxy.cpp b/platform/src/proxy.cpp index 8f3904c..1a2cac4 100644 --- a/platform/src/proxy.cpp +++ b/platform/src/proxy.cpp @@ -621,7 +621,7 @@ int main(int argc, char * argv[]) /* adds locking, only required if accessed from separate threads */ evthread_use_pthreads(); - g_default_logger = MESA_create_runtime_log_handle("tfe", RLOG_LV_DEBUG); + g_default_logger = (void *)MESA_create_runtime_log_handle("tfe", RLOG_LV_DEBUG); if (unlikely(g_default_logger == NULL)) { TFE_LOG_ERROR(g_default_logger, "Failed at creating default logger: %s", "log/tfe.log"); diff --git a/platform/src/ssl_stream.cpp b/platform/src/ssl_stream.cpp index 9e888b8..efffae2 100644 --- a/platform/src/ssl_stream.cpp +++ b/platform/src/ssl_stream.cpp @@ -1488,7 +1488,7 @@ static void peek_chello_on_succ(future_result_t * result, void * user) TFE_LOG_ERROR(ctx->mgr->logger, "CertStore is unavailable, PASSTHROUGH"); } - ssl_stream_set_cmsg_integer(s_stream, TFE_CMSG_SSL_INTERCEPT_STATE, s_stream->up_parts.action); + ssl_stream_set_cmsg_uint8(s_stream, TFE_CMSG_SSL_INTERCEPT_STATE, s_stream->up_parts.action); ctx->s_stream = s_stream; if(s_stream->up_parts.action==SSL_ACTION_PASSTHROUGH) { diff --git a/platform/src/tcp_stream.cpp b/platform/src/tcp_stream.cpp index 1de3f79..dc89d90 100644 --- a/platform/src/tcp_stream.cpp +++ b/platform/src/tcp_stream.cpp @@ -1344,7 +1344,7 @@ void __stream_access_log_write(struct tfe_stream_private * stream) "%s/%s/%s ", __str_stream_log_type(ev_log->type), str_dir, ev_log->str_error); } - MESA_handle_runtime_log(stream->stream_logger, RLOG_LV_INFO, "access", + TFE_LOG_INFO(stream->stream_logger, RLOG_LV_INFO, "access", "%d %d %d %s %s %s %s %s %s", stream->log_fd_downstream, stream->log_fd_upstream, stream->keyring_id, stream->str_stream_addr, str_passthrough, str_kill, str_log_event, stream->ssl_downstream_info_dump, stream->ssl_upstream_info_dump); @@ -1889,7 +1889,7 @@ void tfe_stream_write_access_log(const struct tfe_stream * stream, int level, co vasprintf(&__tmp_buffer, fmt, arg_ptr); /* Log content with stream tag */ - MESA_handle_runtime_log(_stream->stream_logger, level, "access", "%s %s", _stream->str_stream_addr, __tmp_buffer); + TFE_LOG_INFO(_stream->stream_logger, RLOG_LV_INFO, "access", "%s %s", _stream->str_stream_addr, __tmp_buffer); free(__tmp_buffer); } diff --git a/platform/test/test_tfe_rpc.cpp b/platform/test/test_tfe_rpc.cpp index 7837ca7..8fcb7cb 100644 --- a/platform/test/test_tfe_rpc.cpp +++ b/platform/test/test_tfe_rpc.cpp @@ -228,7 +228,7 @@ int main() unsigned int cert_store_port; future_promise_library_init(NULL); //const char* file_path = "./log/test_tfe_rpc.log",*host="localhost"; - //void * logger = MESA_create_runtime_log_handle(file_path, RLOG_LV_INFO); + //void * logger = (void *)MESA_create_runtime_log_handle(file_path, RLOG_LV_INFO); const char* profile = "./conf/tfe.conf"; const char* section = "key_keeper"; int keyring_id = 0; diff --git a/plugin/business/doh/src/doh.cpp b/plugin/business/doh/src/doh.cpp index 9ba291d..53f9902 100644 --- a/plugin/business/doh/src/doh.cpp +++ b/plugin/business/doh/src/doh.cpp @@ -679,7 +679,7 @@ int doh_on_init(struct tfe_proxy *proxy) TFE_LOG_INFO(NULL, "Doh enabled."); g_doh_conf->thread_num = tfe_proxy_get_work_thread_count(); - g_doh_conf->local_logger = MESA_create_runtime_log_handle("doh", RLOG_LV_DEBUG); + g_doh_conf->local_logger = (void *)MESA_create_runtime_log_handle("doh", RLOG_LV_DEBUG); g_doh_conf->gc_evbase = tfe_proxy_get_gc_evbase(); g_doh_conf->fs_handle = tfe_proxy_get_fs_handle(); diff --git a/plugin/business/tsg-http/src/tsg_http.cpp b/plugin/business/tsg-http/src/tsg_http.cpp index 84303e0..5258daa 100644 --- a/plugin/business/tsg-http/src/tsg_http.cpp +++ b/plugin/business/tsg-http/src/tsg_http.cpp @@ -1161,7 +1161,7 @@ int proxy_http_init(struct tfe_proxy * proxy) g_proxy_rt->thread_num = tfe_proxy_get_work_thread_count(); g_proxy_rt->gc_evbase=tfe_proxy_get_gc_evbase(); - g_proxy_rt->local_logger = MESA_create_runtime_log_handle("tsg_http", RLOG_LV_DEBUG); + g_proxy_rt->local_logger = (void *)MESA_create_runtime_log_handle("tsg_http", RLOG_LV_DEBUG); g_proxy_rt->send_logger = proxy_log_handle_create(profile_path, "LOG", g_proxy_rt->local_logger); if (!g_proxy_rt->send_logger) diff --git a/plugin/protocol/http/src/http_entry.cpp b/plugin/protocol/http/src/http_entry.cpp index 463dc94..c5d1b70 100644 --- a/plugin/protocol/http/src/http_entry.cpp +++ b/plugin/protocol/http/src/http_entry.cpp @@ -89,7 +89,7 @@ int http_plugin_init(struct tfe_proxy * proxy) plugin_ctx->gc_event_hs_private[thread_id] = gc_event; } - plugin_ctx->logger = MESA_create_runtime_log_handle("http", RLOG_LV_DEBUG); + plugin_ctx->logger = (void *)MESA_create_runtime_log_handle("http", RLOG_LV_DEBUG); assert(plugin_ctx->logger != NULL); return 0; diff --git a/plugin/protocol/http2/src/http2_plugin.cpp b/plugin/protocol/http2/src/http2_plugin.cpp index 699ff7a..8e69fd5 100644 --- a/plugin/protocol/http2/src/http2_plugin.cpp +++ b/plugin/protocol/http2/src/http2_plugin.cpp @@ -46,7 +46,7 @@ struct event_timer_ctx void load_logging_conf(const char *config) { RTLogInit2Data *logging_sc_lid = logger(); - logging_sc_lid->handle = MESA_create_runtime_log_handle("http2", RLOG_LV_DEBUG); + logging_sc_lid->handle = (void *)MESA_create_runtime_log_handle("http2", RLOG_LV_DEBUG); if(logging_sc_lid->handle == NULL){ TFE_LOG_ERROR(logging_sc_lid->handle, "Create log runtime_log_handle error, init failed!"); }