static void search_response_cb (SoupSession *session, SoupMessage *msg, RBPodcastSearchITunes *search) { JsonParser *parser; GError *error = NULL; int code; g_object_get (msg, SOUP_MESSAGE_STATUS_CODE, &code, NULL); if (code != 200) { char *reason; g_object_get (msg, SOUP_MESSAGE_REASON_PHRASE, &reason, NULL); rb_debug ("search request failed: %s", reason); g_free (reason); rb_podcast_search_finished (RB_PODCAST_SEARCH (search), FALSE); return; } if (msg->response_body->data == NULL) { rb_debug ("no response data"); rb_podcast_search_finished (RB_PODCAST_SEARCH (search), TRUE); return; } parser = json_parser_new (); if (json_parser_load_from_data (parser, msg->response_body->data, msg->response_body->length, &error)) { process_results (search, parser); } else { rb_debug ("unable to parse response data: %s", error->message); g_clear_error (&error); } g_object_unref (parser); rb_podcast_search_finished (RB_PODCAST_SEARCH (search), TRUE); }
static double apop_mysql_query(char *query){ if (mysql_query(mysql_db,query)) { print_error (mysql_db, "apop_mysql_query failed"); return 1; } process_results(); return 0; }
/* * Run a single instance of the throughput test. When attempting to determine * the maximum packet rate this will be invoked multiple times with the only * difference between runs being the target PPS rate. */ static int run_test_single(odp_cpumask_t *thd_mask_tx, odp_cpumask_t *thd_mask_rx, test_status_t *status) { odph_odpthread_t thd_tbl[MAX_WORKERS]; thread_args_t args_tx, args_rx; uint64_t expected_tx_cnt; int num_tx_workers, num_rx_workers; odph_odpthread_params_t thr_params; memset(&thr_params, 0, sizeof(thr_params)); thr_params.thr_type = ODP_THREAD_WORKER; thr_params.instance = gbl_args->instance; odp_atomic_store_u32(&shutdown, 0); memset(thd_tbl, 0, sizeof(thd_tbl)); memset(gbl_args->rx_stats, 0, gbl_args->rx_stats_size); memset(gbl_args->tx_stats, 0, gbl_args->tx_stats_size); expected_tx_cnt = status->pps_curr * gbl_args->args.duration; /* start receiver threads first */ thr_params.start = run_thread_rx; thr_params.arg = &args_rx; args_rx.batch_len = gbl_args->args.rx_batch_len; odph_odpthreads_create(&thd_tbl[0], thd_mask_rx, &thr_params); odp_barrier_wait(&gbl_args->rx_barrier); num_rx_workers = odp_cpumask_count(thd_mask_rx); /* then start transmitters */ thr_params.start = run_thread_tx; thr_params.arg = &args_tx; num_tx_workers = odp_cpumask_count(thd_mask_tx); args_tx.pps = status->pps_curr / num_tx_workers; args_tx.duration = gbl_args->args.duration; args_tx.batch_len = gbl_args->args.tx_batch_len; odph_odpthreads_create(&thd_tbl[num_rx_workers], thd_mask_tx, &thr_params); odp_barrier_wait(&gbl_args->tx_barrier); /* wait for transmitter threads to terminate */ odph_odpthreads_join(&thd_tbl[num_rx_workers]); /* delay to allow transmitted packets to reach the receivers */ odp_time_wait_ns(SHUTDOWN_DELAY_NS); /* indicate to the receivers to exit */ odp_atomic_store_u32(&shutdown, 1); /* wait for receivers */ odph_odpthreads_join(&thd_tbl[0]); if (!status->warmup) return process_results(expected_tx_cnt, status); return 1; }
static int ident_result(void *client_data, const char *ip, int port, const char *reply) { dcc_session_t *session = client_data; session->ident_id = -1; if (reply) session->ident = strdup(reply); else session->ident = strdup("~dcc"); process_results(session); return(0); }
static int dns_result(void *client_data, const char *ip, char **hosts) { dcc_session_t *session = client_data; const char *host; session->dns_id = -1; if (!hosts || !hosts[0]) host = ip; else host = hosts[0]; session->host = strdup(host); process_results(session); return(0); }
/* * Run a single instance of the throughput test. When attempting to determine * the maximum packet rate this will be invoked multiple times with the only * difference between runs being the target PPS rate. */ static int run_test_single(odp_cpumask_t *thd_mask_tx, odp_cpumask_t *thd_mask_rx, test_status_t *status) { odph_linux_pthread_t thd_tbl[MAX_WORKERS]; thread_args_t args_tx, args_rx; uint64_t expected_tx_cnt; int num_tx_workers, num_rx_workers; odp_atomic_store_u32(&shutdown, 0); memset(thd_tbl, 0, sizeof(thd_tbl)); memset(&gbl_args->rx_stats, 0, sizeof(gbl_args->rx_stats)); memset(&gbl_args->tx_stats, 0, sizeof(gbl_args->tx_stats)); expected_tx_cnt = status->pps_curr * gbl_args->args.duration; /* start receiver threads first */ args_rx.batch_len = gbl_args->args.rx_batch_len; odph_linux_pthread_create(&thd_tbl[0], thd_mask_rx, run_thread_rx, &args_rx); odp_barrier_wait(&gbl_args->rx_barrier); num_rx_workers = odp_cpumask_count(thd_mask_rx); /* then start transmitters */ num_tx_workers = odp_cpumask_count(thd_mask_tx); args_tx.pps = status->pps_curr / num_tx_workers; args_tx.duration = gbl_args->args.duration; args_tx.batch_len = gbl_args->args.tx_batch_len; odph_linux_pthread_create(&thd_tbl[num_rx_workers], thd_mask_tx, run_thread_tx, &args_tx); odp_barrier_wait(&gbl_args->tx_barrier); /* wait for transmitter threads to terminate */ odph_linux_pthread_join(&thd_tbl[num_rx_workers], num_tx_workers); /* delay to allow transmitted packets to reach the receivers */ busy_loop_ns(SHUTDOWN_DELAY_NS); /* indicate to the receivers to exit */ odp_atomic_store_u32(&shutdown, 1); /* wait for receivers */ odph_linux_pthread_join(&thd_tbl[0], num_rx_workers); return process_results(expected_tx_cnt, status); }
void run_test(int threads, int n) { reset(); // Let my people go smp_store_release(&go, n+1); // Wait for everyone for (int i = 0; i < threads; i++) { while (!smp_load_acquire(&done[i])) ; smp_store_release(&done[i], false); } // Everyone done, process results. process_results(results); }
static VALUE dh_init(int argc, VALUE* argv, VALUE self) { VALUE db_user, db_pass, db_args, db_name, db_host, tds_socket; TDSSOCKET *tds; /* Let's fill our variables... */ rb_scan_args(argc, argv, "2*", &db_user, &db_pass, &db_args); db_args = rb_ary_shift(db_args); if(db_args != Qnil) { db_args = rb_str_split(db_args, ":"); db_name = rb_ary_entry(db_args, 0); db_host = rb_ary_entry(db_args, 1); } if(db_host == Qnil) { db_host = rb_str_new2("localhost"); } /* Get a TDSSOCKET */ tds_socket = tdss_new(db_host, db_user, db_pass); rb_iv_set(self, "@tds_socket", tds_socket); Data_Get_Struct(tds_socket, TDSSOCKET, tds); /* If the user submited a database-name, change to it */ if(db_name != Qnil) { if(tds_submit_query(tds,STR2CSTR(rb_str_concat(rb_str_new2("USE "), db_name))) != TDS_SUCCEED) { rb_raise(rb_eRuntimeError, "SQL-USE failed (1)"); } else { process_results(tds); } } return self; } // dh_init
static VALUE dh_do(VALUE self, VALUE sqlstring) { TDSSOCKET *tds; Data_Get_Struct(rb_iv_get(self, "@tds_socket"), TDSSOCKET, tds); if(tds_submit_query(tds,STR2CSTR(sqlstring)) != TDS_SUCCEED) { rb_raise(rb_eRuntimeError, "SQL-query failed (1)"); } else { process_results(tds); } return Qnil; } // dh_do
error_t finish_sequential_search( sequential_search_state_t* state, results_t* results, int64_t* counts, seq_search_match_keyvalue_t** matches, size_t* nmatches) { int j; error_t err; // Finish the results writers for all of the regular expression queries. // next, merge the results from the different queries... // finish the results writers and save the results. for( j = 0; j < state->n_regexps; j++ ) { err = results_writer_finish(&state->regexps[j]->results_writer, &state->regexps[j]->query.results); if( err ) return err; } // Now go through the query tree moving the results up it... for( j = 0; j < state->n_queries; j++ ) { err = process_results(state->queries[j]); // move the results to the output. results_move(&results[j], &state->queries[j]->results); // move the counts. counts[j] = state->queries[j]->count; // move the matches, if it's a regular expression query. if( state->queries[j]->type == SEQ_REGEXP ) { sequential_regexp_query_t* b = (sequential_regexp_query_t*) state->queries[j]; if( b->matches.num > 0 ) { size_t cur = 0; matches[j] = malloc(sizeof(seq_search_match_keyvalue_t) * b->matches.num); if( ! matches[j] ) return ERR_MEM; nmatches[j] = b->matches.num; // pull out all of the matches and free the keys and values. for( hash_t i = 0; i < b->matches.size; i++ ) { if( b->matches.map[i].key ) { matches[j][cur].key = b->matches.map[i].key; matches[j][cur].value = b->matches.map[i].value; cur++; } } } } } return ERR_NOERR; }
_Noreturn void* thread_start(void *ptr) { struct message msg = ((struct thread_param*) ptr)->msg; bool allowed = ((struct thread_param*) ptr)->allowed; long channel = msg.channel_request.pid; free(ptr); check_interrupted(); if(msg.channel_request.id > 0) { if(!allowed) refuse_connection(channel); else { accept_connection(channel); process_results(channel); } } else process_report(channel); exit_thread(); }
/** * This method allows to stop the client and to process the results. */ inline void stop() { LOG_INFO << "Stopping the " << m_name << " manager" << END_LOG; //Set the stopping flag m_is_stopping = true; //Wait until the request sending thread is stopped. if (m_sending_thread_ptr != NULL && m_sending_thread_ptr->joinable()) { LOG_DEBUG << "Joining the sending thread" << END_LOG; m_sending_thread_ptr->join(); } LOG_INFO << "Disconnecting the " << m_name << " client ... " << END_LOG; //Disconnect from the server if (m_client != NULL) { m_client->disconnect(); } LOG_INFO << "The " << m_name << " client is disconnected" << END_LOG; //Process the results process_results(); };
error_t process_results( sequential_query_t* q ) { error_t err; switch( q->type ) { case SEQ_BOOLEAN: { sequential_boolean_query_t* b = (sequential_boolean_query_t*) q; struct boolean_node* ast_node = (struct boolean_node*) q->ast_node; err = process_results(b->left); if( err ) return err; err = process_results(b->right); if( err ) return err; // now apply the appropriate Boolean operation. switch( ast_node->nodeType ) { case BOOL_AND: err = intersectResults(&b->left->results, &b->right->results, &b->query.results); break; case BOOL_OR: err = unionResults(&b->left->results, &b->right->results, &b->query.results); break; case BOOL_NOT: err = subtractResults(&b->left->results, &b->right->results, &b->query.results); break; case BOOL_THEN: err = thenResults(&b->left->results, &b->right->results, &b->query.results, ast_node->distance); break; case BOOL_WITHIN: err = withinResults(&b->left->results, &b->right->results, &b->query.results, ast_node->distance); break; default: err = ERR_INVALID_STR("Unknown AST node"); } if( err ) return err; // free up results from the tree... results_destroy(&b->left->results); results_destroy(&b->right->results); } break; case SEQ_REGEXP: // these already have results ready for us... // Don't need to do anything. break; } return ERR_NOERR; }
/** * Main program. */ void main(int argc, char** argv) { CHR_TEST_HANDLE testHandle; CHR_API_RC rc; int argNo; int loadTestEnabled = 0; /* Get command-line parameters. */ for (argNo = 1; argNo < argc; ++argNo) { const char* ap = argv[argNo]; if (strcmp(ap, "--load") == 0) loadTestEnabled = 1; else if (strcmp(ap, "--noload") == 0) loadTestEnabled = 0; else { printf("Unrecognized option: %s\n", ap); exit(EXIT_FAILURE); } } /* Initialize the Chariot API. */ printf("Initializing the API...\n"); initialize_api(); /* Create test object. */ rc = CHR_test_new(&testHandle); if (rc != CHR_OK) show_error(CHR_NULL_HANDLE, rc, "test_new"); if (loadTestEnabled) { /* Load results into test object. */ printf("Loading test results... (%s)\n", lc_testFile); rc = CHR_test_load( testHandle, lc_testFile, strlen(lc_testFile)); if (rc != CHR_OK) show_error(testHandle, rc, "test_load"); } else { /* Load network configuration. */ printf("Loading the configuration... (%s)\n", lc_configFile); rc = CHR_test_load_ixia_network_configuration( testHandle, lc_configFile, strlen(lc_configFile)); if (rc != CHR_OK) show_error(testHandle, rc, "test_load_ixia_network_configuration"); /* Create the test. */ printf("Building the test...\n"); build_test(testHandle); /* Save the test before running it. */ printf("Saving the test... (%s)\n", lc_testFile); rc = CHR_test_save(testHandle); if (rc != CHR_OK) show_error(testHandle, rc, "test_save"); /* Run the test. */ printf("Starting the test...\n"); run_test(testHandle); /* Save results of test. */ printf("Saving the results... (%s)\n", lc_testFile); rc = CHR_test_save(testHandle); if (rc != CHR_OK) show_error(testHandle, rc, "test_save"); } /* Process the results. */ printf("Processing the results...\n"); process_results(testHandle); /* We're finished! */ exit(EXIT_SUCCESS); } /* main */