void main_get_config() { memset(&g_config,0,sizeof(g_config)); get_config(&c); show_config(&c); }
/* * Test of set_config: * - name = test parameter name * - value = test value * - k = expected returned value * - error = expected error code (if k < 0) */ static void test_set_config(ctx_config_t *config, const char *name, const char *value, int32_t k, int32_t error) { int32_t code; error_code_t ecode; printf("Testing set_config %s := %s: ", name, value); fflush(stdout); code = yices_set_config(config, name, value); if (code >= 0) { printf("ok\n"); show_config(config); } else { printf("error\n"); yices_print_error(stdout); } if (code != k) { printf("TEST FAILED\n"); printf("--> Yices function returned %"PRId32"; %"PRId32" was expected\n", code, k); fflush(stdout); exit(1); } else if (k < 0) { ecode = yices_error_code(); if (ecode != error) { printf("TEST FAILED\n"); printf("--> Found error code %"PRId32"; %"PRId32" was expected\n", ecode, error); fflush(stdout); exit(1); } } printf("\n"); fflush(stdout); }
int libusb_show_device(uint16_t vendor_id, uint16_t product_id) { struct libusb_device_handle *handle; struct libusb_device_descriptor desc; struct libusb_config_descriptor **config; int ret = 0, i, config_size; handle = libusb_open_device_with_vid_pid(NULL, vendor_id, product_id); if (handle == NULL) return -EIO; ret = libusb_get_device_descriptor(handle->dev, &desc); if (ret < 0) return -EINVAL; printf("usb device has %d configurations \n", desc.bNumConfigurations); config_size = sizeof(struct libusb_config_descriptor *) * desc.bNumConfigurations; config = (struct libusb_config_descriptor **) malloc(config_size); for (i = 0; i < desc.bNumConfigurations; i++) { ret = libusb_get_config_descriptor(handle->dev, i, &config[i]); if (ret < 0) { free(config); return -EINVAL; } } for (i = 0; i < desc.bNumConfigurations; i++) { show_config(config[i], i); } }
static unsigned _action_cb(u32 button, unsigned flags, void *data) { (void)data; if(! GUI_GetSelected() || lp->selected_for_move < 0 || GUI_IsModal()) return 0; if(CHAN_ButtonIsPressed(button, BUT_EXIT)) { gui->elem[lp->selected_for_move].desc.font_color ^= 0xffff; gui->elem[lp->selected_for_move].desc.fill_color ^= 0xffff; GUI_Redraw((guiObject_t *)&gui->elem[lp->selected_for_move]); set_selected_for_move(-1); return 1; } if(CHAN_ButtonIsPressed(button, BUT_ENTER)) { show_config(); return 1; } if(CHAN_ButtonIsPressed(button, BUT_LEFT)) { xpos_cb(NULL, (flags & BUTTON_LONGPRESS) ? -2 : -1, NULL); return 1; } if(CHAN_ButtonIsPressed(button, BUT_RIGHT)) { xpos_cb(NULL, (flags & BUTTON_LONGPRESS) ? 2 : 1, NULL); return 1; } if(CHAN_ButtonIsPressed(button, BUT_UP)) { ypos_cb(NULL, (flags & BUTTON_LONGPRESS) ? -2 : -1, NULL); return 1; } if(CHAN_ButtonIsPressed(button, BUT_DOWN)) { ypos_cb(NULL, (flags & BUTTON_LONGPRESS) ? 2 : 1, NULL); return 1; } return 0; }
void PAGE_MainLayoutInit(int page) { (void)page; memset(lp, 0, sizeof(*lp)); BUTTON_RegisterCallback(&action, CHAN_ButtonMask(BUT_ENTER) | CHAN_ButtonMask(BUT_EXIT) | CHAN_ButtonMask(BUT_LEFT) | CHAN_ButtonMask(BUT_LEFT) | CHAN_ButtonMask(BUT_RIGHT) | CHAN_ButtonMask(BUT_UP) | CHAN_ButtonMask(BUT_DOWN), BUTTON_PRESS | BUTTON_LONGPRESS | BUTTON_PRIORITY, _action_cb, NULL); PAGE_ShowHeader(NULL); lp->long_press = 0; lp->newelem = 0; lp->selected_x = 0; const u16 color[5] = { RGB888_to_RGB565(0xaa, 0x44, 0x44), RGB888_to_RGB565(0x44, 0xaa, 0x44), RGB888_to_RGB565(0x44, 0x44, 0xaa), RGB888_to_RGB565(0x44, 0x44, 0x44), RGB888_to_RGB565(0x33, 0x33, 0x33), }; for (int i = 0 ; i < 5; i++) gui->desc[i] = (struct LabelDesc){ .font = 0, .font_color = 0xffff, .fill_color = color[i], .outline_color = 0, .style = LABEL_FILL}; gui->desc[1].font = TINY_FONT.font; //Special case for trims GUI_CreateIcon(&gui->newelem, 32, 0, &icons[ICON_LAYOUT_ADD], add_dlg_cb, NULL); GUI_CreateIcon(&gui->editelem, 64, 0, &icons[ICON_LAYOUT_CFG], cfg_cb, NULL); GUI_SetHidden((guiObject_t *)&gui->editelem, 1); //GUI_CreateTextSelect(&gui->newelem, 36, 12, TEXTSELECT_96, newelem_press_cb, newelem_cb, NULL); GUI_CreateLabel(&gui->xlbl, 80+18, 9, NULL, TITLE_FONT, "X"); GUI_CreateTextSelect(&gui->x, 88+18, 8, TEXTSELECT_64, NULL, xpos_cb, NULL); GUI_CreateLabel(&gui->ylbl, 164+16, 9, NULL, TITLE_FONT, "Y"); GUI_CreateTextSelect(&gui->y, 172+16, 8, TEXTSELECT_64, NULL, ypos_cb, NULL); GUI_SelectionNotify(notify_cb); draw_elements(); if (show_config_menu) { lp->selected_for_move = show_config_menu; show_config(); show_config_menu = 0; } } void PAGE_MainLayoutEvent() { } void PAGE_MainLayoutExit() { BUTTON_UnregisterCallback(&action); }
int main(int argc, char *argv[]) { show_banner(); std::cout << "VERSION " << VERSION << std::endl; std::cout << "started at " << timestamp_sql() << std::endl; std::cout << "reading config file from " << argv[1] << std::endl; read_config_file(argv[1],service_config); show_config(); try { if (argc <= 1) { std::cerr << "Usage: tcp_service <config_file>\n"; return EXIT_FAILURE; } db_ptr->set_hostname(service_config.dbhost_address.c_str()); db_ptr->set_username(service_config.dbuser.c_str()); db_ptr->set_password(service_config.dbpassword.c_str()); db_ptr->set_database(service_config.dbdatabase.c_str()); // for schema if(db_ptr->connect()) { std::cout << "connected to database " << db_ptr->get_database() << std::endl; }else { std::cout << "problems openning database " << db_ptr->get_database() << std::endl; exit(EXIT_FAILURE); } boost::asio::io_service io_service; server s(io_service, std::stoi(service_config.service_port,0,10)); s.set_query_begin(service_config.query_begin); s.set_query_end(service_config.query_end); /*boost::thread([](){ create_main_window(); });*/ io_service.run(); }catch (std::exception& e) { std::cerr << std::endl << "Exception: " << e.what() << "\n"; } return EXIT_SUCCESS; }
static void show_all_infos() { /* * show some useful info */ show_program_name(program_name); show_package_name(); show_version_info(); show_gtk_version_info(); show_config(); }
void PAGE_MainLayoutInit(int page) { (void)page; #if HAS_LAYOUT_EDITOR PAGE_ShowHeader(_tr_noop("Layout: Long-Press ENT")); PAGE_SetActionCB(_action_cb); #else PAGE_ShowHeader(PAGE_GetName(PAGEID_MAINCFG)); #endif memset(gui, 0, sizeof(*gui)); memset(lp, 0, sizeof(*lp)); show_config(); }
int configure(int argc, char **argv){ parse_cmdline(argc, argv); if(conf.help){ display_help(); return 1; } if(conf.version) display_version(); if(strcmp(conf.confile, "")!=0 && load_conf(conf.confile)) return 1; if(conf.config) show_config(); }
int main(void) { ctx_config_t *c1, *c2; yices_init(); c1 = yices_new_config(); printf("Allocated config %p\n", c1); show_config(c1); c2 = yices_new_config(); printf("Allocated config %p\n", c2); show_config(c2); test_logic_configs(c1); test_set_configs(c2); yices_free_config(c2); yices_free_config(c1); yices_exit(); printf("All tests succeeded\n"); return 0; }
static void dlgbut_cb(struct guiObject *obj, const void *data) { (void)obj; int idx = (long)data; int i; //Remove object int type = ELEM_TYPE(pc.elem[idx]); for(i = idx+1; i < NUM_ELEMS; i++) { if (! ELEM_USED(pc.elem[i])) break; pc.elem[i-1] = pc.elem[i]; } ELEM_SET_Y(pc.elem[i-1], 0); idx = MAINPAGE_FindNextElem(type, 0); set_selected_for_move(idx); //close the dialog and reopen with new elements show_config(); }
/** * parses command line arguments and assigns * values to run time variables. relies on GNU * getopts included with this distribution. */ void parse_cmdline( int argc, char *argv[] ) { int c = 0; int nhosts; while(( c = getopt_long( argc, argv, "VhvCDH:i", long_options, (int *)0)) != EOF ){ switch( c ){ case 'V': display_version( TRUE ); break; case 'h': display_help(); exit( EXIT_SUCCESS ); case 'v': my.verbose = TRUE; break; case 'C': my.config = TRUE; break; case 'D': my.debug = TRUE; break; case 'i': my.images = TRUE; break; case 'H': { int ll; if(!strchr(optarg,':')) joe_fatal("no ':' in http-header"); if((strlen(optarg) + strlen(my.extra) + 3) > 512) joe_fatal("too many headers"); strcat(my.extra,optarg); strcat(my.extra,"\015\012"); } break; } /** end of switch( c ) **/ } /** end of while c = getopt_long **/ nhosts = argc - optind; if( my.config ){ show_config( TRUE ); } if( !nhosts ) { display_help( TRUE ); } else{ my.url = strdup( argv[argc-1] ); } } /* end of parse_cmdline */
/** * scout main */ int main( int argc, char *argv[] ) { int x, result; /* index, func. result*/ struct sigaction action; CLIENT *client; /* defined in setup.h */ init_config(); /* defined in init.h */ parse_cmdline(argc, argv); /* defined above */ if( my.config ){ /* see: init.h */ show_config( TRUE ); } memset( &action, 0, sizeof( action )); action.sa_handler = signal_handler; if( sigaction( SIGHUP, &action, NULL )) joe_error( "sigaction" ); if( sigaction( SIGINT, &action, NULL)) joe_error( "sigaction" ); if( sigaction( SIGTERM, &action, NULL)) joe_error( "sigaction" ); /* cookie is an EXTERN, defined in setup */ cookie = (COOKIE*)malloc( sizeof(COOKIE)); if( !cookie ){ joe_fatal( "memory exhausted" ); } cookie->first = NULL; client = (CLIENT*)malloc(sizeof(CLIENT)); if( !client ){ joe_fatal( "application memory exhausted" ); } http_client( client ); write_queue( my.showcodes ); /** * exit program. */ exit( EXIT_SUCCESS ); } /* end of int main **/
int recv_func(char *buf, int *size) { struct msg_st *rmsg = (struct msg_st *)buf; switch (rmsg->d.type) { case MSG_RSP_GET_CFG: show_config(rmsg); break; case MSG_RSP_GET_SE433L: show_se433_list(rmsg); break; case MSG_RSP_END: show_resp(rmsg); break; default: printf("Unknown MSG command %ld", rmsg->d.type); break; } return 0; }
static void cfg_cb(guiObject_t *obj, const void *data) { (void)obj; (void)data; show_config(); }
static void _proc_msg(int new_fd, char *msg, slurm_addr_t cli_addr) { /* Locks: Read job and node data */ slurmctld_lock_t job_read_lock = { NO_LOCK, READ_LOCK, READ_LOCK, NO_LOCK, NO_LOCK }; /* Locks: Write job */ slurmctld_lock_t job_write_lock = { NO_LOCK, WRITE_LOCK, NO_LOCK, NO_LOCK, NO_LOCK }; /* Locks: Write job, write node, read partition */ slurmctld_lock_t job_write_lock2 = { NO_LOCK, WRITE_LOCK, WRITE_LOCK, READ_LOCK, READ_LOCK }; /* Locks: Write node data */ slurmctld_lock_t node_write_lock = { NO_LOCK, NO_LOCK, WRITE_LOCK, NO_LOCK, READ_LOCK }; char *cmd_ptr, *resp = NULL, *msg_decrypted = NULL; uid_t cmd_uid; uint32_t protocol_version = 0; if (!msg) { info("slurmctld/nonstop: NULL message received"); resp = xstrdup("Error:\"NULL message received\""); goto send_resp; } msg_decrypted = _decrypt(msg, &cmd_uid); if (!msg_decrypted) { info("slurmctld/nonstop: Message decrypt failure"); resp = xstrdup("Error:\"Message decrypt failure\""); goto send_resp; } if (nonstop_debug > 0) info("slurmctld/nonstop: msg decrypted:%s", msg_decrypted); cmd_ptr = msg_decrypted; /* 123456789012345678901234567890 */ if (xstrncmp(cmd_ptr, version_string, 13) == 0) { cmd_ptr = strchr(cmd_ptr + 13, ':'); if (cmd_ptr) { cmd_ptr++; protocol_version = SLURM_PROTOCOL_VERSION; } } if (protocol_version == 0) { info("slurmctld/nonstop: Message version invalid"); resp = xstrdup("Error:\"Message version invalid\""); goto send_resp; } if (xstrncmp(cmd_ptr, "CALLBACK:JOBID:", 15) == 0) { resp = register_callback(cmd_ptr, cmd_uid, cli_addr, protocol_version); } else if (xstrncmp(cmd_ptr, "DRAIN:NODES:", 12) == 0) { lock_slurmctld(node_write_lock); resp = drain_nodes_user(cmd_ptr, cmd_uid, protocol_version); unlock_slurmctld(node_write_lock); } else if (xstrncmp(cmd_ptr, "DROP_NODE:JOBID:", 15) == 0) { lock_slurmctld(job_write_lock2); resp = drop_node(cmd_ptr, cmd_uid, protocol_version); unlock_slurmctld(job_write_lock2); } else if (xstrncmp(cmd_ptr, "GET_FAIL_NODES:JOBID:", 21) == 0) { lock_slurmctld(job_read_lock); resp = fail_nodes(cmd_ptr, cmd_uid, protocol_version); unlock_slurmctld(job_read_lock); } else if (xstrncmp(cmd_ptr, "REPLACE_NODE:JOBID:", 19) == 0) { lock_slurmctld(job_write_lock2); resp = replace_node(cmd_ptr, cmd_uid, protocol_version); unlock_slurmctld(job_write_lock2); } else if (xstrncmp(cmd_ptr, "SHOW_CONFIG", 11) == 0) { resp = show_config(cmd_ptr, cmd_uid, protocol_version); } else if (xstrncmp(cmd_ptr, "SHOW_JOB:JOBID:", 15) == 0) { resp = show_job(cmd_ptr, cmd_uid, protocol_version); } else if (xstrncmp(cmd_ptr, "TIME_INCR:JOBID:", 16) == 0) { lock_slurmctld(job_write_lock); resp = time_incr(cmd_ptr, cmd_uid, protocol_version); unlock_slurmctld(job_write_lock); } else { info("slurmctld/nonstop: Invalid command: %s", cmd_ptr); xstrfmtcat(resp, "%s ECMD", SLURM_VERSION_STRING); } send_resp: if (nonstop_debug > 0) info("slurmctld/nonstop: msg send:%s", resp); _send_reply(new_fd, resp); xfree(resp); if (msg_decrypted) free(msg_decrypted); return; }
static void parse_conf() { FILE *fp; int len; unsigned int tmp = 0; int finished = 0; char conf_line[2048] = ""; char service_tag[1024]; char *p, *q; if (snprintf(service_tag, 1024, "[%s]", service) < 0) return; if ((fp = fopen(conf_path, "r")) == NULL) { write_log(fdlogwf, WARNING, "Cannot open config file. ", "Old configurations unchanged.", "\n"); return; } alarm_interval = 2; bzero(alarm_mail, sizeof(alarm_mail)); bzero(alarm_gsm, sizeof(alarm_gsm)); max_tries = 20; max_tries_if_coredumped = 5; gsm_list_len = 0; while (fgets(conf_line, 2048, fp) != NULL) { if (strncmp(conf_line, "[global]", strlen("[global]")) == 0) break; if (strncmp(conf_line, service_tag, strlen(service_tag)) == 0) { finished = 1; break; } } while (fgets(conf_line, 2048, fp) != NULL && conf_line[0] != '[') { p = conf_line + strlen(conf_line) - 1; while (*p == '\n' || isspace(*p)) { *p = '\0'; p--; } if (strncmp(conf_line, "alarm_mail", strlen("alarm_mail")) == 0) { p = conf_line + strlen("alarm_mail"); while (*p && isspace(*p)) p++; if (*p++ != ':') continue; while (*p && isspace(*p)) p++; if (*p) strncpy(alarm_mail, p, 1024); continue; } if (strncmp(conf_line, "alarm_gsm", strlen("alarm_gsm")) == 0) { p = conf_line + strlen("alarm_gsm"); while (*p && isspace(*p)) p++; if (*p++ != ':') continue; while (*p && isspace(*p)) p++; if (!p) continue; len = strlen(p); q = p; while (*q) { if (isspace(*q)) *q = '\0'; q++; } while (len > 0 && gsm_list_len < 10) { if (!(*p)) { p++; len--; continue; } strncpy(alarm_gsm[gsm_list_len], p, 1024 - 1); len -= strlen(alarm_gsm[gsm_list_len]); p += strlen(alarm_gsm[gsm_list_len]); gsm_list_len++; } continue; } if (strncmp(conf_line, "max_tries_if_coredumped", strlen("max_tries_if_coredumped")) == 0) { sscanf(conf_line, "max_tries_if_coredumped : %u", &max_tries_if_coredumped); continue; } if (strncmp(conf_line, "max_tries", strlen("max_tries")) == 0) { sscanf(conf_line, "max_tries : %u", &max_tries); continue; } if (strncmp(conf_line, "alarm_interval", strlen("alarm_interval")) == 0) { sscanf(conf_line, "alarm_interval : %u", &alarm_interval); if (alarm_interval > 0 && alarm_interval < 60) alarm_interval = 60; continue; } } if (finished) { fclose(fp); write_log(fdlog, NOTICE, "Finished loading configurations!\n", "", ""); show_config(); return; } while (strncmp(conf_line, service_tag, strlen(service_tag)) != 0 && fgets(conf_line, 2048, fp) != NULL) ; while (fgets(conf_line, 2048, fp) != NULL && conf_line[0] != '[') { p = conf_line + strlen(conf_line) - 1; while (*p == '\n' || isspace(*p)) { *p = 0; p--; } if (strncmp(conf_line, "alarm_mail", strlen("alarm_mail")) == 0) { p = conf_line + strlen("alarm_mail"); while (*p && isspace(*p)) p++; if (*p++ != ':') continue; while (*p && isspace(*p)) p++; if (*p) snprintf(alarm_mail + strlen(alarm_mail), 1024 - strlen(alarm_mail), " %s", p); continue; } if (strncmp(conf_line, "alarm_gsm", strlen("alarm_gsm")) == 0) { p = conf_line + strlen("alarm_gsm"); while (*p && isspace(*p)) p++; if (*p++ != ':') continue; while (*p && isspace(*p)) p++; if (!p) continue; len = strlen(p); q = p; while (*q) { if (isspace(*q)) *q = '\0'; q++; } while (len > 0 && gsm_list_len < 10) { if (!(*p)) { p++; len--; continue; } strncpy(alarm_gsm[gsm_list_len], p, 1024 - 1); len -= strlen(alarm_gsm[gsm_list_len]); p += strlen(alarm_gsm[gsm_list_len]); gsm_list_len++; } continue; } tmp = 0; if (strncmp(conf_line, "max_tries_if_coredumped", strlen("max_tries_if_coredumped")) == 0) { sscanf(conf_line, "max_tries_if_coredumped : %u", &tmp); if (tmp > 0) max_tries_if_coredumped = tmp; continue; } if (strncmp(conf_line, "max_tries", strlen("max_tries")) == 0) { sscanf(conf_line, "max_tries : %u", &tmp); if (tmp > 0) max_tries = tmp; continue; } if (strncmp(conf_line, "alarm_interval", strlen("alarm_interval")) == 0) { sscanf(conf_line, "alarm_interval : %u", &tmp); if (tmp > 0) alarm_interval = tmp; if (alarm_interval > 0 && alarm_interval < 60) alarm_interval = 60; continue; } } fclose(fp); write_log(fdlog, NOTICE, "Finished loading configurations!\n", "", ""); show_config(); }
int main(int argc, char *argv[]) { int x; int result; DATA D = new_data(); ARRAY urls = new_array(); CREW crew; LINES *lines; CLIENT *client; pthread_t cease; pthread_t timer; pthread_attr_t scope_attr; void *statusp; sigset_t sigs; sigemptyset(&sigs); sigaddset(&sigs, SIGHUP); sigaddset(&sigs, SIGINT); sigaddset(&sigs, SIGALRM); sigaddset(&sigs, SIGTERM); sigprocmask(SIG_BLOCK, &sigs, NULL); lines = xcalloc(1, sizeof *lines); lines->index = 0; lines->line = NULL; memset(&my, 0, sizeof(struct CONFIG)); parse_rc_cmdline(argc, argv); if (init_config() < 0) { /* defined in init.h */ exit( EXIT_FAILURE ); /* polly was a girl... */ } parse_cmdline(argc, argv); /* defined above */ ds_module_check(); /* check config integ */ /** * XXX: we should consider moving the following * if-checks into the ds_module_check */ if (my.config) { show_config(TRUE); } if (my.url != NULL) { my.length = 1; } else { my.length = read_cfg_file(lines, my.file); } if (my.reps < 0) { my.reps = my.length; } if (my.length == 0) { display_help(); } /* cookie is an EXTERN, defined in setup */ cookie = xcalloc(sizeof(COOKIE), 1); cookie->first = NULL; if ((result = pthread_mutex_init( &(cookie->mutex), NULL)) !=0) { NOTIFY(FATAL, "pthread_mutex_init" ); } /* memory allocation for threads and clients */ client = xcalloc(my.cusers, sizeof(CLIENT)); if ((crew = new_crew(my.cusers, my.cusers, FALSE)) == NULL) { NOTIFY(FATAL, "unable to allocate memory for %d simulated browser", my.cusers); } /** * determine the source of the url(s), * command line or file, and add them * to the urls struct. */ if (my.url != NULL) { URL tmp = new_url(my.url); url_set_ID(tmp, 0); if (my.get && url_get_method(tmp) != POST && url_get_method(tmp) != PUT) { url_set_method(tmp, my.method); } array_npush(urls, tmp, URLSIZE); // from cmd line } else { for (x = 0; x < my.length; x++) { URL tmp = new_url(lines->line[x]); url_set_ID(tmp, x); array_npush(urls, tmp, URLSIZE); } } /** * display information about the siege * to the user and prepare for verbose * output if necessary. */ if (!my.get && !my.quiet) { fprintf(stderr, "** "); display_version(FALSE); fprintf(stderr, "** Preparing %d concurrent users for battle.\n", my.cusers); fprintf(stderr, "The server is now under siege..."); if (my.verbose) { fprintf(stderr, "\n"); } } /** * record start time before spawning threads * as the threads begin hitting the server as * soon as they are created. */ data_set_start(D); /** * for each concurrent user, spawn a thread and * loop until condition or pthread_cancel from the * handler thread. */ pthread_attr_init(&scope_attr); pthread_attr_setscope(&scope_attr, PTHREAD_SCOPE_SYSTEM); #if defined(_AIX) /* AIX, for whatever reason, defies the pthreads standard and * * creates threads detached by default. (see pthread.h on AIX) */ pthread_attr_setdetachstate(&scope_attr, PTHREAD_CREATE_JOINABLE); #endif /** * invoke OpenSSL's thread safety */ #ifdef HAVE_SSL SSL_thread_setup(); #endif /** * create the signal handler and timer; the * signal handler thread (cease) responds to * ctrl-C (sigterm) and the timer thread sends * sigterm to cease on time out. */ if ((result = pthread_create(&cease, NULL, (void*)sig_handler, (void*)crew)) < 0) { NOTIFY(FATAL, "failed to create handler: %d\n", result); } if (my.secs > 0) { if ((result = pthread_create(&timer, NULL, (void*)siege_timer, (void*)cease)) < 0) { NOTIFY(FATAL, "failed to create handler: %d\n", result); } } /** * loop until my.cusers and create a corresponding thread... */ for (x = 0; x < my.cusers && crew_get_shutdown(crew) != TRUE; x++) { client[x].id = x; client[x].bytes = 0; client[x].time = 0.0; client[x].hits = 0; client[x].code = 0; client[x].ok200 = 0; client[x].fail = 0; client[x].urls = urls; client[x].auth.www = 0; client[x].auth.proxy = 0; client[x].auth.type.www = BASIC; client[x].auth.type.proxy = BASIC; client[x].rand_r_SEED = urandom(); result = crew_add(crew, (void*)start_routine, &(client[x])); if (result == FALSE) { my.verbose = FALSE; fprintf(stderr, "Unable to spawn additional threads; you may need to\n"); fprintf(stderr, "upgrade your libraries or tune your system in order\n"); fprintf(stderr, "to exceed %d users.\n", my.cusers); NOTIFY(FATAL, "system resources exhausted"); } } /* end of for pthread_create */ crew_join(crew, TRUE, &statusp); #ifdef HAVE_SSL SSL_thread_cleanup(); #endif /** * collect all the data from all the threads that * were spawned by the run. */ for (x = 0; x < ((crew_get_total(crew) > my.cusers || crew_get_total(crew)==0 ) ? my.cusers : crew_get_total(crew)); x++) { data_increment_count(D, client[x].hits); data_increment_bytes(D, client[x].bytes); data_increment_total(D, client[x].time); data_increment_code (D, client[x].code); data_increment_ok200(D, client[x].ok200); data_increment_fail (D, client[x].fail); data_set_highest (D, client[x].himark); data_set_lowest (D, client[x].lomark); client[x].rand_r_SEED = urandom(); } /* end of stats accumulation */ /** * record stop time */ data_set_stop(D); /** * cleanup crew */ crew_destroy(crew); for (x = 0; x < my.cusers; x++) { // XXX: TODO //digest_challenge_destroy(client[x].auth.wwwchlg); //digest_credential_destroy(client[x].auth.wwwcred); //digest_challenge_destroy(client[x].auth.proxychlg); //digest_credential_destroy(client[x].auth.proxycred); } array_destroy(my.lurl); xfree(client); if (my.get) { if (data_get_ok200(D) > 0) { exit(EXIT_SUCCESS); } else { if (!my.quiet) echo("[done]\n"); exit(EXIT_FAILURE); } } /** * take a short nap for cosmetic effect * this does NOT affect performance stats. */ pthread_usleep_np(10000); if (my.verbose) fprintf(stderr, "done.\n"); else fprintf(stderr, "\b done.\n"); /** * prepare and print statistics. */ if (my.failures > 0 && my.failed >= my.failures) { fprintf(stderr, "%s aborted due to excessive socket failure; you\n", program_name); fprintf(stderr, "can change the failure threshold in $HOME/.%src\n", program_name); } fprintf(stderr, "\nTransactions:\t\t%12u hits\n", data_get_count(D)); fprintf(stderr, "Availability:\t\t%12.2f %%\n", data_get_count(D)==0 ? 0 : (double)data_get_count(D) / (data_get_count(D)+my.failed) *100 ); fprintf(stderr, "Elapsed time:\t\t%12.2f secs\n", data_get_elapsed(D)); fprintf(stderr, "Data transferred:\t%12.2f MB\n", data_get_megabytes(D)); /*%12llu*/ fprintf(stderr, "Response time:\t\t%12.3f secs\n", data_get_response_time(D)); fprintf(stderr, "Transaction rate:\t%12.2f trans/sec\n", data_get_transaction_rate(D)); fprintf(stderr, "Throughput:\t\t%12.2f MB/sec\n", data_get_throughput(D)); fprintf(stderr, "Concurrency:\t\t%12.2f\n", data_get_concurrency(D)); fprintf(stderr, "Successful transactions:%12u\n", data_get_code(D)); if (my.debug) { fprintf(stderr, "HTTP OK received:\t%12u\n", data_get_ok200(D)); } fprintf(stderr, "Failed transactions:\t%12u\n", my.failed); fprintf(stderr, "Longest transaction:\t%12.3f\n", data_get_highest(D)); fprintf(stderr, "Shortest transaction:\t%12.3f\n", data_get_lowest(D)); fprintf(stderr, " \n"); if(my.mark) mark_log_file(my.markstr); if(my.logging) log_transaction(D); data_destroy(D); if (my.url == NULL) { for (x = 0; x < my.length; x++) xfree(lines->line[x]); xfree(lines->line); xfree(lines); } else { xfree(lines->line); xfree(lines); } pthread_mutex_destroy( &(cookie->mutex)); /** * I should probably take a deeper look * at cookie content to free it but at * this point we're two lines from exit */ xfree (cookie); xfree (my.url); exit(EXIT_SUCCESS); } /* end of int main **/
void maintainr_projectbox_set_editing_mode (MaintainrProjectbox *box) { show_config (box); }