int main(int argc, char **argv) { #if 1 if(0 == isArbiterExist()) { marbit_send_log(ERROR,"arbiter is not start!\n"); exit(1); } #endif //init sys info if(0 != init_sys_info()) { marbit_send_log(ERROR,"Failed to init_sys_info!\n"); exit(1); } //parse the parameters if(0 != parse_input_parameters(argc, argv)) { destroy_info(); input_error(); exit(1); } //time_t begin_time = time(NULL); // time_t do_process_data_stream_time= time(NULL); // time_t do_process_data_aggregation_time= time(NULL); // time_t do_process_sort_time = time(NULL); // time_t print_baselink_time = time(NULL); //time_t print_sorted_list_time = time(NULL); struct timeval start, getFromArbiter, printLink, dataAggregation, quickSort, printSort, end; gettimeofday( &start, NULL ); #if 1 //data_stream, check need get data stream from arbiter or configure file if(0 == isNeedReadFromDB(DATA_STREAM_FILE_PATH, g_flush_interval)) { //set_timer(); if(0 != do_process_from_arbiter()) { marbit_send_log(ERROR,"Failed to get data stream from arbiter\n"); exit(1); } } gettimeofday( &getFromArbiter, NULL ); #endif if(SORTED_BASE_LINK == g_sorted_list_index) { print_baselink_info(DATA_STREAM_FILE_PATH); gettimeofday( &printLink, NULL ); } else if(SORTED_BASE_APP == g_sorted_list_index || SORTED_BASE_IP == g_sorted_list_index) { //data_aggregation do_process_data_aggregation(); gettimeofday( &dataAggregation, NULL ); #if 1 MergeSort(&merglist); gettimeofday( &quickSort, NULL ); printMergeList(merglist); gettimeofday( &printSort, NULL ); destroyMergelist(merglist); #else struct list_head *head = &sorted_list_arry[SORTED_BASE_AGG].list; //struct list_head *head = &sorted_list_arry[g_sorted_list_index].list; struct list_head *first = head->next; struct list_head *last = head->prev; sorted_node_t *pstHead = list_entry(head, sorted_node_t, list); quick_sort(head, first, last); gettimeofday( &quickSort, NULL ); print_sorted_list(SORTED_BASE_AGG); //print_sorted_list(g_sorted_list_index); gettimeofday( &printSort, NULL ); #endif } destroy_info(); gettimeofday( &end, NULL ); if(logdebug.g_trace_enable_flag > 0) { marbit_send_log(INFO,"=======================================\n"); int timeuse = 0; if(SORTED_BASE_LINK == g_sorted_list_index) { timeuse = 1000000 * ( end.tv_sec - start.tv_sec ) + end.tv_usec - start.tv_usec; marbit_send_log(INFO,"all used time = %lu us\n", timeuse); timeuse = 1000000 * ( getFromArbiter.tv_sec - start.tv_sec ) + getFromArbiter.tv_usec - start.tv_usec; marbit_send_log(INFO,"getFromArbiter used time = %lu us\n", timeuse); timeuse = 1000000 * ( printLink.tv_sec - getFromArbiter.tv_sec ) + printLink.tv_usec - getFromArbiter.tv_usec; marbit_send_log(INFO,"printLink used time = %lu us\n", timeuse); timeuse = 1000000 * ( end.tv_sec - printLink.tv_sec ) + end.tv_usec - printLink.tv_usec; marbit_send_log(INFO,"destroy used time = %lu us\n", timeuse); } else { timeuse = 1000000 * ( end.tv_sec - start.tv_sec ) + end.tv_usec - start.tv_usec; marbit_send_log(INFO,"all used time = %lu us\n", timeuse); timeuse = 1000000 * ( getFromArbiter.tv_sec - start.tv_sec ) + getFromArbiter.tv_usec - start.tv_usec; marbit_send_log(INFO,"getFromArbiter used time = %lu us\n", timeuse); timeuse = 1000000 * ( dataAggregation.tv_sec - getFromArbiter.tv_sec ) + dataAggregation.tv_usec - getFromArbiter.tv_usec; marbit_send_log(INFO,"dataAggregation used time = %lu us\n", timeuse); timeuse = 1000000 * ( quickSort.tv_sec - dataAggregation.tv_sec ) + quickSort.tv_usec - dataAggregation.tv_usec; marbit_send_log(INFO,"quickSort used time = %lu us\n", timeuse); timeuse = 1000000 * ( printSort.tv_sec - quickSort.tv_sec ) + printSort.tv_usec - quickSort.tv_usec; marbit_send_log(INFO,"printSort used time = %lu us\n", timeuse); timeuse = 1000000 * ( end.tv_sec - printSort.tv_sec ) + end.tv_usec - printSort.tv_usec; marbit_send_log(INFO,"destroy used time = %lu us\n", timeuse); } } return 0; }
int init_service(int isparent) { if (!isparent) { DEBUG_LOG("INIT_SERVICE"); const char *ip= get_ip_ex(0x01); if ( strncmp( ip,"10.",3 )==0 ) { g_is_test_env=true; DEBUG_LOG("=============TEST ENV TRUE ============="); }else{ g_is_test_env=false; DEBUG_LOG("=============TEST ENV FALSE ============="); } g_log_send_buf_hex_flag=g_is_test_env?1:0; if (sizeof(sprite_t) >= SPRITE_STRUCT_LEN - 800 || sizeof(grp_loop_t) != VIP_BUFF_LEN) { ERROR_RETURN(("sprite struct not big enough\t[%lu %u]", sizeof(sprite_t), SPRITE_STRUCT_LEN), -1); } srand(time(0) * get_server_id()); setup_timer(); INIT_LIST_HEAD(&(g_events.timer_list)); INIT_LIST_HEAD(&active_box_list); if ( config_get_strval("_use_lua_config") ==NULL ){ config_init("./conf/common.conf"); } statistic_logfile = config_get_strval("statistic_file"); if (!statistic_logfile) return -1; if ((init_cli_proto_handles(0) == -1) || (init_db_proto_handles(0) == -1) || (init_home_handle_funs() == -1) || (init_switch_handle_funs() == -1) || (init_all_timer_type() == -1) || (init_magic_code_proto_handles(0) == -1) || (init_spacetime_code_proto_handles(0) == -1) || (init_mall_proto_handles(0) == -1) ) { return -1; } init_sprites(); init_exp_lv(); init_home_maps(); init_all_items(); init_beast_grp(); init_rand_infos(); init_npcs(); init_all_skills(); init_all_clothes(); init_sys_info(); init_all_tasks(); init_mail(); init_shops(); init_vip_items(); init_products(); idc_type = config_get_intval("idc_type" ,1); KDEBUG_LOG(0, "ONLINE START\t[%lu %d]", sizeof(sprite_t), idc_type); if ( //11 (load_xmlconf("./conf/items.xml", load_items) == -1) || (load_xmlconf("./conf/clothes.xml", load_clothes) == -1) || (load_xmlconf("./conf/beasts.xml", load_beasts) == -1) // || (load_xmlconf("./conf/pet_exchange.xml", load_pet_exchange) == -1)//3M || (load_xmlconf("./conf/pet_exchange_egg.xml", load_pet_exchange_egg) == -1) //62 || (load_xmlconf("./conf/gplan.xml", load_rare_beasts) == -1) || (load_xmlconf("./conf/titles.xml", load_honor_titles) == -1) || (load_xmlconf("./conf/picsrv.xml", load_picsrv_config) == -1) ) { return -1; } if ( load_xmlconf("./conf/beastgrp.xml", load_beast_grp) == -1 || (load_xmlconf("./conf/handbook.xml", load_handbook) == -1) || (load_xmlconf("./conf/suits.xml", load_suit) == -1) || ( load_xmlconf("./conf/maps.xml", load_maps) == -1) || (load_xmlconf("./conf/rand_item.xml", load_rand_item) == -1) || (load_xmlconf("./conf/vip_item.xml", load_vip_item) == -1) || (load_xmlconf("./conf/commodity.xml", load_products) == -1) || (load_xmlconf("./conf/skills_price.xml", load_all_skills) == -1) || (load_xmlconf("./conf/tasks_new.xml", load_tasks) == -1)//task:12M || (load_xmlconf("./conf/tasks_new.xml", load_task_loops) == -1) || (load_xmlconf("./conf/holiday.xml", load_holiday_factor) == -1) || (load_xmlconf("./conf/box.xml", load_box) == -1) || (load_xmlconf("./conf/exchanges.xml", load_exchange_info) == -1) || (load_xmlconf("./conf/npc.xml", load_npc) == -1) || (load_xmlconf("./conf/npcSkills.xml", load_shop_skill) == -1) || (load_xmlconf("./conf/npcShop.xml", load_shop_item) == -1) || (load_xmlconf("./conf/mail.xml", load_sys_mail) == -1) || (load_xmlconf("./conf/sysinfo.xml", load_sys_info) == -1) || (load_xmlconf("./conf/fishGame.xml", load_fish_info) == -1) || (load_xmlconf("./conf/professtion.xml", load_init_prof_info) == -1) || (load_xmlconf("./conf/maze.xml", load_maze_xml) == -1) || (load_xmlconf("./conf/mapcopy.xml", load_map_copy) == -1) ) return -1; // sleep(1000); activate_boxes(); start_maze_timer(); /* if(tm_load_dirty("./data/tm_dirty.dat") < 0){ KERROR_LOG(0, "Failed to load drity word file!"); return -1; } */ init_batter_teams(); init_batter_infos(); connect_to_switch_timely(0, 0); regist_timers(); udp_report_fd = create_udp_socket(&udp_report_addr, config_get_strval("report_svr_ip"), config_get_intval("report_svr_port", 0)); udp_post_fd = create_udp_socket(&udp_post_addr, config_get_strval("post_svr_ip"), config_get_intval("post_svr_port", 0)); switch (idc_type) { case idc_type_dx: chat_svr_fd = create_udp_socket(&udp_chat_svr_addr, config_get_strval("dx_chat_svr_ip"), config_get_intval("chat_svr_port", 0)); break; case idc_type_wt: chat_svr_fd = create_udp_socket(&udp_chat_svr_addr, config_get_strval("wt_chat_svr_ip"), config_get_intval("chat_svr_port", 0)); break; case idc_type_internal: case idc_type_internal + 1: chat_svr_fd = create_udp_socket(&udp_chat_svr_addr, config_get_strval("in_chat_svr_ip"), config_get_intval("chat_svr_port", 0)); break; default: return -1; } } return 0; }