SqlPool::SqlConnectionPtr SqlPool::get(const String &source_id, int timeout) { SqlSource src; { ScopedLock lock(pool_mux_); std::map<String, SqlSource>::iterator source_it = sources_.find(source_id); if (sources_.end() == source_it) throw PoolError(_T("Unknown source ID: ") + source_id); if (pools_[source_id].size()) { SqlConnectionPtr handle = pools_[source_id].front(); ++counts_[source_id]; pools_[source_id].pop_front(); LOG(ll_INFO, _T("got connection") + get_stats(source_id)); return handle; } src = source_it->second; } LOG(ll_DEBUG, _T("opening connection") + format_stats(source_id)); SqlConnectionPtr handle; if (interlocked_open_) { ScopedLock lock(open_mux_); handle = new SqlConnection(src); } else handle = new SqlConnection(src); LOG(ll_INFO, _T("opened connection") + get_stats(source_id)); { ScopedLock lock(pool_mux_); ++counts_[source_id]; } return handle; }
void SqlPool::put(SqlConnectionPtr handle, bool close_now) { if (!handle) return; if (handle->bad()) close_now = true; if (!close_now) handle->clear(); if (handle->bad()) close_now = true; const String source_id = handle->get_source().id(); ScopedLock lock(pool_mux_); --counts_[source_id]; if (!close_now) { handle->free_since_ = time(NULL); pools_[source_id].push_back(handle); LOG(ll_INFO, _T("put connection") + get_stats(source_id)); } else { LOG(ll_DEBUG, _T("forced closing connection") + format_stats(source_id)); delete handle; LOG(ll_INFO, _T("forced closed connection") + get_stats(source_id)); } }
struct SimulationResult* run_simulation() { int rank = get_rank(); int num_processes = get_num_processes(); struct SimulationResult *result = 0; struct StepResult *last_result = 0; // only the master process collects the simulation results if(rank == 0) { result = malloc(sizeof(struct SimulationResult)); result->operations = 0; // set start time gettimeofday(&result->start_time, NULL); } init_map(); MPI_Barrier(MPI_COMM_WORLD); int i = 0; int died = 0; if(rank == 0) { printf("Start Population\n"); } died = get_stats(i, &last_result, result); while(i < MAX_SIMULATION_STEPS && !died) { i++; if(rank == 0) printf("Simulation Step %d\n", i); simulation_step(i); died = get_stats(i, &last_result, result); if(num_processes == 1) { print_bitmap(i); } } MPI_Barrier(MPI_COMM_WORLD); if(rank == 0) { gettimeofday(&result->finish_time, NULL); calc_runtime(result); } return result; }
void SqlPool::close_all() { ScopedLock lock(pool_mux_); for (std::map<String, Pool>::iterator i = pools_.begin(); i != pools_.end(); ++i) { LOG(ll_DEBUG, _T("closing all") + get_stats(i->first)); for (Pool::iterator j = i->second.begin(); j != i->second.end(); ++j) delete *j; LOG(ll_INFO, _T("closed all") + get_stats(i->first)); } }
void netstats(void) { pid_read(0); // include all processes printf("Displaying network statistics only for sandboxes using a new network namespace.\n"); // print processes while (1) { // set pid table int i; int itv = 5; // 5 second interval pid_read(0); // start rx/tx measurements for (i = 0; i < max_pids; i++) { if (pids[i].level == 1) get_stats(i); } // wait 5 seconds firemon_sleep(itv); // grab screen size struct winsize sz; int row = 24; int col = 80; if (!ioctl(0, TIOCGWINSZ, &sz)) { col = sz.ws_col; row = sz.ws_row; } // start printing firemon_clrscr(); char *header = get_header(); if (strlen(header) > (size_t)col) header[col] = '\0'; printf("%s\n", header); if (row > 0) row--; free(header); // start rx/tx measurements for (i = 0; i < max_pids; i++) { if (pids[i].level == 1) { get_stats(i); print_proc(i, itv, col); } } #ifdef HAVE_GCOV __gcov_flush(); #endif } }
void netstats(void) { if (getuid() == 0) firemon_drop_privs(); pid_read(0); // include all processes printf("Displaying network statistics only for sandboxes using a new network namespace.\n"); // print processes while (1) { // set pid table int i; int itv = 5; // 5 second interval pid_read(0); // todo: preserve the last calculation if any, so we don't have to do get_stats() // start rx/tx measurements for (i = 0; i < MAX_PIDS; i++) { if (pids[i].level == 1) get_stats(i); } // wait 5 seconds firemon_sleep(itv); // grab screen size struct winsize sz; int row = 24; int col = 80; if (!ioctl(0, TIOCGWINSZ, &sz)) { col = sz.ws_col; row = sz.ws_row; } // start printing firemon_clrscr(); char *header = get_header(); if (strlen(header) > col) header[col] = '\0'; printf("%s\n", header); if (row > 0) row--; free(header); // start rx/tx measurements for (i = 0; i < MAX_PIDS; i++) { if (pids[i].level == 1) { get_stats(i); print_proc(i, itv, col); } } } }
void testSuite() { hashtable table = init_hashtable(7); printf(":: Table elems: %d\n", table->p); printf(":: Inserting elements in hashtable\n"); put(&table, "toto", "hey"); put(&table, "lablab", "monk"); put(&table, "blabla", "plop"); put(&table, "toto", "ho!"); put(&table, "tops", "hahah"); put(&table, "pots", "huhuh"); displayHashTable(table); printf(":: Seeking for hello: %s\n", get(table, "hello")); printf(":: Seeking for toto: %s\n", get(table, "toto")); printf(":: Removing elem tops, toto and lablab\n"); rmove(&table, "tops"); rmove(&table, "toto"); rmove(&table, "lablab"); displayHashTable(table); printf(":: Changing hash function and adding two elems\n"); hashtable table2 = init_hashtable(7); set_hfunc(&table2, &idx_hashfunction); put(&table2, "toto", "hey"); put(&table2, "blabla", "plop"); put(&table2, "lablab", "monk"); displayHashTable(table2); printf(":: Fonction for first hashtable: %p\n", get_hfunc(table)); printf(":: Fonction for second hashtable: %p\n", get_hfunc(table2)); printf(":: Stats for first table\n"); put(&table, "lablab", "monk"); put(&table, "toto", "ho!"); put(&table, "tops", "hahah"); displayStats(get_stats(table)); printf(":: Stats for second table\n"); displayStats(get_stats(table2)); printf(":: Rehash table with 11 buckets\n"); set_hfunc(&table, &idx_hashfunction); rehash_table(&table, 11); displayHashTable(table); }
void create_tag( const string& tag, const comment_object& comment, double hot )const { comment_id_type parent; account_id_type author = _db.get_account( comment.author ).id; if( comment.parent_author.size() ) parent = _db.get_comment( comment.parent_author, comment.parent_permlink ).id; const auto& tag_obj = _db.create<tag_object>( [&]( tag_object& obj ) { obj.tag = tag; obj.comment = comment.id; obj.parent = parent; obj.created = comment.created; obj.active = comment.active; obj.cashout = comment.cashout_time; obj.net_votes = comment.net_votes; obj.children = comment.children; obj.net_rshares = comment.net_rshares.value; obj.children_rshares2 = comment.children_rshares2; obj.total_payout = comment.total_payout_value; obj.author = author; obj.net_votes = comment.net_votes; }); add_stats( tag_obj, get_stats( tag ) ); }
void run_io(ARK *ark, uint32_t pths) { worker_t w[pths]; uint32_t i = 0; uint32_t ops = 0; uint32_t ios = 0; uint32_t e_secs = 0; testcase_start = time(0); /* start all threads */ for (i=0; i<pths; i++) { w[i].ark = ark; w[i].db = dbs+(i % pths); pthread_create(&(w[i].pth), NULL, fp, (void*)(w+i)); } /* wait for all threads to complete */ for (i=0; i<pths; i++) { pthread_join(w[i].pth, NULL); } testcase_stop = time(0); e_secs = testcase_stop - testcase_start; get_stats(ark, &ops, &ios); ops = ops / e_secs; ios = ios / e_secs; printf("op/s:%7d io/s:%7d secs:%d\n", ops, ios, e_secs); }
void song_stats(void *unused1, void *unused2, void *unused3) { SongStats stats; get_stats(&stats); char str[1000]; snprintf(str, sizeof(str), "Header: %6d bytes %2d %%\n" "FX: %6d bytes %2d %%\n" "Def.vol/pan: %6d bytes %2d %%\n" "Instruments: %6d bytes %2d %%\n" "Sequence: %6d bytes %2d %%\n" "Patterns: %6d bytes %2d %%\n" "Wavetable: %6d bytes %2d %%\n" "Wave names: %6d bytes %2d %%\n" "-------------------------------\n" "TOTAL: %6d bytes", stats.size[STATS_HEADER], stats.size[STATS_HEADER] * 100 / stats.total_size, stats.size[STATS_FX], stats.size[STATS_FX] * 100 / stats.total_size, stats.size[STATS_DEFVOLPAN], stats.size[STATS_DEFVOLPAN] * 100 / stats.total_size, stats.size[STATS_INSTRUMENTS], stats.size[STATS_INSTRUMENTS] * 100 / stats.total_size, stats.size[STATS_SEQUENCE], stats.size[STATS_SEQUENCE] * 100 / stats.total_size, stats.size[STATS_PATTERNS], stats.size[STATS_PATTERNS] * 100 / stats.total_size, stats.size[STATS_WAVETABLE], stats.size[STATS_WAVETABLE] * 100 / stats.total_size, stats.size[STATS_WAVETABLE_NAMES], stats.size[STATS_WAVETABLE_NAMES] * 100 / stats.total_size, stats.total_size ); msgbox(domain, mused.slider_bevel, &mused.largefont, str, MB_OK); }
static t_file *get_file_infos(char *path, t_padding *paddings, int flags) { t_file *file; file = (t_file*)ft_memalloc(sizeof(t_file)); file->stats = get_stats(path); file->size = ft_ultoa(file->stats->st_size); file->nblink = ft_ultoa(file->stats->st_nlink); if (S_ISBLK(file->stats->st_mode) || (S_ISCHR(file->stats->st_mode))) { file->major = ft_itoa(major(file->stats->st_rdev)); file->minor = ft_itoa(minor(file->stats->st_rdev)); } else { file->major = NULL; file->minor = NULL; } file->path = ft_strdup(""); file->file_name = ft_strdup(path); get_group_and_name(file); get_paddings(paddings, file); file->flags = flags; return (file); }
static void io_recv_error_without_active_register(){ LinphoneCoreManager *mgr; LinphoneCore* lc; int register_ok; stats* counters ; int number_of_udp_proxy=0; MSList* proxys; mgr=configure_lcm(); lc=mgr->lc; counters = get_stats(lc); register_ok=counters->number_of_LinphoneRegistrationOk; number_of_udp_proxy=get_number_of_udp_proxy(lc); for (proxys=ms_list_copy(linphone_core_get_proxy_config_list(lc));proxys!=NULL;proxys=proxys->next) { LinphoneProxyConfig* proxy_cfg=(LinphoneProxyConfig*)proxys->data; linphone_proxy_config_edit(proxy_cfg); linphone_proxy_config_enable_register(proxy_cfg,FALSE); linphone_proxy_config_done(proxy_cfg); } ms_list_free(proxys); CU_ASSERT_TRUE(wait_for(lc,lc,&counters->number_of_LinphoneRegistrationCleared,register_ok /*because 1 udp*/)); sal_set_recv_error(lc->sal, 0); /*nothing should happen because no active registration*/ CU_ASSERT_FALSE(wait_for(lc,lc,&counters->number_of_LinphoneRegistrationProgress,2*(register_ok-number_of_udp_proxy) /*because 1 udp*/)); CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationFailed,0) sal_set_recv_error(lc->sal, 1); /*reset*/ linphone_core_manager_destroy(mgr); }
void web_server::handle_get(socket_ptr socket, const std::string& url, const std::map<std::string, std::string>& args) { std::map<std::string, std::string>::const_iterator it = args.find("type"); if(it != args.end() && it->second == "status") { std::map<variant,variant> m; const std::map<std::string,std::string> errors = get_stats_errors(); for(std::map<std::string,std::string>::const_iterator i = errors.begin(); i != errors.end(); ++i) { std::string msg = i->second; if(msg.empty()) { msg = "OK"; } m[variant(i->first)] = variant(msg); } send_msg(socket, "text/json", variant(&m).write_json(true, variant::JSON_COMPLIANT), ""); return; } variant value = get_stats(args.count("version") ? args.find("version")->second : "", args.count("module") ? args.find("module")->second : "", args.count("module_version") ? args.find("module_version")->second : "", args.count("level") ? args.find("level")->second : ""); send_msg(socket, "text/json", value.write_json(true, variant::JSON_COMPLIANT), ""); }
static void io_recv_error_late_recovery(){ LinphoneCoreManager *mgr; LinphoneCore* lc; int register_ok; stats* counters ; int number_of_udp_proxy=0; MSList* lcs; mgr=linphone_core_manager_new2( "multi_account_lrc",FALSE); /*to make sure iterates are not call yet*/ lc=mgr->lc; sal_set_refresher_retry_after(lc->sal,1000); counters=&mgr->stat; CU_ASSERT_TRUE(wait_for(mgr->lc,mgr->lc,&counters->number_of_LinphoneRegistrationOk,ms_list_size(linphone_core_get_proxy_config_list(mgr->lc)))); counters = get_stats(lc); register_ok=counters->number_of_LinphoneRegistrationOk; number_of_udp_proxy=get_number_of_udp_proxy(lc); /*simulate a general socket error*/ sal_set_recv_error(lc->sal, 0); sal_set_send_error(lc->sal, -1); CU_ASSERT_TRUE(wait_for(lc,NULL,&counters->number_of_LinphoneRegistrationProgress,(register_ok-number_of_udp_proxy)+register_ok /*because 1 udp*/)); CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationFailed,0) CU_ASSERT_TRUE(wait_for_list(lcs=ms_list_append(NULL,lc),&counters->number_of_LinphoneRegistrationFailed,(register_ok-number_of_udp_proxy),sal_get_refresher_retry_after(lc->sal)+1000)); sal_set_recv_error(lc->sal, 1); /*reset*/ sal_set_send_error(lc->sal, 0); CU_ASSERT_TRUE(wait_for_list(lcs=ms_list_append(NULL,lc),&counters->number_of_LinphoneRegistrationOk,register_ok-number_of_udp_proxy +register_ok,sal_get_refresher_retry_after(lc->sal)+1000)); linphone_core_manager_destroy(mgr); }
static GtkWidget *create_video_window(LinphoneCall *call, LinphoneCallState cstate) { GtkWidget *video_window; GdkDisplay *display; GdkColor color; MSVideoSize vsize = MS_VIDEO_SIZE_CIF; const char *cstate_str; char *title; stats* counters = get_stats(call->core); cstate_str = linphone_call_state_to_string(cstate); title = g_strdup_printf("%s", cstate_str); video_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(video_window), title); g_free(title); gtk_window_resize(GTK_WINDOW(video_window), vsize.width, vsize.height); gdk_color_parse("black", &color); gtk_widget_modify_bg(video_window, GTK_STATE_NORMAL, &color); gtk_widget_show(video_window); g_object_set_data(G_OBJECT(video_window), "call", call); #if GTK_CHECK_VERSION(2,24,0) display = gdk_window_get_display(gtk_widget_get_window(video_window)); #else // backward compatibility with Debian 6 and Centos 6 display = gdk_drawable_get_display(gtk_widget_get_window(video_window)); #endif gdk_display_flush(display); counters->number_of_video_windows_created++; return video_window; }
bool test_transmission(){ udpc_connection_stats stats = get_stats(); const char * srv_arg[] = {"server", NULL}; iron_process server_proc; ASSERT(iron_process_run("./server", srv_arg, &server_proc) == 0); iron_usleep(10000); udpc_service * s1 = udpc_login("[email protected]:a"); ASSERT(s1 != NULL); u64 service_id = 12345; int sent = 0; int received = 0; bool ok = true; void * connection_handle(void * info){ UNUSED(info); udpc_connection * c2 = udpc_listen(s1); int handle_chunk(const transmission_data * tid, const void * _chunk, size_t chunk_id, size_t chunk_size, void * userdata){ received += 1; UNUSED(userdata); UNUSED(tid); const int * chunk = _chunk; int chunk_cnt = chunk_size / sizeof(int); for(int i = 0; i < chunk_cnt; i++){ ok &= (chunk[i] == (int)((chunk_id * (tid->chunk_size/4)) + i)); } return 0; }
static void transport_change(){ LinphoneCoreManager *mgr; LinphoneCore* lc; int register_ok; stats* counters ; LCSipTransports sip_tr; LCSipTransports sip_tr_orig; int number_of_udp_proxy=0; int total_number_of_proxies; memset(&sip_tr,0,sizeof(sip_tr)); mgr=configure_lcm(); lc=mgr->lc; counters = get_stats(lc); register_ok=counters->number_of_LinphoneRegistrationOk; number_of_udp_proxy=get_number_of_udp_proxy(lc); total_number_of_proxies=ms_list_size(linphone_core_get_proxy_config_list(lc)); linphone_core_get_sip_transports(lc,&sip_tr_orig); sip_tr.udp_port=sip_tr_orig.udp_port; /*keep only udp*/ linphone_core_set_sip_transports(lc,&sip_tr); CU_ASSERT_TRUE(wait_for(lc,lc,&counters->number_of_LinphoneRegistrationOk,register_ok+number_of_udp_proxy)); CU_ASSERT_TRUE(wait_for(lc,lc,&counters->number_of_LinphoneRegistrationFailed,total_number_of_proxies-number_of_udp_proxy)); linphone_core_manager_destroy(mgr); }
int diagnostics_read_stats(struct json_str *jptr) { char temp[DIAG_STATS_LENGTH]; int json_int; if (jptr == NULL) return -1; json_set_val_int(jptr, VAR_EPOCH, sys_get_epoch()); get_stats(temp, sizeof(temp), CONN_STATS); json_set_val_str(jptr, VAR_CONN_STATS, temp); get_stats(temp, sizeof(temp), DHCP_STATS); json_set_val_str(jptr, VAR_DHCP_STATS, temp); get_stats(temp, sizeof(temp), HTTP_CLIENT_STATS); json_set_val_str(jptr, VAR_HTTP_CLIENT_STATS, temp); get_stats(temp, sizeof(temp), CLOUD_STATS); json_set_val_str(jptr, VAR_CLOUD_STATS, temp); /* fixme: Removing cloud cumulative stats from the output */ #if 0 get_stats(temp, sizeof(temp), CLOUD_CUMUL_STATS); json_set_val_str(jptr, VAR_CLOUD_CUMUL_STATS, temp); #endif get_stats(temp, sizeof(temp), HTTPD_STATS); json_set_val_str(jptr, VAR_HTTPD_STATS, temp); get_stats(temp, sizeof(temp), NET_STATS); json_set_val_str(jptr, VAR_NET_STATS, temp); get_stats(temp, sizeof(temp), IP_ADDR); json_set_val_str(jptr, VAR_IP_ADDR, temp); get_stats(temp, sizeof(temp), TIME); json_int = atoi(temp); json_set_val_int(jptr, VAR_TIME, json_int); get_stats(temp, sizeof(temp), PROV_TYPE); json_int = atoi(temp); json_set_val_int(jptr, VAR_PROV_TYPE, json_int); return 0; }
Json::Value get_detailed_stats(const std::vector<dex_output_stats_t> &dexes_stats) { Json::Value dexes; int i = 0; for (const dex_output_stats_t &stats : dexes_stats) { dexes[i++] = get_stats(stats); } return dexes; }
void is_composing_received(LinphoneCore *lc, LinphoneChatRoom *room) { stats *counters = get_stats(lc); if (room->remote_is_composing == LinphoneIsComposingActive) { counters->number_of_LinphoneIsComposingActiveReceived++; } else { counters->number_of_LinphoneIsComposingIdleReceived++; } }
static void auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain) { stats* counters; ms_message("Auth info requested for user id [%s] at realm [%s]\n" ,username ,realm); counters = get_stats(lc); counters->number_of_auth_info_requested++; }
void dtmf_received(LinphoneCore *lc, LinphoneCall *call, int dtmf) { stats* counters = get_stats(lc); char** dst = &counters->dtmf_list_received; *dst = *dst ? ms_strcat_printf(*dst, "%c", dtmf) : ms_strdup_printf("%c", dtmf); counters->dtmf_count++; }
static void wireless_noise(RESULT * result, RESULT * arg1) { char *dev = R2S(arg1); if (check_socket() != 0) return; save_result(result, dev, KEY_NOISE, get_stats(dev, KEY_NOISE)); }
static void wireless_level(RESULT * result, RESULT * arg1) { char *dev = R2S(arg1); if (check_socket() != 0) return; save_result(result, dev, KEY_LEVEL, get_stats(dev, KEY_LEVEL)); }
static void wireless_quality(RESULT * result, RESULT * arg1) { char *dev = R2S(arg1); if (check_socket() != 0) return; save_result(result, dev, KEY_QUALITY, get_stats(dev, KEY_QUALITY)); }
void run_max_io(char *dev, uint32_t vlen, uint32_t LEN) { ARK *ark[MAX_IO_ARKS]; worker_t w[MAX_IO_ARKS][MAX_IO_PTHS]; uint32_t i = 0; uint32_t j = 0; uint32_t ops = 0; uint32_t ios = 0; uint32_t tops = 0; uint32_t tios = 0; uint32_t e_secs = 0; init_kv_db(MAX_IO_PTHS, KLEN, vlen, LEN); testcase_start = time(0); for (i=0; i<MAX_IO_ARKS; i++) { NEW_ARK(dev, &ark[i]); /* create all threads */ for (j=0; j<MAX_IO_PTHS; j++) { w[i][j].ark = ark[i]; w[i][j].db = dbs+(j % KV_PTHS); pthread_create(&(w[i][j].pth), NULL, fp, (void*)(&w[i][j])); } } /* wait for all threads to complete */ for (i=0; i<MAX_IO_ARKS; i++) { for (j=0; j<MAX_IO_PTHS; j++) { pthread_join(w[i][j].pth, NULL); } } testcase_stop = time(0); for (i=0; i<MAX_IO_ARKS; i++) { get_stats(ark[i], &ops, &ios); tops += ops; tios += ios; } e_secs = testcase_stop - testcase_start; ops = tops / e_secs; ios = tios / e_secs; printf("op/s:%7d io/s:%7d secs:%d\n", ops, ios, e_secs); free_kv_db(MAX_IO_PTHS, LEN); for (i=0; i<MAX_IO_ARKS; i++) { assert(0 == ark_delete(ark[i])); } }
static void register_with_refresh_base_3(LinphoneCore* lc , bool_t refresh ,const char* domain ,const char* route ,bool_t late_auth_info ,LCSipTransports transport ,LinphoneRegistrationState expected_final_state) { int retry=0; char* addr; LinphoneProxyConfig* proxy_cfg; stats* counters; LinphoneAddress *from; const char* server_addr; LinphoneAuthInfo *info; BC_ASSERT_PTR_NOT_NULL(lc); if (!lc) return; counters = get_stats(lc); reset_counters(counters); linphone_core_set_sip_transports(lc,&transport); proxy_cfg = linphone_proxy_config_new(); from = create_linphone_address(domain); linphone_proxy_config_set_identity(proxy_cfg,addr=linphone_address_as_string(from)); ms_free(addr); server_addr = linphone_address_get_domain(from); linphone_proxy_config_enable_register(proxy_cfg,TRUE); linphone_proxy_config_set_expires(proxy_cfg,1); if (route) { linphone_proxy_config_set_route(proxy_cfg,route); linphone_proxy_config_set_server_addr(proxy_cfg,route); } else { linphone_proxy_config_set_server_addr(proxy_cfg,server_addr); } linphone_address_destroy(from); linphone_core_add_proxy_config(lc,proxy_cfg); linphone_core_set_default_proxy(lc,proxy_cfg); while (counters->number_of_LinphoneRegistrationOk<1+(refresh!=0) && retry++ <(1100 /*only wait 11 s if final state is progress*/+(expected_final_state==LinphoneRegistrationProgress?0:2000))) { linphone_core_iterate(lc); if (counters->number_of_auth_info_requested>0 && linphone_proxy_config_get_state(proxy_cfg) == LinphoneRegistrationFailed && late_auth_info) { if (!linphone_core_get_auth_info_list(lc)) { BC_ASSERT_EQUAL(linphone_proxy_config_get_error(proxy_cfg),LinphoneReasonUnauthorized, int, "%d"); info=linphone_auth_info_new(test_username,NULL,test_password,NULL,auth_domain,NULL); /*create authentication structure from identity*/ linphone_core_add_auth_info(lc,info); /*add authentication info to LinphoneCore*/ } } if (linphone_proxy_config_get_error(proxy_cfg) == LinphoneReasonBadCredentials || (counters->number_of_auth_info_requested>2 &&linphone_proxy_config_get_error(proxy_cfg) == LinphoneReasonUnauthorized)) /*no need to continue if auth cannot be found*/ break; /*no need to continue*/ ms_usleep(10000); }
static void network_reachable(LinphoneCore *lc, bool_t reachable) { stats* counters; ms_message("Network reachable [%s]",reachable?"TRUE":"FALSE"); counters = get_stats(lc); if (reachable) counters->number_of_NetworkReachableTrue++; else counters->number_of_NetworkReachableFalse++; }
/** ******************************************************************************** ** \brief ** create threads to run one of the IO functions, wait for the threads to ** complete, and print the iops *******************************************************************************/ void kv_sync_io(char *dev, uint32_t vlen, uint32_t len, uint32_t pths, uint32_t read) { worker_t w[KV_PTHS]; ARK *ark = NULL; uint32_t i = 0; uint32_t ops = 0; uint32_t ios = 0; uint32_t e_secs = 0; char *fp_txt = NULL; void* (*fp)(void*); if (read == 75) { fp = (void*(*)(void*))read_75_percent; fp_txt="read: 75%"; } else { fp = (void*(*)(void*))read_100_percent; fp_txt="read:100%"; } init_kv_db(pths, KLEN, vlen, len); NEW_ARK(dev, &ark); printf("SYNC: ctxt:%-2d QD:%-3d size:%2dk %s ", 1, pths, vlen/1000,fp_txt); fflush(stdout); testcase_start = time(0); /* start all threads */ for (i=0; i<pths; i++) { w[i].ark = ark; w[i].db = dbs+(i % pths); pthread_create(&(w[i].pth), NULL, fp, (void*)(w+i)); } /* wait for all threads to complete */ for (i=0; i<pths; i++) { pthread_join(w[i].pth, NULL); } testcase_stop = time(0); e_secs = testcase_stop - testcase_start; get_stats(ark, &ops, &ios); ops = ops / e_secs; ios = ios / e_secs; printf("op/s:%-7d io/s:%-7d secs:%d\n", ops, ios, e_secs); free_kv_db(pths, len); assert(0 == ark_delete(ark)); }
void reset_turn_stats(const std::string & save_id) { stats &s = get_stats(save_id); s.turn_damage_inflicted = 0; s.turn_damage_taken = 0; s.turn_expected_damage_inflicted = 0; s.turn_expected_damage_taken = 0; s.save_id = save_id; }