// // initialize // void do_init(int pv_argc, char **ppp_argv) { char *lp_arg; int lv_arg; bool lv_attach; int lv_ferr; char *lv_delay_s; lv_attach = false; for (lv_arg = 1; lv_arg < pv_argc; lv_arg++) { lp_arg = ppp_argv[lv_arg]; if (strcmp(lp_arg, "-attach") == 0) lv_attach = true; else if (strcmp(lp_arg, "-shook") == 0) gv_shook = true; else if (strcmp(lp_arg, "-v") == 0) gv_verbose = true; } if (lv_attach) lv_ferr = msg_init_attach(&pv_argc, &ppp_argv, false, (char *) "$TSID0"); else lv_ferr = msg_init(&pv_argc, &ppp_argv); assert(lv_ferr == XZFIL_ERR_OK); gv_time_refresh_delay = 200; // 2 seconds lv_delay_s = getenv("TM_IDTMSRV_REFRESH_DELAY_SECONDS"); if (lv_delay_s != NULL) { gv_time_refresh_delay = 100 * (atoi(lv_delay_s)); } if (gv_verbose){ printf("TM_IDTMSRV_REFRESH_DELAY_SECONDS is %s. Setting gv_time_refresh_delay to %d \n", lv_delay_s, gv_time_refresh_delay); } if (gv_shook) msg_debug_hook("s", "s"); }
// // initialize // void do_init(int argc, char **argv) { int arg; char *argp; bool attach; int ferr; attach = false; for (arg = 1; arg < argc; arg++) { argp = argv[arg]; if (strcmp(argp, "-attach") == 0) attach = true; else if (strcmp(argp, "-shook") == 0) shook = true; else if (strcmp(argp, "-v") == 0) verbose = true; } if (attach) ferr = msg_init_attach(&argc, &argv, false, (char *) "$TSID0"); else ferr = msg_init(&argc, &argv); assert(ferr == XZFIL_ERR_OK); if (shook) msg_debug_hook("s", "s"); }
// // initialize // void do_init(int pv_argc, char **ppp_argv) { char *lp_arg; int lv_arg; bool lv_attach; int lv_ferr; lv_attach = false; for (lv_arg = 1; lv_arg < pv_argc; lv_arg++) { lp_arg = ppp_argv[lv_arg]; if (strcmp(lp_arg, "-attach") == 0) lv_attach = true; else if (strcmp(lp_arg, "-shook") == 0) gv_shook = true; else if (strcmp(lp_arg, "-v") == 0) gv_verbose = true; } if (lv_attach) lv_ferr = msg_init_attach(&pv_argc, &ppp_argv, false, (char *) "$TSID0"); else lv_ferr = msg_init(&pv_argc, &ppp_argv); assert(lv_ferr == XZFIL_ERR_OK); if (gv_shook) msg_debug_hook("s", "s"); }
// // initialize. // // if first call, attach and startup. // open server. // // return file error. // static int do_init(JNIEnv *j_env) { int argc; char *argv[1]; int ferr; int perr; perr = pthread_mutex_lock(&mutex); assert(perr == 0); if (inited) ferr = XZFIL_ERR_OK; else { do_reg_hash_cb(NULL); // ref to make cmplr happy argc = 0; argv[0] = NULL; inited = true; try { ferr = msg_init_attach(&argc, (char ***) &argv, 0, NULL); } catch (SB_Fatal_Excep &fatal_exc) { if (verbose) printf("cli: msg_init_attach threw exc=%s, setting PATHDOWN\n", fatal_exc.what()); ferr = XZFIL_ERR_PATHDOWN; } catch (...) { if (verbose) printf("cli: msg_init_attach threw unknown exc, setting PATHDOWN\n"); ferr = XZFIL_ERR_PATHDOWN; } if (ferr == XZFIL_ERR_OK) { try { ferr = msg_mon_process_startup(false); } catch (SB_Fatal_Excep &fatal_exc) { if (verbose) printf("cli: msg_mon_process_startup threw exc=%s, setting PATHDOWN\n", fatal_exc.what()); ferr = XZFIL_ERR_PATHDOWN; } catch (...) { if (verbose) printf("cli: msg_mon_process_startup threw unknown exc, setting PATHDOWN\n"); ferr = XZFIL_ERR_PATHDOWN; } } } if (ferr == XZFIL_ERR_OK) { if (oid < 0) { ferr = do_cli_open(j_env, &phandle, &oid); if (verbose) printf("cli: open-err=%d\n", ferr); } } perr = pthread_mutex_unlock(&mutex); assert(perr == 0); return ferr; }
// ---------------------------------------------------------------------------- // // main - simpy attach to the seaquest env and initialize // // ---------------------------------------------------------------------------- int main(int pv_argc, char *pa_argv[]) { CALL_COMP_DOVERS(sp_wrapper, pv_argc, pa_argv); int error = msg_init_attach (&pv_argc, &pa_argv, false, NULL); if (!error) { error = msg_mon_process_startup2(false, false); // client sp_initialize(pv_argc, pa_argv ); } msg_mon_process_shutdown(); }
int main(int argc, char *argv[]) { int arg; char *argvn[100]; char argvna[100][200]; bool chook = false; bool client = false; int ferr; int linx; int loop = 1; char name[20]; int pid; bool server0 = false; bool server1 = false; bool server2 = false; char *server_name = (char *) "$SRV"; bool shook = false; int status; bool strace = false; struct timeval t_elapsed; struct timeval t_start; struct timeval t_stop; bool test[] = { true, true, true }; bool test0 = false; bool test1 = false; bool test2 = false; int tinx; int uerr; bool verbose = false; const char *who; TAD zargs[] = { { "-chook", TA_Bool, TA_NOMAX, &chook }, { "-client", TA_Bool, TA_NOMAX, &client }, { "-loop", TA_Int, TA_NOMAX, &loop }, { "-server", TA_Ign, TA_NOMAX, NULL }, { "-server0", TA_Bool, TA_NOMAX, &server0 }, { "-server1", TA_Bool, TA_NOMAX, &server1 }, { "-server2", TA_Bool, TA_NOMAX, &server2 }, { "-shook", TA_Bool, TA_NOMAX, &shook }, { "-strace", TA_Bool, TA_NOMAX, &strace }, { "-test0", TA_Bool, TA_NOMAX, &test0 }, { "-test1", TA_Bool, TA_NOMAX, &test1 }, { "-test2", TA_Bool, TA_NOMAX, &test2 }, { "-v", TA_Bool, TA_NOMAX, &verbose }, { "", TA_End, TA_NOMAX, NULL } }; arg_proc_args(zargs, false, argc, argv); if (test0) { test[0] = true; test[1] = false; test[2] = false; } else if (test1) { test[0] = false; test[1] = true; test[2] = false; } else if (test2) { test[0] = false; test[1] = false; test[2] = true; } if (client) who = "cli"; else if (server0) who = "srv0"; else if (server1) who = "srv1"; else who = "srv2"; if (verbose) for (arg = 0; arg < argc; arg++) printf("%s: argv[%d]=%s\n", who, arg, argv[arg]); if (chook && client) test_debug_hook("c", "c"); if (shook && !client) test_debug_hook("s", "s"); if (client) { if (verbose) printf("%s: about to msg_init\n", who); ferr = msg_init(&argc, &argv); TEST_CHK_FEOK(ferr); } else if (server0) { if (verbose) printf("%s: about to msg_init_attach\n", who); ferr = msg_init_attach(&argc, &argv, false, server_name); TEST_CHK_FEOK(ferr); } else if (server1) { if (verbose) printf("%s: about to msg_init_attach\n", who); ferr = msg_test_enable_client_only(); TEST_CHK_FEOK(ferr); ferr = msg_init_attach(&argc, &argv, false, server_name); TEST_CHK_FEOK(ferr); } if (client) util_test_start(client); if (verbose) printf("%s: about to msg_mon_process_startup\n", who); if (client || server0 || server1) { ferr = msg_mon_process_startup(!client); // system messages TEST_CHK_FEOK(ferr); } if (client) { for (linx = 0; linx < loop; linx++) { for (tinx = 0; tinx < 3; tinx++) { if (!test[tinx]) continue; for (arg = 0; arg < argc; arg++) { if (strcmp(argv[arg], "-client") == 0) { // start_process sprintf(argvna[arg], "-server%d", tinx); argvn[arg] = argvna[arg]; } else argvn[arg] = argv[arg]; } argvn[arg] = NULL; if (strace) { sprintf(argvna[0], "xt172ms%d", tinx); argvn[0] = argvna[0]; } if (verbose) printf("%s: about to fork-exec\n", who); util_time_timer_start(&t_start); pid = fork(); switch (pid) { case 0: // child uerr = execvp(argvn[0], argvn); if (uerr == -1) perror("execvp"); exit(0); case -1: // parent perror("fork"); exit(1); default: // parent while (wait(&status) != pid) ; util_time_timer_stop(&t_stop); util_time_elapsed(&t_start, &t_stop, &t_elapsed); sprintf(name, " server%d", tinx); print_elapsed(name, &t_elapsed); } TEST_CHK_FEOK(ferr); } } } if (client || server0 || server1) { if (verbose) printf("%s: about to msg_mon_process_shutdown\n", who); ferr = msg_mon_process_shutdown(); TEST_CHK_FEOK(ferr); } if (client) { util_test_finish(client); util_time_timer_stop(&t_stop); util_time_elapsed(&t_start, &t_stop, &t_elapsed); print_elapsed(" client", &t_elapsed); } if (verbose) printf("%s: about to exit main\n", who); return 0; }
int main(int argc, char *argv[]) { bool chook = false; bool client = false; FILE *f; bool fail = false; int ferr; int lerr; int msgid; int oid; TPT_DECL (phandle); MS_Result_Type results; MS_SRE sre; TAD zargs[] = { { "-chook", TA_Bool, TA_NOMAX, &chook }, { "-client", TA_Bool, TA_NOMAX, &client }, { "-cluster", TA_Ign, TA_NOMAX, NULL }, { "-fail", TA_Bool, TA_NOMAX, &fail }, { "-verbose", TA_Ign, TA_NOMAX, NULL }, { "", TA_End, TA_NOMAX, NULL } }; arg_proc_args(zargs, false, argc, argv); if (chook) test_debug_hook("c", "c"); util_test_start(true); if (client) { f = NULL; while (f == NULL) { f = fopen("z100", "r"); if (f == NULL) sleep(1); } fclose(f); } if (client) ferr = msg_init_attach(&argc, &argv, true, (char *) "$CLI"); else ferr = msg_init(&argc, &argv); TEST_CHK_FEOK(ferr); ferr = msg_mon_process_startup(!client); // system messages TEST_CHK_FEOK(ferr); if (client) { ferr = msg_mon_open_process((char *) "$SRV", TPT_REF(phandle), &oid); TEST_CHK_FEOK(ferr); if (fail) util_abort_core_free(); ferr = XMSG_LINK_(TPT_REF(phandle), // phandle &msgid, // msgid NULL, // reqctrl 0, // reqctrlsize recv_buffer3, // replyctrl 0, // replyctrlmax NULL, // reqdata 0, // reqdatasize recv_buffer, // replydata 0, // replydatamax 0, // linkertag 0, // pri 0, // xmitclass 0); // linkopts TEST_CHK_FEOK(ferr); ferr = XMSG_BREAK_(msgid, (short *) &results, TPT_REF(phandle)); TEST_CHK_FEOK(ferr); } else { f = fopen("z100", "w"); assert(f != NULL); fclose(f); for (;;) { do { lerr = XWAIT(LREQ, 20); TEST_CHK_WAITIGNORE(lerr); if (!lerr) continue; lerr = XMSG_LISTEN_((short *) &sre, // sre 0, // listenopts 0); // listenertag } while (lerr == XSRETYPE_NOWORK); if (sre.sre_flags & XSRE_MON) printf("server received mon message\n"); else printf("server received regular message\n"); XMSG_REPLY_(sre.sre_msgId, // msgid recv_buffer2, // replyctrl 0, // replyctrlsize recv_buffer, // replydata 0, // replydatasize 0, // errorclass NULL); // newphandle if ((sre.sre_flags & XSRE_MON) == 0) break; } } ferr = msg_mon_process_shutdown(); TEST_CHK_FEOK(ferr); util_test_finish(true); return 0; }
// // initialize. // // if first call, attach and startup. // open server. // // return file error. // static int do_init(JNIEnv *pp_j_env) { char *la_argv[1]; int lv_argc; int lv_ferr; int lv_perr; if (gv_verbose) printf("cli: do_init start\n"); lv_perr = pthread_mutex_lock(&gv_mutex); assert(lv_perr == 0); if (gv_inited) lv_ferr = XZFIL_ERR_OK; else { do_reg_hash_cb(NULL); // ref to make cmplr happy lv_argc = 0; la_argv[0] = NULL; gv_inited = true; try { lv_ferr = msg_init_attach(&lv_argc, (char ***) &la_argv, 0, NULL); if (gv_verbose) printf("cli: msg_init_attach ferr=%d\n", lv_ferr); } catch (SB_Fatal_Excep &fatal_exc) { if (gv_verbose) printf("cli: msg_init_attach threw exc=%s, setting PATHDOWN\n", fatal_exc.what()); lv_ferr = XZFIL_ERR_PATHDOWN; } catch (...) { if (gv_verbose) printf("cli: msg_init_attach threw unknown exc, setting PATHDOWN\n"); lv_ferr = XZFIL_ERR_PATHDOWN; } if (lv_ferr == XZFIL_ERR_OK) { try { lv_ferr = msg_mon_process_startup4(false, true, true); } catch (SB_Fatal_Excep &fatal_exc) { if (gv_verbose) printf("cli: msg_mon_process_startup threw exc=%s, setting PATHDOWN\n", fatal_exc.what()); lv_ferr = XZFIL_ERR_PATHDOWN; } catch (...) { if (gv_verbose) printf("cli: msg_mon_process_startup threw unknown exc, setting PATHDOWN\n"); lv_ferr = XZFIL_ERR_PATHDOWN; } } else if (lv_ferr == XZFIL_ERR_INVALIDSTATE) { // attach failed, already initialized, clear error lv_ferr = XZFIL_ERR_OK; } } if (lv_ferr == XZFIL_ERR_OK) { if (gv_oid < 0) { lv_ferr = do_cli_open(pp_j_env, &gv_phandle, &gv_oid); if (gv_verbose) printf("cli: open-err=%d\n", lv_ferr); } } lv_perr = pthread_mutex_unlock(&gv_mutex); assert(lv_perr == 0); if (gv_verbose) printf("cli: do_init end ferr=%d\n", lv_ferr); return lv_ferr; }