Skip to content

Commit

Permalink
[CBRD-25295] [11.3] Set ppid of broker/cas proc created by cub_manage…
Browse files Browse the repository at this point in the history
…r to 1 (#99)

Set ppid of broker/cas proc created by cub_manager to 1
  • Loading branch information
kisoo-han authored Apr 11, 2024
1 parent 84cd82b commit 358b3f0
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 1 deletion.
14 changes: 13 additions & 1 deletion server/src/cm_cmd_exec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,13 +466,20 @@ read_error_file (const char *err_file, char *err_buf, int err_buf_size)
char rm_prev_flag = 0;
char is_debug = 0;
size_t i;
int append_end = 1;

if (err_buf == NULL || err_file == NULL || err_file[0] == '\0'
|| err_buf_size == 0)
{
return 0;
}

if (err_buf_size < 0)
{
err_buf_size = DBMT_ERROR_MSG_SIZE;
append_end = 0;
}

memset (err_buf, 0, err_buf_size);

fp = fopen (err_file, "r");
Expand Down Expand Up @@ -530,7 +537,12 @@ read_error_file (const char *err_file, char *err_buf, int err_buf_size)
{
msg_size = 0;
}
strcat (buf, "<end>");

if (append_end)
{
strcat (buf, "<end>");
}

if ((err_buf_size - msg_size - 1) > 0)
{
strncpy (err_buf + msg_size, buf, err_buf_size - msg_size - 1);
Expand Down
69 changes: 69 additions & 0 deletions server/src/cm_job_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1043,13 +1043,46 @@ int
ts2_start_unicas (nvplist *in, nvplist *out, char *_dbmt_error)
{
T_CM_ERROR error;

#if !defined (WINDOWS)
const char *argv[3];
char cmd_name[CUBRID_CMD_NAME_LEN];
char cubrid_err_file[PATH_MAX];
int argc = 0;
int retval = ERR_NO_ERROR;
int rc;
#endif

#if defined (WINDOWS)
if (cm_broker_env_start (&error) < 0)
{
strcpy (_dbmt_error, error.err_msg);
return ERR_WITH_MSG;
}

return ERR_NO_ERROR;
#else
#if !defined (DO_NOT_USE_CUBRIDENV)
sprintf (cmd_name, "%s/%s%s", sco.szCubrid, CUBRID_DIR_BIN, UTIL_BROKER_NAME);
#else
sprintf (cmd_name, "%s/%s", CUBRID_BINDIR, UTIL_BROKER_NAME);
#endif
argv[argc++] = cmd_name;
argv[argc++] = "start";
argv[argc++] = NULL;

make_temp_filepath (cubrid_err_file, sco.dbmt_tmp_dir, "broker_start", TS2_STARTBROKER, PATH_MAX);
if (run_child (argv, 1, NULL, NULL, cubrid_err_file, &rc) < 0 || rc != 0)
{
if (read_error_file (cubrid_err_file, _dbmt_error, -1) < 0)
{
retval = ERR_WITH_MSG;
}
}

unlink (cubrid_err_file);
return retval;
#endif
}

int
Expand Down Expand Up @@ -1539,18 +1572,54 @@ ts2_start_broker (nvplist *in, nvplist *out, char *_dbmt_error)
char *bname;
T_CM_ERROR error;

#if !defined (WINDOWS)
const char *argv[4];
char cubrid_err_file[PATH_MAX];
char cmd_name[CUBRID_CMD_NAME_LEN];
int retval = ERR_NO_ERROR;
int argc = 0;
int rc = 0;
#endif

if ((bname = nv_get_val (in, "bname")) == NULL)
{
strcpy (_dbmt_error, "broker name");
return ERR_PARAM_MISSING;
}

#if defined (WINDOWS)
if (cm_broker_on (bname, &error) < 0)
{
strcpy (_dbmt_error, error.err_msg);
return ERR_WITH_MSG;
}
return ERR_NO_ERROR;
#else

#if !defined (DO_NOT_USE_CUBRIDENV)
sprintf (cmd_name, "%s/%s%s", sco.szCubrid, CUBRID_DIR_BIN, UTIL_BROKER_NAME);
#else
sprintf (cmd_name, "%s/%s", CUBRID_BINDIR, UTIL_BROKER_NAME);
#endif

argv[argc++] = cmd_name;
argv[argc++] = "on";
argv[argc++] = bname;
argv[argc++] = NULL;

make_temp_filepath (cubrid_err_file, sco.dbmt_tmp_dir, "broker_start", TS2_STARTBROKER, PATH_MAX);

if (run_child (argv, 1, NULL, NULL, cubrid_err_file, &rc) < 0 || rc != 0)
{
if (read_error_file (cubrid_err_file, _dbmt_error, -1) < 0)
{
retval = ERR_WITH_MSG;
}
}

unlink (cubrid_err_file);
return retval;
#endif
}

int
Expand Down

0 comments on commit 358b3f0

Please sign in to comment.