void cce_start(void) { int4 status; uint4 prvadr[2], prvprv[2]; static readonly $DESCRIPTOR(proc,"GT.CX_CONTROL"); static readonly $DESCRIPTOR(image,"GTM$DIST:CCP.EXE"); static readonly uic = 65540; /* uic = [1,4] */ $DESCRIPTOR(ccp,""); unsigned char success[] = "GT.CX Cluster controller started with PID = "; uint4 pid; uint4 baspri; struct FAB ccp_fab; struct NAM ccp_nam; unsigned char ccp_namebuf[63]; /* max image name allowable for creprc */ prvadr[1] = 0; prvadr[0] = PRV$M_DETACH | PRV$M_OPER | PRV$M_SYSNAM | PRV$M_SYSLCK | PRV$M_TMPMBX; status = sys$setprv(TRUE, &prvadr[0], FALSE, &prvprv[0]); if (status == SS$_NORMAL) { baspri = 5; cli_get_num("PRIORITY",&baspri); ccp_fab = cc$rms_fab; ccp_fab.fab$l_fna = image.dsc$a_pointer; ccp_fab.fab$b_fns = image.dsc$w_length; ccp_fab.fab$l_nam = &ccp_nam; ccp_nam = cc$rms_nam; ccp_nam.nam$l_esa = ccp_namebuf; ccp_nam.nam$b_ess = SIZEOF(ccp_namebuf); ccp_nam.nam$b_nop = NAM$M_SYNCHK; status = sys$parse (&ccp_fab); if (!(status & 1)) { lib$signal(status); return; } ccp.dsc$a_pointer = ccp_namebuf; ccp.dsc$w_length = ccp_nam.nam$b_esl; status = sys$creprc(&pid, &ccp, 0, 0, 0, &prvadr, 0, &proc, baspri, uic, 0, PRC$M_DETACH); sys$setprv(FALSE, &prvprv[0], FALSE, 0); if (status != SS$_NORMAL) { lib$signal(status); return; } util_out_open(0); i2hex(pid, &success[ SIZEOF(success) - 8], 8); util_out_write(&success[0], SIZEOF(success)); util_out_close(); } else lib$signal(status); }
int gtmsource_get_opt(void) { char *connect_parm_token_str, *connect_parm; char *connect_parms_str, tmp_connect_parms_str[GTMSOURCE_CONN_PARMS_LEN + 1]; char secondary_sys[MAX_SECONDARY_LEN], *c, inst_name[MAX_FN_LEN + 1]; char statslog_val[SIZEOF("OFF")]; /* "ON" or "OFF" */ char update_val[SIZEOF("DISABLE")]; /* "ENABLE" or "DISABLE" */ char freeze_val[SIZEOF("OFF")]; /* "ON" or "OFF" */ char freeze_comment[SIZEOF(gtmsource_options.freeze_comment)]; int tries, index = 0, timeout_status, connect_parms_index, status, renegotiate_interval; struct hostent *sec_hostentry; unsigned short log_file_len, filter_cmd_len; unsigned short secondary_len, inst_name_len, statslog_val_len, update_val_len, connect_parms_str_len; unsigned short freeze_val_len, freeze_comment_len, tlsid_len; int errcode; int port_len; char *ip_end; mstr log_nam, trans_name; boolean_t secondary, dotted_notation, log, log_interval_specified, connect_parms_badval, plaintext_fallback; memset((char *)>msource_options, 0, SIZEOF(gtmsource_options)); gtmsource_options.start = (CLI_PRESENT == cli_present("START")); gtmsource_options.shut_down = (CLI_PRESENT == cli_present("SHUTDOWN")); gtmsource_options.activate = (CLI_PRESENT == cli_present("ACTIVATE")); gtmsource_options.deactivate = (CLI_PRESENT == cli_present("DEACTIVATE")); gtmsource_options.checkhealth = (CLI_PRESENT == cli_present("CHECKHEALTH")); gtmsource_options.statslog = (CLI_PRESENT == cli_present("STATSLOG")); gtmsource_options.showbacklog = (CLI_PRESENT == cli_present("SHOWBACKLOG")); gtmsource_options.changelog = (CLI_PRESENT == cli_present("CHANGELOG")); gtmsource_options.stopsourcefilter = (CLI_PRESENT == cli_present("STOPSOURCEFILTER")); gtmsource_options.needrestart = (CLI_PRESENT == cli_present("NEEDRESTART")); gtmsource_options.losttncomplete = (CLI_PRESENT == cli_present("LOSTTNCOMPLETE")); gtmsource_options.jnlpool = (CLI_PRESENT == cli_present("JNLPOOL")); secondary = (CLI_PRESENT == cli_present("SECONDARY")); gtmsource_options.rootprimary = ROOTPRIMARY_UNSPECIFIED; /* to indicate unspecified state */ if ((CLI_PRESENT == cli_present("ROOTPRIMARY")) || (CLI_PRESENT == cli_present("UPDOK"))) gtmsource_options.rootprimary = ROOTPRIMARY_SPECIFIED; else if ((CLI_PRESENT == cli_present("PROPAGATEPRIMARY")) || (CLI_PRESENT == cli_present("UPDNOTOK"))) gtmsource_options.rootprimary = PROPAGATEPRIMARY_SPECIFIED; else { /* Neither ROOTPRIMARY (or UPDOK) nor PROPAGATEPRIMARY (or UPDNOTOK) specified. Assume default values. * Assume ROOTPRIMARY for -START -SECONDARY (active source server start) and -ACTIVATE commands. * Assume PROPAGATEPRIMARY for -START -PASSIVE (passive source server start) and -DEACTIVATE commands. */ if ((gtmsource_options.start && secondary) || gtmsource_options.activate) gtmsource_options.rootprimary = ROOTPRIMARY_SPECIFIED; if ((gtmsource_options.start && !secondary) || gtmsource_options.deactivate) gtmsource_options.rootprimary = PROPAGATEPRIMARY_SPECIFIED; } gtmsource_options.instsecondary = (CLI_PRESENT == cli_present("INSTSECONDARY")); if (gtmsource_options.instsecondary) { /* -INSTSECONDARY is specified in the command line. */ inst_name_len = SIZEOF(inst_name);; if (!cli_get_str("INSTSECONDARY", &inst_name[0], &inst_name_len)) { util_out_print("Error parsing INSTSECONDARY qualifier", TRUE); return(-1); } } else { /* Check if environment variable "gtm_repl_instsecondary" is defined. * Do that only if any of the following qualifiers is present as these are the only ones that honour it. * Mandatory : START, ACTIVATE, DEACTIVATE, STOPSOURCEFILTER, CHANGELOG, STATSLOG, NEEDRESTART, * Optional : CHECKHEALTH, SHOWBACKLOG or SHUTDOWN */ if (gtmsource_options.start || gtmsource_options.activate || gtmsource_options.deactivate || gtmsource_options.stopsourcefilter || gtmsource_options.changelog || gtmsource_options.statslog || gtmsource_options.needrestart || gtmsource_options.checkhealth || gtmsource_options.showbacklog || gtmsource_options.shut_down) { log_nam.addr = GTM_REPL_INSTSECONDARY; log_nam.len = SIZEOF(GTM_REPL_INSTSECONDARY) - 1; trans_name.addr = &inst_name[0]; if (SS_NORMAL == (status = TRANS_LOG_NAME(&log_nam, &trans_name, inst_name, SIZEOF(inst_name), do_sendmsg_on_log2long))) { gtmsource_options.instsecondary = TRUE; inst_name_len = trans_name.len; } else if (!gtmsource_options.checkhealth && !gtmsource_options.showbacklog && !gtmsource_options.shut_down) { if (SS_LOG2LONG == status) gtm_putmsg_csa(CSA_ARG(NULL) VARLSTCNT(5) ERR_LOGTOOLONG, 3, log_nam.len, log_nam.addr, SIZEOF(inst_name) - 1); gtm_putmsg_csa(CSA_ARG(NULL) VARLSTCNT(1) ERR_REPLINSTSECUNDF); return (-1); } } } if (gtmsource_options.instsecondary) { /* Secondary instance name specified either through -INSTSECONDARY or "gtm_repl_instsecondary" */ inst_name[inst_name_len] = '\0'; if ((MAX_INSTNAME_LEN <= inst_name_len) || (0 == inst_name_len)) { gtm_putmsg_csa(CSA_ARG(NULL) VARLSTCNT(4) ERR_REPLINSTSECLEN, 2, inst_name_len, inst_name); return (-1); } assert((inst_name_len + 1) <= MAX_INSTNAME_LEN); memcpy(gtmsource_options.secondary_instname, inst_name, inst_name_len + 1); /* copy terminating '\0' as well */ } if (gtmsource_options.start || gtmsource_options.activate) { if (secondary) { secondary_len = MAX_SECONDARY_LEN; if (!cli_get_str("SECONDARY", secondary_sys, &secondary_len)) { util_out_print("Error parsing SECONDARY qualifier", TRUE); return(-1); } /* Parse secondary_sys into secondary_host * and secondary_port */ c = secondary_sys; dotted_notation = TRUE; if ('[' == *c) { ip_end = strchr(++c, ']'); if (NULL == ip_end || 0 == (index = ip_end - c)) { util_out_print("Invalid IP address !AD", TRUE, LEN_AND_STR(secondary_sys)); return(-1); } memcpy(gtmsource_options.secondary_host, c, index); gtmsource_options.secondary_host[index] = '\0'; c = ip_end + 1; } else { while(*c && (':' != *c)) gtmsource_options.secondary_host[index++] = *c++; gtmsource_options.secondary_host[index] = '\0'; } if (':' != *c) { util_out_print("Secondary port number should be specified", TRUE); return(-1); } port_len = strlen(++c); errno = 0; if (((0 == (gtmsource_options.secondary_port = ATOI(c))) && (0 != errno)) || (0 >= gtmsource_options.secondary_port)) { util_out_print("Error parsing secondary port number !AD", TRUE, LEN_AND_STR(c)); return(-1); } } if (CLI_PRESENT == cli_present("CONNECTPARAMS")) { connect_parms_str_len = GTMSOURCE_CONN_PARMS_LEN + 1; if (!cli_get_str("CONNECTPARAMS", tmp_connect_parms_str, &connect_parms_str_len)) { util_out_print("Error parsing CONNECTPARAMS qualifier", TRUE); return(-1); } #ifdef VMS /* strip the quotes around the string. (DCL doesn't do it) */ assert('"' == tmp_connect_parms_str[0]); assert('"' == tmp_connect_parms_str[connect_parms_str_len - 1]); connect_parms_str = &tmp_connect_parms_str[1]; tmp_connect_parms_str[connect_parms_str_len - 1] = '\0'; #else connect_parms_str = &tmp_connect_parms_str[0]; #endif for (connect_parms_index = GTMSOURCE_CONN_HARD_TRIES_COUNT, connect_parms_badval = FALSE, connect_parm_token_str = connect_parms_str; !connect_parms_badval && connect_parms_index < GTMSOURCE_CONN_PARMS_COUNT && (connect_parm = strtok(connect_parm_token_str, GTMSOURCE_CONN_PARMS_DELIM)) != NULL; connect_parms_index++, connect_parm_token_str = NULL) { errno = 0; if ((0 == (gtmsource_options.connect_parms[connect_parms_index] = ATOI(connect_parm)) && 0 != errno) || 0 >= gtmsource_options.connect_parms[connect_parms_index]) connect_parms_badval = TRUE; } if (connect_parms_badval) { util_out_print("Error parsing or invalid value parameter in CONNECTPARAMS", TRUE); return(-1); } if (GTMSOURCE_CONN_PARMS_COUNT != connect_parms_index) { util_out_print( "All CONNECTPARAMS - HARD TRIES, HARD TRIES PERIOD, " "SOFT TRIES PERIOD, " "ALERT TIME, HEARTBEAT INTERVAL, " "MAX HEARBEAT WAIT should be specified", TRUE); return(-1); } } else { gtmsource_options.connect_parms[GTMSOURCE_CONN_HARD_TRIES_COUNT] = REPL_CONN_HARD_TRIES_COUNT; gtmsource_options.connect_parms[GTMSOURCE_CONN_HARD_TRIES_PERIOD] = REPL_CONN_HARD_TRIES_PERIOD; gtmsource_options.connect_parms[GTMSOURCE_CONN_SOFT_TRIES_PERIOD] = REPL_CONN_SOFT_TRIES_PERIOD; gtmsource_options.connect_parms[GTMSOURCE_CONN_ALERT_PERIOD] = REPL_CONN_ALERT_ALERT_PERIOD; gtmsource_options.connect_parms[GTMSOURCE_CONN_HEARTBEAT_PERIOD] = REPL_CONN_HEARTBEAT_PERIOD; gtmsource_options.connect_parms[GTMSOURCE_CONN_HEARTBEAT_MAX_WAIT] = REPL_CONN_HEARTBEAT_MAX_WAIT; } if (gtmsource_options.connect_parms[GTMSOURCE_CONN_ALERT_PERIOD]< gtmsource_options.connect_parms[GTMSOURCE_CONN_SOFT_TRIES_PERIOD]) gtmsource_options.connect_parms[GTMSOURCE_CONN_ALERT_PERIOD] = gtmsource_options.connect_parms[GTMSOURCE_CONN_SOFT_TRIES_PERIOD]; if (gtmsource_options.connect_parms[GTMSOURCE_CONN_HEARTBEAT_MAX_WAIT] < gtmsource_options.connect_parms[GTMSOURCE_CONN_HEARTBEAT_PERIOD]) gtmsource_options.connect_parms[GTMSOURCE_CONN_HEARTBEAT_MAX_WAIT] = gtmsource_options.connect_parms[GTMSOURCE_CONN_HEARTBEAT_PERIOD]; } if (gtmsource_options.start || gtmsource_options.statslog || gtmsource_options.changelog || gtmsource_options.activate) { log = (cli_present("LOG") == CLI_PRESENT); log_interval_specified = (CLI_PRESENT == cli_present("LOG_INTERVAL")); if (log) { log_file_len = MAX_FN_LEN + 1; if (!cli_get_str("LOG", gtmsource_options.log_file, &log_file_len)) { util_out_print("Error parsing LOG qualifier", TRUE); return(-1); } } else gtmsource_options.log_file[0] = '\0'; gtmsource_options.src_log_interval = 0; if (log_interval_specified) { if (!cli_get_num("LOG_INTERVAL", (int4 *)>msource_options.src_log_interval)) { util_out_print("Error parsing LOG_INTERVAL qualifier", TRUE); return (-1); } } if (gtmsource_options.start && 0 == gtmsource_options.src_log_interval) gtmsource_options.src_log_interval = LOGTRNUM_INTERVAL; /* For changelog/activate, interval == 0 implies don't change log interval already established */ /* We ignore interval specification for statslog, Vinaya 2005/02/07 */ } if (gtmsource_options.start) { assert(secondary || CLI_PRESENT == cli_present("PASSIVE")); gtmsource_options.mode = ((secondary) ? GTMSOURCE_MODE_ACTIVE : GTMSOURCE_MODE_PASSIVE); if (CLI_PRESENT == cli_present("BUFFSIZE")) { if (!cli_get_int("BUFFSIZE", >msource_options.buffsize)) { util_out_print("Error parsing BUFFSIZE qualifier", TRUE); return(-1); } if (MIN_JNLPOOL_SIZE > gtmsource_options.buffsize) gtmsource_options.buffsize = MIN_JNLPOOL_SIZE; } else gtmsource_options.buffsize = DEFAULT_JNLPOOL_SIZE; /* Round up buffsize to the nearest (~JNL_WRT_END_MASK + 1) multiple */ gtmsource_options.buffsize = ((gtmsource_options.buffsize + ~JNL_WRT_END_MASK) & JNL_WRT_END_MASK); if (CLI_PRESENT == cli_present("FILTER")) { filter_cmd_len = MAX_FILTER_CMD_LEN; if (!cli_get_str("FILTER", gtmsource_options.filter_cmd, &filter_cmd_len)) { util_out_print("Error parsing FILTER qualifier", TRUE); return(-1); } } else gtmsource_options.filter_cmd[0] = '\0'; /* Check if compression level is specified */ if (CLI_PRESENT == cli_present("CMPLVL")) { if (!cli_get_int("CMPLVL", >msource_options.cmplvl)) { util_out_print("Error parsing CMPLVL qualifier", TRUE); return(-1); } if (GTM_CMPLVL_OUT_OF_RANGE(gtmsource_options.cmplvl)) gtmsource_options.cmplvl = ZLIB_CMPLVL_MIN; /* no compression in this case */ /* CMPLVL qualifier should override any value specified in the environment variable gtm_zlib_cmp_level */ gtm_zlib_cmp_level = gtmsource_options.cmplvl; } else gtmsource_options.cmplvl = ZLIB_CMPLVL_MIN; /* no compression in this case */ /* Check if SSL/TLS secure communication is requested. */ # ifdef GTM_TLS if (CLI_PRESENT == cli_present("TLSID")) { tlsid_len = MAX_TLSID_LEN; if (!cli_get_str("TLSID", repl_tls.id, &tlsid_len)) { util_out_print("Error parsing TLSID qualifier", TRUE); return -1; } assert(0 < tlsid_len); if (CLI_PRESENT == cli_present("RENEGOTIATE_INTERVAL")) { if (!cli_get_int("RENEGOTIATE_INTERVAL", &renegotiate_interval)) { util_out_print("Error parsing RENEGOTIATE_INTERVAL qualifier", TRUE); return -1; } if (0 > renegotiate_interval) { util_out_print("Negative values are not allowed for RENEGOTIATE_INTERVAL qualifier", TRUE); return -1; } else if ((0 < renegotiate_interval) && (renegotiate_interval < MIN_RENEGOTIATE_TIMEOUT)) renegotiate_interval = MIN_RENEGOTIATE_TIMEOUT; renegotiate_interval = renegotiate_interval * 60; /* Convert to seconds. */ } else renegotiate_interval = DEFAULT_RENEGOTIATE_TIMEOUT * 60; /* Convert to seconds. */ /* Convert renegotiate_interval to heartbeat units (# of 8 second intervals). */ renegotiate_interval = DIVIDE_ROUND_UP(renegotiate_interval, HEARTBEAT_INTERVAL_IN_SECS); gtmsource_options.renegotiate_interval = renegotiate_interval; /* Check if plaintext-fallback mode is specified. Default option is NOPLAINTEXTFALLBACK. */ if (CLI_PRESENT == (plaintext_fallback = cli_present("PLAINTEXTFALLBACK"))) repl_tls.plaintext_fallback = (plaintext_fallback != CLI_NEGATED); else repl_tls.plaintext_fallback = FALSE; } # endif } if (gtmsource_options.shut_down) { if ((timeout_status = cli_present("TIMEOUT")) == CLI_PRESENT) { if (!cli_get_int("TIMEOUT", >msource_options.shutdown_time)) { util_out_print("Error parsing TIMEOUT qualifier", TRUE); return(-1); } if (DEFAULT_SHUTDOWN_TIMEOUT < gtmsource_options.shutdown_time || 0 > gtmsource_options.shutdown_time) { gtmsource_options.shutdown_time = DEFAULT_SHUTDOWN_TIMEOUT; util_out_print("shutdown TIMEOUT changed to !UL", TRUE, gtmsource_options.shutdown_time); } } else if (CLI_NEGATED == timeout_status) gtmsource_options.shutdown_time = -1; else /* TIMEOUT not specified */ gtmsource_options.shutdown_time = DEFAULT_SHUTDOWN_TIMEOUT; } if (gtmsource_options.statslog) { statslog_val_len = 4; /* max(strlen("ON"), strlen("OFF")) + 1 */ if (!cli_get_str("STATSLOG", statslog_val, &statslog_val_len)) { util_out_print("Error parsing STATSLOG qualifier", TRUE); return(-1); } UNIX_ONLY(cli_strupper(statslog_val);) if (0 == STRCMP(statslog_val, "ON"))
int4 mupip_set_file(int db_fn_len, char *db_fn) { bool got_standalone; boolean_t bypass_partial_recov, need_standalone = FALSE; char acc_spec[MAX_ACC_METH_LEN], ver_spec[MAX_DB_VER_LEN], exit_stat, *fn; unsigned short acc_spec_len = MAX_ACC_METH_LEN, ver_spec_len = MAX_DB_VER_LEN; int fd, fn_len; int4 status; int4 status1; int glbl_buff_status, defer_status, rsrvd_bytes_status, extn_count_status, lock_space_status, disk_wait_status; int4 new_disk_wait, new_cache_size, new_extn_count, new_lock_space, reserved_bytes, defer_time; sgmnt_data_ptr_t csd; tp_region *rptr, single; enum db_acc_method access, access_new; enum db_ver desired_dbver; gd_region *temp_cur_region; char *errptr, *command = "MUPIP SET VERSION"; int save_errno; error_def(ERR_DBPREMATEOF); error_def(ERR_DBRDERR); error_def(ERR_DBRDONLY); error_def(ERR_INVACCMETHOD); error_def(ERR_MUNOACTION); error_def(ERR_RBWRNNOTCHG); error_def(ERR_WCERRNOTCHG); error_def(ERR_WCWRNNOTCHG); error_def(ERR_MMNODYNDWNGRD); exit_stat = EXIT_NRM; defer_status = cli_present("DEFER_TIME"); if (defer_status) need_standalone = TRUE; bypass_partial_recov = cli_present("PARTIAL_RECOV_BYPASS") == CLI_PRESENT; if (bypass_partial_recov) need_standalone = TRUE; if (disk_wait_status = cli_present("WAIT_DISK")) { if (cli_get_int("WAIT_DISK", &new_disk_wait)) { if (new_disk_wait < 0) { util_out_print("!UL negative, minimum WAIT_DISK allowed is 0.", TRUE, new_disk_wait); return (int4)ERR_WCWRNNOTCHG; } need_standalone = TRUE; } else { util_out_print("Error getting WAIT_DISK qualifier value", TRUE); return (int4)ERR_WCWRNNOTCHG; } } if (glbl_buff_status = cli_present("GLOBAL_BUFFERS")) { if (cli_get_int("GLOBAL_BUFFERS", &new_cache_size)) { if (new_cache_size > WC_MAX_BUFFS) { util_out_print("!UL too large, maximum write cache buffers allowed is !UL", TRUE, new_cache_size, WC_MAX_BUFFS); return (int4)ERR_WCWRNNOTCHG; } if (new_cache_size < WC_MIN_BUFFS) { util_out_print("!UL too small, minimum cache buffers allowed is !UL", TRUE, new_cache_size, WC_MIN_BUFFS); return (int4)ERR_WCWRNNOTCHG; } } else { util_out_print("Error getting GLOBAL BUFFER qualifier value", TRUE); return (int4)ERR_WCWRNNOTCHG; } need_standalone = TRUE; } /* EXTENSION_COUNT does not require standalone access and hence need_standalone will not be set to TRUE for this. */ if (extn_count_status = cli_present("EXTENSION_COUNT")) { if (cli_get_int("EXTENSION_COUNT", &new_extn_count)) { if (new_extn_count > MAX_EXTN_COUNT) { util_out_print("!UL too large, maximum extension count allowed is !UL", TRUE, new_extn_count, MAX_EXTN_COUNT); return (int4)ERR_WCWRNNOTCHG; } if (new_extn_count < MIN_EXTN_COUNT) { util_out_print("!UL too small, minimum extension count allowed is !UL", TRUE, new_extn_count, MIN_EXTN_COUNT); return (int4)ERR_WCWRNNOTCHG; } } else { util_out_print("Error getting EXTENSION COUNT qualifier value", TRUE); return (int4)ERR_WCWRNNOTCHG; } } if (lock_space_status = cli_present("LOCK_SPACE")) { if (cli_get_int("LOCK_SPACE", &new_lock_space)) { if (new_lock_space > MAX_LOCK_SPACE) { util_out_print("!UL too large, maximum lock space allowed is !UL", TRUE, new_lock_space, MAX_LOCK_SPACE); return (int4)ERR_WCWRNNOTCHG; } else if (new_lock_space < MIN_LOCK_SPACE) { util_out_print("!UL too small, minimum lock space allowed is !UL", TRUE, new_lock_space, MIN_LOCK_SPACE); return (int4)ERR_WCWRNNOTCHG; } } else { util_out_print("Error getting LOCK_SPACE qualifier value", TRUE); return (int4)ERR_WCWRNNOTCHG; } need_standalone = TRUE; } if (rsrvd_bytes_status = cli_present("RESERVED_BYTES")) { if (!cli_get_int("RESERVED_BYTES", &reserved_bytes)) { util_out_print("Error getting RESERVED BYTES qualifier value", TRUE); return (int4)ERR_RBWRNNOTCHG; } need_standalone = TRUE; } if (cli_present("ACCESS_METHOD")) { cli_get_str("ACCESS_METHOD", acc_spec, &acc_spec_len); cli_strupper(acc_spec); if (0 == memcmp(acc_spec, "MM", acc_spec_len)) access = dba_mm; else if (0 == memcmp(acc_spec, "BG", acc_spec_len)) access = dba_bg; else mupip_exit(ERR_INVACCMETHOD); need_standalone = TRUE; } else access = n_dba; /* really want to keep current method, which has not yet been read */ if (cli_present("VERSION")) { assert(!need_standalone); cli_get_str("VERSION", ver_spec, &ver_spec_len); cli_strupper(ver_spec); if (0 == memcmp(ver_spec, "V4", ver_spec_len)) desired_dbver = GDSV4; else if (0 == memcmp(ver_spec, "V5", ver_spec_len)) desired_dbver = GDSV5; else GTMASSERT; /* CLI should prevent us ever getting here */ } else desired_dbver = GDSVLAST; /* really want to keep version, which has not yet been read */ if (region) rptr = grlist; else { rptr = &single; memset(&single, 0, sizeof(single)); } csd = (sgmnt_data *)malloc(ROUND_UP(sizeof(sgmnt_data), DISK_BLOCK_SIZE)); in_backup = FALSE; /* Only want yes/no from mupfndfil, not an address */ for (; rptr != NULL; rptr = rptr->fPtr) { if (region) { if (dba_usr == rptr->reg->dyn.addr->acc_meth) { util_out_print("!/Region !AD is not a GDS access type", TRUE, REG_LEN_STR(rptr->reg)); exit_stat |= EXIT_WRN; continue; } if (!mupfndfil(rptr->reg, NULL)) continue; fn = (char *)rptr->reg->dyn.addr->fname; fn_len = rptr->reg->dyn.addr->fname_len; } else { fn = db_fn; fn_len = db_fn_len; } mu_gv_cur_reg_init(); strcpy((char *)gv_cur_region->dyn.addr->fname, fn); gv_cur_region->dyn.addr->fname_len = fn_len; if (!need_standalone) { gvcst_init(gv_cur_region); change_reg(); /* sets cs_addrs and cs_data */ if (gv_cur_region->read_only) { gtm_putmsg(VARLSTCNT(4) ERR_DBRDONLY, 2, DB_LEN_STR(gv_cur_region)); exit_stat |= EXIT_ERR; gds_rundown(); mu_gv_cur_reg_free(); continue; } grab_crit(gv_cur_region); status = EXIT_NRM; access_new = (n_dba == access ? cs_data->acc_meth : access); /* recalculate; n_dba is a proxy for no change */ change_fhead_timer("FLUSH_TIME", cs_data->flush_time, (dba_bg == access_new ? TIM_FLU_MOD_BG : TIM_FLU_MOD_MM), FALSE); if (GDSVLAST != desired_dbver) { if ((dba_mm != access_new) || (GDSV4 != desired_dbver)) status1 = desired_db_format_set(gv_cur_region, desired_dbver, command); else { status1 = ERR_MMNODYNDWNGRD; gtm_putmsg(VARLSTCNT(4) status1, 2, REG_LEN_STR(gv_cur_region)); } if (SS_NORMAL != status1) { /* "desired_db_format_set" would have printed appropriate error messages */ if (ERR_MUNOACTION != status1) { /* real error occurred while setting the db format. skip to next region */ status = EXIT_ERR; } } } if (EXIT_NRM == status) { if (extn_count_status) cs_data->extension_size = (uint4)new_extn_count; wcs_flu(WCSFLU_FLUSH_HDR); if (extn_count_status) util_out_print("Database file !AD now has extension count !UL", TRUE, fn_len, fn, cs_data->extension_size); if (GDSVLAST != desired_dbver) util_out_print("Database file !AD now has desired DB format !AD", TRUE, fn_len, fn, LEN_AND_STR(gtm_dbversion_table[cs_data->desired_db_format])); } else exit_stat |= status; rel_crit(gv_cur_region); gds_rundown(); } else { /* Following part needs standalone access */ assert(GDSVLAST == desired_dbver); got_standalone = mu_rndwn_file(gv_cur_region, TRUE); if (FALSE == got_standalone) return (int4)ERR_WCERRNOTCHG; /* we should open it (for changing) after mu_rndwn_file, since mu_rndwn_file changes the file header too */ if (-1 == (fd = OPEN(fn, O_RDWR))) { save_errno = errno; errptr = (char *)STRERROR(save_errno); util_out_print("open : !AZ", TRUE, errptr); exit_stat |= EXIT_ERR; db_ipcs_reset(gv_cur_region, FALSE); mu_gv_cur_reg_free(); continue; } LSEEKREAD(fd, 0, csd, sizeof(sgmnt_data), status); if (0 != status) { save_errno = errno; PERROR("Error reading header of file"); errptr = (char *)STRERROR(save_errno); util_out_print("read : !AZ", TRUE, errptr); util_out_print("Error reading header of file", TRUE); util_out_print("Database file !AD not changed: ", TRUE, fn_len, fn); if (-1 != status) rts_error(VARLSTCNT(4) ERR_DBRDERR, 2, fn_len, fn); else rts_error(VARLSTCNT(4) ERR_DBPREMATEOF, 2, fn_len, fn); } if (rsrvd_bytes_status) { if (reserved_bytes > MAX_RESERVE_B(csd)) { util_out_print("!UL too large, maximum reserved bytes allowed is !UL for database file !AD", TRUE, reserved_bytes, MAX_RESERVE_B(csd), fn_len, fn); close(fd); db_ipcs_reset(gv_cur_region, FALSE); return (int4)ERR_RBWRNNOTCHG; } csd->reserved_bytes = reserved_bytes; } access_new = (n_dba == access ? csd->acc_meth : access); /* recalculate; n_dba is a proxy for no change */ change_fhead_timer("FLUSH_TIME", csd->flush_time, (dba_bg == access_new ? TIM_FLU_MOD_BG : TIM_FLU_MOD_MM), FALSE); if ((n_dba != access) && (csd->acc_meth != access)) /* n_dba is a proxy for no change */ { if (dba_mm == access) csd->defer_time = 1; /* defer defaults to 1 */ csd->acc_meth = access; if (0 == csd->n_bts) { csd->n_bts = WC_DEF_BUFFS; csd->bt_buckets = getprime(csd->n_bts); } } if (glbl_buff_status) { csd->n_bts = BT_FACTOR(new_cache_size); csd->bt_buckets = getprime(csd->n_bts); csd->n_wrt_per_flu = 7; csd->flush_trigger = FLUSH_FACTOR(csd->n_bts); } if (disk_wait_status) csd->wait_disk_space = new_disk_wait; if (extn_count_status) csd->extension_size = (uint4)new_extn_count; if (lock_space_status) csd->lock_space_size = (uint4)new_lock_space * OS_PAGELET_SIZE; if (bypass_partial_recov) { csd->file_corrupt = FALSE; util_out_print("Database file !AD now has partial recovery flag set to !UL(FALSE) ", TRUE, fn_len, fn, csd->file_corrupt); } if (dba_mm == access_new) { if (CLI_NEGATED == defer_status) csd->defer_time = 0; else if (CLI_PRESENT == defer_status) { if (!cli_get_num("DEFER_TIME", &defer_time)) { util_out_print("Error getting DEFER_TIME qualifier value", TRUE); db_ipcs_reset(gv_cur_region, FALSE); return (int4)ERR_RBWRNNOTCHG; } if (-1 > defer_time) { util_out_print("DEFER_TIME cannot take negative values less than -1", TRUE); util_out_print("Database file !AD not changed", TRUE, fn_len, fn); exit_stat |= EXIT_WRN; db_ipcs_reset(gv_cur_region, FALSE); mu_gv_cur_reg_free(); continue; } csd->defer_time = defer_time; } if (csd->blks_to_upgrd) { util_out_print("MM access method cannot be set if there are blocks to upgrade", TRUE); util_out_print("Database file !AD not changed", TRUE, fn_len, fn); exit_stat |= EXIT_WRN; db_ipcs_reset(gv_cur_region, FALSE); mu_gv_cur_reg_free(); continue; } if (GDSVCURR != csd->desired_db_format) { util_out_print("MM access method cannot be set in DB compatibility mode", TRUE); util_out_print("Database file !AD not changed", TRUE, fn_len, fn); exit_stat |= EXIT_WRN; db_ipcs_reset(gv_cur_region, FALSE); mu_gv_cur_reg_free(); continue; } if (JNL_ENABLED(csd) && csd->jnl_before_image) { util_out_print("MM access method cannot be set with BEFORE image journaling", TRUE); util_out_print("Database file !AD not changed", TRUE, fn_len, fn); exit_stat |= EXIT_WRN; db_ipcs_reset(gv_cur_region, FALSE); mu_gv_cur_reg_free(); continue; } csd->jnl_before_image = FALSE; } else { if (defer_status) { util_out_print("DEFER cannot be specified with BG access method.", TRUE); util_out_print("Database file !AD not changed", TRUE, fn_len, fn); exit_stat |= EXIT_WRN; db_ipcs_reset(gv_cur_region, FALSE); mu_gv_cur_reg_free(); continue; } } LSEEKWRITE(fd, 0, csd, sizeof(sgmnt_data), status); if (0 != status) { save_errno = errno; errptr = (char *)STRERROR(save_errno); util_out_print("write : !AZ", TRUE, errptr); util_out_print("Error writing header of file", TRUE); util_out_print("Database file !AD not changed: ", TRUE, fn_len, fn); rts_error(VARLSTCNT(4) ERR_DBRDERR, 2, fn_len, fn); } close(fd); /* --------------------- report results ------------------------- */ if (glbl_buff_status) util_out_print("Database file !AD now has !UL global buffers", TRUE, fn_len, fn, csd->n_bts); if (defer_status && (dba_mm == csd->acc_meth)) util_out_print("Database file !AD now has defer_time set to !SL", TRUE, fn_len, fn, csd->defer_time); if (rsrvd_bytes_status) util_out_print("Database file !AD now has !UL reserved bytes", TRUE, fn_len, fn, csd->reserved_bytes); if (extn_count_status) util_out_print("Database file !AD now has extension count !UL", TRUE, fn_len, fn, csd->extension_size); if (lock_space_status) util_out_print("Database file !AD now has lock space !UL pages", TRUE, fn_len, fn, csd->lock_space_size/OS_PAGELET_SIZE); if (disk_wait_status) util_out_print("Database file !AD now has wait disk set to !UL seconds", TRUE, fn_len, fn, csd->wait_disk_space); db_ipcs_reset(gv_cur_region, FALSE); } /* end of else part if (!need_standalone) */ mu_gv_cur_reg_free(); } free(csd); assert(!(exit_stat & EXIT_INF)); return (exit_stat & EXIT_ERR ? (int4)ERR_WCERRNOTCHG : (exit_stat & EXIT_WRN ? (int4)ERR_WCWRNNOTCHG : SS_NORMAL)); }
int gtmsource_get_opt(void) { boolean_t secondary, dotted_notation; int tries, index = 0; unsigned short secondary_len; char secondary_sys[MAX_SECONDARY_LEN], *c; struct hostent *sec_hostentry; boolean_t log, log_interval_specified; unsigned short log_file_len; boolean_t buffsize_status; boolean_t filter; unsigned short filter_cmd_len; int timeout_status; unsigned short statslog_val_len; char statslog_val[4]; /* "ON" or "OFF" */ unsigned short update_val_len; char update_val[SIZEOF("DISABLE")]; /* "ENABLE" or "DISABLE" */ unsigned short connect_parms_str_len; char *connect_parms_str, tmp_connect_parms_str[GTMSOURCE_CONN_PARMS_LEN + 1]; char *connect_parm_token_str, *connect_parm; int connect_parms_index; boolean_t connect_parms_badval; memset((char *)>msource_options, 0, SIZEOF(gtmsource_options)); gtmsource_options.start = (cli_present("START") == CLI_PRESENT); gtmsource_options.shut_down = (cli_present("SHUTDOWN") == CLI_PRESENT); gtmsource_options.activate = (cli_present("ACTIVATE") == CLI_PRESENT); gtmsource_options.deactivate = (cli_present("DEACTIVATE") == CLI_PRESENT); gtmsource_options.checkhealth = (cli_present("CHECKHEALTH") == CLI_PRESENT); gtmsource_options.statslog = (cli_present("STATSLOG") == CLI_PRESENT); gtmsource_options.showbacklog = (cli_present("SHOWBACKLOG") == CLI_PRESENT); gtmsource_options.changelog = (cli_present("CHANGELOG") == CLI_PRESENT); gtmsource_options.stopsourcefilter = (cli_present("STOPSOURCEFILTER") == CLI_PRESENT); gtmsource_options.update = (cli_present("UPDATE") == CLI_PRESENT); if (gtmsource_options.start || gtmsource_options.activate) { if (secondary = (CLI_PRESENT == cli_present("SECONDARY"))) { secondary_len = MAX_SECONDARY_LEN; if (!cli_get_str("SECONDARY", secondary_sys, &secondary_len)) { util_out_print("Error parsing SECONDARY qualifier", TRUE); return(-1); } /* Parse secondary_sys into secondary_host * and secondary_port */ c = secondary_sys; dotted_notation = TRUE; while(*c && *c != ':') { if ('.' != *c && !ISDIGIT(*c)) dotted_notation = FALSE; gtmsource_options.secondary_host[index++] = *c++; } gtmsource_options.secondary_host[index] = '\0'; if (':' != *c) { util_out_print("Secondary port number should be specified", TRUE); return(-1); } errno = 0; if (((0 == (gtmsource_options.secondary_port = ATOI(++c))) && (0 != errno)) || (0 >= gtmsource_options.secondary_port)) { util_out_print("Error parsing secondary port number !AD", TRUE, LEN_AND_STR(c)); return(-1); } /* Validate the specified secondary host name */ if (dotted_notation) { if ((in_addr_t)-1 == (gtmsource_options.sec_inet_addr = INET_ADDR(gtmsource_options.secondary_host))) { util_out_print("Invalid IP address !AD", TRUE, LEN_AND_STR(gtmsource_options.secondary_host)); return(-1); } } else { for (tries = 0; tries < MAX_GETHOST_TRIES && !(sec_hostentry = GETHOSTBYNAME(gtmsource_options.secondary_host)) && h_errno == TRY_AGAIN; tries++); if (NULL == sec_hostentry) { util_out_print("Could not find IP address for !AD", TRUE, LEN_AND_STR(gtmsource_options.secondary_host)); return(-1); } gtmsource_options.sec_inet_addr = ((struct in_addr *)sec_hostentry->h_addr_list[0])->s_addr; } } if (CLI_PRESENT == cli_present("CONNECTPARAMS")) { connect_parms_str_len = GTMSOURCE_CONN_PARMS_LEN + 1; if (!cli_get_str("CONNECTPARAMS", tmp_connect_parms_str, &connect_parms_str_len)) { util_out_print("Error parsing CONNECTPARAMS qualifier", TRUE); return(-1); } #ifdef VMS /* strip the quotes around the string. (DCL doesn't do it) */ assert('"' == tmp_connect_parms_str[0]); assert('"' == tmp_connect_parms_str[connect_parms_str_len - 1]); connect_parms_str = &tmp_connect_parms_str[1]; tmp_connect_parms_str[connect_parms_str_len - 1] = '\0'; #else connect_parms_str = &tmp_connect_parms_str[0]; #endif for (connect_parms_index = GTMSOURCE_CONN_HARD_TRIES_COUNT, connect_parms_badval = FALSE, connect_parm_token_str = connect_parms_str; !connect_parms_badval && connect_parms_index < GTMSOURCE_CONN_PARMS_COUNT && (connect_parm = strtok(connect_parm_token_str, GTMSOURCE_CONN_PARMS_DELIM)) != NULL; connect_parms_index++, connect_parm_token_str = NULL) { errno = 0; if ((0 == (gtmsource_options.connect_parms[connect_parms_index] = ATOI(connect_parm)) && 0 != errno) || 0 >= gtmsource_options.connect_parms[connect_parms_index]) connect_parms_badval = TRUE; } if (connect_parms_badval) { util_out_print("Error parsing or invalid value parameter in CONNECTPARAMS", TRUE); return(-1); } if (GTMSOURCE_CONN_PARMS_COUNT != connect_parms_index) { util_out_print( "All CONNECTPARAMS - HARD TRIES, HARD TRIES PERIOD, " "SOFT TRIES PERIOD, " "ALERT TIME, HEARTBEAT INTERVAL, " "MAX HEARBEAT WAIT should be specified", TRUE); return(-1); } } else { gtmsource_options.connect_parms[GTMSOURCE_CONN_HARD_TRIES_COUNT] = REPL_CONN_HARD_TRIES_COUNT; gtmsource_options.connect_parms[GTMSOURCE_CONN_HARD_TRIES_PERIOD] = REPL_CONN_HARD_TRIES_PERIOD; gtmsource_options.connect_parms[GTMSOURCE_CONN_SOFT_TRIES_PERIOD] = REPL_CONN_SOFT_TRIES_PERIOD; gtmsource_options.connect_parms[GTMSOURCE_CONN_ALERT_PERIOD] = REPL_CONN_ALERT_ALERT_PERIOD; gtmsource_options.connect_parms[GTMSOURCE_CONN_HEARTBEAT_PERIOD] = REPL_CONN_HEARTBEAT_PERIOD; gtmsource_options.connect_parms[GTMSOURCE_CONN_HEARTBEAT_MAX_WAIT] = REPL_CONN_HEARTBEAT_MAX_WAIT; } if (gtmsource_options.connect_parms[GTMSOURCE_CONN_ALERT_PERIOD]< gtmsource_options.connect_parms[GTMSOURCE_CONN_SOFT_TRIES_PERIOD]) gtmsource_options.connect_parms[GTMSOURCE_CONN_ALERT_PERIOD] = gtmsource_options.connect_parms[GTMSOURCE_CONN_SOFT_TRIES_PERIOD]; if (gtmsource_options.connect_parms[GTMSOURCE_CONN_HEARTBEAT_MAX_WAIT] < gtmsource_options.connect_parms[GTMSOURCE_CONN_HEARTBEAT_PERIOD]) gtmsource_options.connect_parms[GTMSOURCE_CONN_HEARTBEAT_MAX_WAIT] = gtmsource_options.connect_parms[GTMSOURCE_CONN_HEARTBEAT_PERIOD]; } if (gtmsource_options.start || gtmsource_options.statslog || gtmsource_options.changelog || gtmsource_options.activate || gtmsource_options.deactivate) { log = (cli_present("LOG") == CLI_PRESENT); log_interval_specified = (CLI_PRESENT == cli_present("LOG_INTERVAL")); if (log) { log_file_len = MAX_FN_LEN + 1; if (!cli_get_str("LOG", gtmsource_options.log_file, &log_file_len)) { util_out_print("Error parsing LOG qualifier", TRUE); return(-1); } } else gtmsource_options.log_file[0] = '\0'; gtmsource_options.src_log_interval = 0; if (log_interval_specified) { if (!cli_get_num("LOG_INTERVAL", (int4 *)>msource_options.src_log_interval)) { util_out_print("Error parsing LOG_INTERVAL qualifier", TRUE); return (-1); } } if (gtmsource_options.start && 0 == gtmsource_options.src_log_interval) gtmsource_options.src_log_interval = LOGTRNUM_INTERVAL; /* For changelog/activate/deactivate, interval == 0 implies don't change log interval already established */ /* We ignore interval specification for statslog, Vinaya 2005/02/07 */ } if (gtmsource_options.start) { assert(secondary || CLI_PRESENT == cli_present("PASSIVE")); gtmsource_options.mode = ((secondary) ? GTMSOURCE_MODE_ACTIVE : GTMSOURCE_MODE_PASSIVE); if (buffsize_status = (CLI_PRESENT == cli_present("BUFFSIZE"))) { if (!cli_get_int("BUFFSIZE", >msource_options.buffsize)) { util_out_print("Error parsing BUFFSIZE qualifier", TRUE); return(-1); } if (MIN_JNLPOOL_SIZE > gtmsource_options.buffsize) gtmsource_options.buffsize = MIN_JNLPOOL_SIZE; } else gtmsource_options.buffsize = DEFAULT_JNLPOOL_SIZE; /* Round up buffsize to the nearest (~JNL_WRT_END_MASK + 1) multiple */ gtmsource_options.buffsize = ((gtmsource_options.buffsize + ~JNL_WRT_END_MASK) & JNL_WRT_END_MASK); if (filter = (CLI_PRESENT == cli_present("FILTER"))) { filter_cmd_len = MAX_FILTER_CMD_LEN; if (!cli_get_str("FILTER", gtmsource_options.filter_cmd, &filter_cmd_len)) { util_out_print("Error parsing FILTER qualifier", TRUE); return(-1); } } else gtmsource_options.filter_cmd[0] = '\0'; } if (gtmsource_options.shut_down) { if ((timeout_status = cli_present("TIMEOUT")) == CLI_PRESENT) { if (!cli_get_int("TIMEOUT", >msource_options.shutdown_time)) { util_out_print("Error parsing TIMEOUT qualifier", TRUE); return(-1); } if (DEFAULT_SHUTDOWN_TIMEOUT < gtmsource_options.shutdown_time || 0 > gtmsource_options.shutdown_time) { gtmsource_options.shutdown_time = DEFAULT_SHUTDOWN_TIMEOUT; util_out_print("shutdown TIMEOUT changed to !UL", TRUE, gtmsource_options.shutdown_time); } } else if (CLI_NEGATED == timeout_status) gtmsource_options.shutdown_time = -1; else /* TIMEOUT not specified */ gtmsource_options.shutdown_time = DEFAULT_SHUTDOWN_TIMEOUT; } if (gtmsource_options.statslog) { statslog_val_len = 4; /* max(strlen("ON"), strlen("OFF")) + 1 */ if (!cli_get_str("STATSLOG", statslog_val, &statslog_val_len)) { util_out_print("Error parsing STATSLOG qualifier", TRUE); return(-1); } UNIX_ONLY(cli_strupper(statslog_val);) if (0 == strcmp(statslog_val, "ON"))
void dse_chng_bhead(void) { block_id blk; block_id *blkid_ptr; sgm_info *dummysi = NULL; int4 x; cache_rec_ptr_t cr; uchar_ptr_t bp; sm_uc_ptr_t blkBase; blk_hdr new_hdr; blk_segment *bs1, *bs_ptr; cw_set_element *cse; int4 blk_seg_cnt, blk_size; /* needed for BLK_INIT,BLK_SEG and BLK_FINI macros */ bool ismap; bool chng_blk; uint4 mapsize; uint4 jnl_status; error_def(ERR_DSEBLKRDFAIL); error_def(ERR_DSEFAIL); error_def(ERR_DBRDONLY); if (gv_cur_region->read_only) rts_error(VARLSTCNT(4) ERR_DBRDONLY, 2, DB_LEN_STR(gv_cur_region)); assert(update_array); /* reset new block mechanism */ update_array_ptr = update_array; chng_blk = FALSE; if (cli_present("BLOCK") == CLI_PRESENT) { if (!cli_get_hex("BLOCK",&blk)) return; if (blk < 0 || blk > cs_addrs->ti->total_blks) { util_out_print("Error: invalid block number.",TRUE); return; } patch_curr_blk = blk; } blk_size = cs_addrs->hdr->blk_size; ismap = (patch_curr_blk / cs_addrs->hdr->bplmap * cs_addrs->hdr->bplmap == patch_curr_blk); mapsize = BM_SIZE(cs_addrs->hdr->bplmap); t_begin_crit (ERR_DSEFAIL); if (!(bp = t_qread (patch_curr_blk,&dummy_hist.h[0].cycle,&dummy_hist.h[0].cr))) rts_error(VARLSTCNT(1) ERR_DSEBLKRDFAIL); new_hdr = *(blk_hdr_ptr_t)bp; if (cli_present("LEVEL") == CLI_PRESENT) { if (!cli_get_num("LEVEL",&x)) { t_abort(gv_cur_region, cs_addrs); return; } if (ismap && (unsigned char)x != LCL_MAP_LEVL) { util_out_print("Error: invalid level for a bit map block.",TRUE); t_abort(gv_cur_region, cs_addrs); return; } if (!ismap && (x < 0 || x > MAX_BT_DEPTH + 1)) { util_out_print("Error: invalid level.",TRUE); t_abort(gv_cur_region, cs_addrs); return; } new_hdr.levl = (unsigned char)x; chng_blk = TRUE; if (new_hdr.bsiz < sizeof(blk_hdr)) new_hdr.bsiz = sizeof(blk_hdr); if (new_hdr.bsiz > blk_size) new_hdr.bsiz = blk_size; } if (cli_present("BSIZ") == CLI_PRESENT) { if (!cli_get_hex("BSIZ",&x)) { t_abort(gv_cur_region, cs_addrs); return; } if (ismap && x != mapsize) { util_out_print("Error: invalid bsiz.",TRUE); t_abort(gv_cur_region, cs_addrs); return; } else if (x < sizeof(blk_hdr) || x > blk_size) { util_out_print("Error: invalid bsiz.",TRUE); t_abort(gv_cur_region, cs_addrs); return; } chng_blk = TRUE; new_hdr.bsiz = x; } if (!chng_blk) t_abort(gv_cur_region, cs_addrs); else { BLK_INIT(bs_ptr, bs1); BLK_SEG(bs_ptr, bp + sizeof(new_hdr), new_hdr.bsiz - sizeof(new_hdr)); if (!BLK_FINI(bs_ptr, bs1)) { util_out_print("Error: bad block build.",TRUE); t_abort(gv_cur_region, cs_addrs); return; } t_write (patch_curr_blk, (unsigned char *)bs1, 0, 0, bp, new_hdr.levl, TRUE, FALSE); BUILD_AIMG_IF_JNL_ENABLED(cs_addrs, cs_data, non_tp_jfb_buff_ptr, cse); t_end(&dummy_hist, 0); } if (cli_present("TN") == CLI_PRESENT) { if (!cli_get_hex("TN",&x)) return; t_begin_crit(ERR_DSEFAIL); assert(cs_addrs->ti->early_tn == cs_addrs->ti->curr_tn); cs_addrs->ti->early_tn++; blkBase = t_qread(patch_curr_blk, &dummy_hist.h[0].cycle, &dummy_hist.h[0].cr); if (NULL == blkBase) { rel_crit(gv_cur_region); util_out_print("Error: Unable to read buffer.", TRUE); t_abort(gv_cur_region, cs_addrs); return; } /* Create a null update array for a block */ if (ismap) { BLK_ADDR(blkid_ptr, sizeof(block_id), block_id); *blkid_ptr = 0; t_write_map(patch_curr_blk, blkBase, (unsigned char *)blkid_ptr, cs_addrs->ti->curr_tn); cr_array_index = 0; block_saved = FALSE; } else { BLK_INIT(bs_ptr, bs1); BLK_SEG(bs_ptr, bp + sizeof(new_hdr), new_hdr.bsiz - sizeof(new_hdr)); BLK_FINI(bs_ptr, bs1); t_write(patch_curr_blk, (unsigned char *)bs1, 0, 0, blkBase, ((blk_hdr_ptr_t)blkBase)->levl, TRUE, FALSE); cr_array_index = 0; block_saved = FALSE; if (JNL_ENABLED(cs_data)) { JNL_SHORT_TIME(jgbl.gbl_jrec_time); /* needed for jnl_put_jrt_pini() and jnl_write_aimg_rec() */ jnl_status = jnl_ensure_open(); if (0 == jnl_status) { cse = (cw_set_element *)(&cw_set[0]); cse->new_buff = non_tp_jfb_buff_ptr; gvcst_blk_build(cse, (uchar_ptr_t)cse->new_buff, x); cse->done = TRUE; if (0 == cs_addrs->jnl->pini_addr) jnl_put_jrt_pini(cs_addrs); jnl_write_aimg_rec(cs_addrs, cse->blk, (blk_hdr_ptr_t)cse->new_buff); } else rts_error(VARLSTCNT(6) jnl_status, 4, JNL_LEN_STR(cs_data), DB_LEN_STR(gv_cur_region)); } } /* Pass the desired tn "x" as argument to bg_update or mm_update */ if (dba_bg == cs_addrs->hdr->acc_meth) bg_update(cw_set, cw_set + cw_set_depth, cs_addrs->ti->curr_tn, x, dummysi); else mm_update(cw_set, cw_set + cw_set_depth, cs_addrs->ti->curr_tn, x, dummysi); cs_addrs->ti->curr_tn++; assert(cs_addrs->ti->early_tn == cs_addrs->ti->curr_tn); /* the following code is analogous to that in t_end and should be maintained in a similar fashion */ while (cr_array_index) cr_array[--cr_array_index]->in_cw_set = FALSE; rel_crit(gv_cur_region); if (block_saved) backup_buffer_flush(gv_cur_region); UNIX_ONLY( if (unhandled_stale_timer_pop) process_deferred_stale(); ) wcs_timer_start(gv_cur_region, TRUE); }
int gtmrecv_get_opt(void) { boolean_t log; unsigned short log_file_len; boolean_t buffsize_status; boolean_t filter; unsigned short filter_cmd_len; int timeout_status; boolean_t listenport_status; unsigned short statslog_val_len; char statslog_val[4]; /* "ON" or "OFF" */ int num_actions; num_actions = 0; num_actions += ((gtmrecv_options.start = (CLI_PRESENT == cli_present("START"))) ? 1 : 0); num_actions += ((gtmrecv_options.shut_down = (CLI_PRESENT == cli_present("SHUTDOWN"))) ? 1 : 0); num_actions += ((gtmrecv_options.checkhealth = (CLI_PRESENT == cli_present("CHECKHEALTH"))) ? 1 : 0); num_actions += ((gtmrecv_options.statslog = (CLI_PRESENT == cli_present("STATSLOG"))) ? 1 : 0); num_actions += ((gtmrecv_options.showbacklog = (CLI_PRESENT == cli_present("SHOWBACKLOG"))) ? 1 : 0); num_actions += ((gtmrecv_options.changelog = (CLI_PRESENT == cli_present("CHANGELOG"))) ? 1 : 0); if (1 < num_actions) { util_out_print("Invalid mixing of action qualifiers. Only one of START, SHUTDOWN, CHECKHEALTH, STATSLOG, " "SHOWBACKLOG, CHANGELOG should be specified", TRUE); return (-1); } else if (0 == num_actions) { util_out_print("No action qualifier specified. One of START, SHUTDOWN, CHECKHEALTH, STATSLOG, SHOWBACKLOG, " "CHANGELOG should be specified", TRUE); return (-1); } gtmrecv_options.updateonly = (CLI_PRESENT == cli_present("UPDATEONLY")); gtmrecv_options.updateresync = (CLI_PRESENT == cli_present("UPDATERESYNC")); if (gtmrecv_options.start && !gtmrecv_options.updateonly) { if (!(listenport_status = (CLI_PRESENT == cli_present("LISTENPORT")))) { util_out_print("LISTENPORT should be specfied with START", TRUE); return (-1); } else if (!cli_get_num("LISTENPORT", >mrecv_options.listen_port)) { util_out_print("Error parsing LISTENPORT qualifier", TRUE); return (-1); } if (buffsize_status = (CLI_PRESENT == cli_present("BUFFSIZE"))) { if (!cli_get_num("BUFFSIZE", >mrecv_options.buffsize)) { util_out_print("Error parsing BUFFSIZE qualifier", TRUE); return (-1); } if (MIN_RECVPOOL_SIZE > gtmrecv_options.buffsize) gtmrecv_options.buffsize = MIN_RECVPOOL_SIZE; } else gtmrecv_options.buffsize = DEFAULT_RECVPOOL_SIZE; /* Round up or down buffsize */ if (filter = (CLI_PRESENT == cli_present("FILTER"))) { filter_cmd_len = MAX_FILTER_CMD_LEN; if (!cli_get_str("FILTER", gtmrecv_options.filter_cmd, &filter_cmd_len)) { util_out_print("Error parsing FILTER qualifier", TRUE); return (-1); } } else gtmrecv_options.filter_cmd[0] = '\0'; gtmrecv_options.stopsourcefilter = (CLI_PRESENT == cli_present("STOPSOURCEFILTER")); } if ((gtmrecv_options.start && !gtmrecv_options.updateonly) || gtmrecv_options.statslog || gtmrecv_options.changelog) { log = (CLI_PRESENT == cli_present("LOG")); if ((gtmrecv_options.start && !gtmrecv_options.updateonly || gtmrecv_options.changelog) && !log) { util_out_print("LOG should be specified with START or CHANGELOG", TRUE); return (-1); } if (log) { log_file_len = MAX_FN_LEN + 1; if (!cli_get_str("LOG", gtmrecv_options.log_file, &log_file_len)) { util_out_print("Error parsing LOG qualifier", TRUE); return (-1); } } else gtmrecv_options.log_file[0] = '\0'; } if (!gtmrecv_options.start && gtmrecv_options.updateresync) { util_out_print("UPDATERESYNC can be used only with START", TRUE); gtmrecv_options.updateresync = FALSE; return (-1); } if (gtmrecv_options.shut_down) { if (CLI_PRESENT == (timeout_status = cli_present("TIMEOUT"))) { if (!cli_get_num("TIMEOUT", >mrecv_options.shutdown_time)) { util_out_print("Error parsing TIMEOUT qualifier", TRUE); return (-1); } if (DEFAULT_SHUTDOWN_TIMEOUT < gtmrecv_options.shutdown_time || 0 > gtmrecv_options.shutdown_time) { gtmrecv_options.shutdown_time = DEFAULT_SHUTDOWN_TIMEOUT; util_out_print("shutdown TIMEOUT changed to !UL", TRUE, gtmrecv_options.shutdown_time); } } else if (CLI_NEGATED == timeout_status) gtmrecv_options.shutdown_time = -1; else /* TIMEOUT not specified */ gtmrecv_options.shutdown_time = DEFAULT_SHUTDOWN_TIMEOUT; } if (gtmrecv_options.statslog) { statslog_val_len = 4; /* max(strlen("ON"), strlen("OFF")) + 1 */ if (!cli_get_str("STATSLOG", statslog_val, &statslog_val_len)) { util_out_print("Error parsing STATSLOG qualifier", TRUE); return (-1); } #ifdef UNIX cli_strupper(statslog_val); #endif if (0 == strcmp(statslog_val, "ON")) gtmrecv_options.statslog = TRUE; else if (0 == strcmp(statslog_val, "OFF")) gtmrecv_options.statslog = FALSE; else { util_out_print("Invalid value for STATSLOG qualifier, should be either ON or OFF", TRUE); return (-1); } } return (0); }