//--------------------------------------------------------------------------// // wait for reconfiguration or termination request // //--------------------------------------------------------------------------// void _WaitSignalThread(void *unused) { // Capture all ereport() calls on this thread HANDLE hMsgPipe = INVALID_HANDLE_VALUE; ereport_register_thread_cb(&ereport_configuration_callback, &hMsgPipe); DWORD dwWait; while (TRUE) { dwWait = WaitForMultipleObjects(NUM_WS_EVENTS, phEvents, FALSE, INFINITE); if ((dwWait - WAIT_OBJECT_0) == WS_RECONFIG) { ResetEvent(phEvents[WS_RECONFIG]); hMsgPipe = admin_connect(); PRStatus status = WebServer::Reconfigure(); if (hMsgPipe != INVALID_HANDLE_VALUE) { FlushFileBuffers(hMsgPipe); CloseHandle(hMsgPipe); hMsgPipe = INVALID_HANDLE_VALUE; } } else { // either WS_SHUTDOWN or WaitForMultipleObjects error break; } } }
int main(int argc, char **argv) { void *dest_addr; struct cmd_struct *cmd; struct admin_opts opts; int i, ret, addr_type, status = 0; int cmd_num = ARRAY_SIZE(admin_cmds); int rsock; ret = parse_opts(argc, argv, &status); if (ret) exit(status); for (i = 0; i < cmd_num; i++) { cmd = admin_cmds + i; if (!strncmp(argv[optind], cmd->cmd, strlen(cmd->cmd))) break; } if (i == cmd_num) { fprintf(stderr, "Non-existing command specified\n"); show_usage(); exit(-1); } if (!strncmp(cmd->cmd, "help", 4)) { if (argc - optind <= 1) { fprintf(stderr, "No command was specified\n"); exit(-1); } for (i = 0; i < cmd_num; i++) { cmd = admin_cmds + i; if (!strncmp(argv[optind + 1], cmd->cmd, strlen(cmd->cmd))) break; } if (i == cmd_num) { fprintf(stderr, "Non-existing command specified\n"); show_usage(); exit(-1); } if (cmd) show_cmd_usage(cmd->cmd, admin_cmd_help(cmd->id), admin_get_cmd_opts(cmd->id)); exit(0); } if (dest_lid) { dest_addr = &dest_lid; addr_type = ADMIN_ADDR_TYPE_LID; } else { if (!dest_gid) dest_gid = "::1"; /* local host GID */ dest_addr = dest_gid; addr_type = ADMIN_ADDR_TYPE_GID; } if (admin_init(short_option, long_option) < 0) { fprintf(stderr, "ERROR - unable to init admin client\n"); exit(-1); } opts.dev = ca_name; opts.src_port = src_port; opts.admin_port = admin_port; opts.pkey = pkey; opts.timeout = timeout; rsock = admin_connect(dest_addr, addr_type, &opts); if (rsock < 0) { fprintf(stderr, "ERROR - unable to connect\n"); exit(-1); } optind = 1; ret = admin_exec_recursive(rsock, cmd->id, recursive, argc, argv); if (ret) { fprintf(stderr, "Failed executing '%s' command (%s)\n", cmd->cmd, admin_cmd_help(cmd->id)->desc); exit(-1); } admin_disconnect(rsock); admin_cleanup(); return 0; }