[mpich2-commits] r4157 - in mpich2/trunk/src/pm/hydra: bootstrap/fork bootstrap/slurm bootstrap/ssh include pm/pmiserv utils/env utils/launch utils/string
balaji at mcs.anl.gov
balaji at mcs.anl.gov
Sun Mar 22 01:18:32 CDT 2009
Author: balaji
Date: 2009-03-22 01:18:32 -0500 (Sun, 22 Mar 2009)
New Revision: 4157
Modified:
mpich2/trunk/src/pm/hydra/bootstrap/fork/fork_launch.c
mpich2/trunk/src/pm/hydra/bootstrap/slurm/slurm_launch.c
mpich2/trunk/src/pm/hydra/bootstrap/ssh/ssh_launch.c
mpich2/trunk/src/pm/hydra/include/hydra_utils.h
mpich2/trunk/src/pm/hydra/pm/pmiserv/pmi_handle_v1.c
mpich2/trunk/src/pm/hydra/pm/pmiserv/pmi_proxy.c
mpich2/trunk/src/pm/hydra/pm/pmiserv/pmi_serv_launch.c
mpich2/trunk/src/pm/hydra/utils/env/env.c
mpich2/trunk/src/pm/hydra/utils/launch/launch.c
mpich2/trunk/src/pm/hydra/utils/string/string.c
Log:
Fixed a bug in the passing of local environment variables + general
cleanup and compression of code.
Modified: mpich2/trunk/src/pm/hydra/bootstrap/fork/fork_launch.c
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/fork/fork_launch.c 2009-03-22 05:18:11 UTC (rev 4156)
+++ mpich2/trunk/src/pm/hydra/bootstrap/fork/fork_launch.c 2009-03-22 06:18:32 UTC (rev 4157)
@@ -35,7 +35,8 @@
/* The stdin pointer will be some value for process_id 0; for
* everyone else, it's NULL. */
- status = HYDU_create_process(client_arg, (process_id == 0 ? &handle.in : NULL),
+ status = HYDU_create_process(client_arg, NULL,
+ (process_id == 0 ? &handle.in : NULL),
&partition->out, &partition->err, &partition->pid, -1);
HYDU_ERR_POP(status, "create process returned error\n");
Modified: mpich2/trunk/src/pm/hydra/bootstrap/slurm/slurm_launch.c
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/slurm/slurm_launch.c 2009-03-22 05:18:11 UTC (rev 4156)
+++ mpich2/trunk/src/pm/hydra/bootstrap/slurm/slurm_launch.c 2009-03-22 06:18:32 UTC (rev 4157)
@@ -43,7 +43,8 @@
/* The stdin pointer will be some value for process_id 0; for
* everyone else, it's NULL. */
- status = HYDU_create_process(client_arg, (process_id == 0 ? &handle.in : NULL),
+ status = HYDU_create_process(client_arg, NULL,
+ (process_id == 0 ? &handle.in : NULL),
&partition->out, &partition->err, &partition->pid, -1);
if (status != HYD_SUCCESS) {
HYDU_Error_printf("bootstrap spawn process returned error\n");
Modified: mpich2/trunk/src/pm/hydra/bootstrap/ssh/ssh_launch.c
===================================================================
--- mpich2/trunk/src/pm/hydra/bootstrap/ssh/ssh_launch.c 2009-03-22 05:18:11 UTC (rev 4156)
+++ mpich2/trunk/src/pm/hydra/bootstrap/ssh/ssh_launch.c 2009-03-22 06:18:32 UTC (rev 4157)
@@ -55,7 +55,8 @@
/* The stdin pointer will be some value for process_id 0; for
* everyone else, it's NULL. */
- status = HYDU_create_process(client_arg, (process_id == 0 ? &handle.in : NULL),
+ status = HYDU_create_process(client_arg, NULL,
+ (process_id == 0 ? &handle.in : NULL),
&partition->out, &partition->err, &partition->pid, -1);
HYDU_ERR_POP(status, "create process returned error\n");
Modified: mpich2/trunk/src/pm/hydra/include/hydra_utils.h
===================================================================
--- mpich2/trunk/src/pm/hydra/include/hydra_utils.h 2009-03-22 05:18:11 UTC (rev 4156)
+++ mpich2/trunk/src/pm/hydra/include/hydra_utils.h 2009-03-22 06:18:32 UTC (rev 4157)
@@ -33,7 +33,8 @@
HYD_Status HYDU_env_free_list(HYD_Env_t * env);
HYD_Env_t *HYDU_env_lookup(HYD_Env_t env, HYD_Env_t * env_list);
HYD_Status HYDU_append_env_to_list(HYD_Env_t env, HYD_Env_t ** env_list);
-void HYDU_putenv(char *env_str);
+HYD_Status HYDU_putenv(HYD_Env_t * env);
+HYD_Status HYDU_putenv_list(HYD_Env_t * env_list);
HYD_Status HYDU_comma_list_to_env_list(char *str, HYD_Env_t ** env_list);
@@ -47,8 +48,8 @@
struct HYD_Partition **partition_list);
HYD_Status HYDU_alloc_partition_exec(struct HYD_Partition_exec **exec);
HYD_Status HYDU_create_host_list(char *host_file, struct HYD_Partition **partition_list);
-HYD_Status HYDU_create_process(char **client_arg, int *in, int *out, int *err,
- int *pid, int core);
+HYD_Status HYDU_create_process(char **client_arg, HYD_Env_t * env_list,
+ int *in, int *out, int *err, int *pid, int core);
/* signals */
@@ -129,8 +130,9 @@
void HYDU_free_strlist(char **args);
HYD_Status HYDU_str_alloc_and_join(char **strlist, char **strjoin);
HYD_Status HYDU_strsplit(char *str, char **str1, char **str2, char sep);
-HYD_Status HYDU_int_to_str(int x, char **str);
+char *HYDU_int_to_str(int x);
char *HYDU_strerror(int error);
+int HYDU_strlist_lastidx(char **strlist);
/* Timer utilities */
Modified: mpich2/trunk/src/pm/hydra/pm/pmiserv/pmi_handle_v1.c
===================================================================
--- mpich2/trunk/src/pm/hydra/pm/pmiserv/pmi_handle_v1.c 2009-03-22 05:18:11 UTC (rev 4156)
+++ mpich2/trunk/src/pm/hydra/pm/pmiserv/pmi_handle_v1.c 2009-03-22 06:18:32 UTC (rev 4157)
@@ -82,7 +82,7 @@
HYD_Status HYD_PMCD_pmi_handle_v1_initack(int fd, char *args[])
{
int id, size, debug, i;
- char *ssize, *srank, *sdebug, *tmp[HYDU_NUM_JOIN_STR], *cmd;
+ char *tmp[HYDU_NUM_JOIN_STR], *cmd;
struct HYD_Partition *partition;
struct HYD_Partition_exec *exec;
HYD_PMCD_pmi_pg_t *run;
@@ -100,34 +100,25 @@
debug = handle.debug;
- status = HYDU_int_to_str(size, &ssize);
- HYDU_ERR_POP(status, "unable to convert int to string\n");
-
- status = HYDU_int_to_str(id, &srank);
- HYDU_ERR_POP(status, "unable to convert int to string\n");
-
- status = HYDU_int_to_str(debug, &sdebug);
- HYDU_ERR_POP(status, "unable to convert int to string\n");
-
i = 0;
- tmp[i++] = "cmd=initack\ncmd=set size=";
- tmp[i++] = ssize;
- tmp[i++] = "\ncmd=set rank=";
- tmp[i++] = srank;
- tmp[i++] = "\ncmd=set debug=";
- tmp[i++] = sdebug;
- tmp[i++] = "\n";
+ tmp[i++] = MPIU_Strdup("cmd=initack\ncmd=set size=");
+ tmp[i++] = HYDU_int_to_str(size);
+ tmp[i++] = MPIU_Strdup("\ncmd=set rank=");
+ tmp[i++] = HYDU_int_to_str(id);
+ tmp[i++] = MPIU_Strdup("\ncmd=set debug=");
+ tmp[i++] = HYDU_int_to_str(debug);
+ tmp[i++] = MPIU_Strdup("\n");
tmp[i++] = NULL;
status = HYDU_str_alloc_and_join(tmp, &cmd);
HYDU_ERR_POP(status, "error while joining strings\n");
+ for (i = 0; tmp[i]; i++)
+ HYDU_FREE(tmp[i]);
+
status = HYDU_sock_writeline(fd, cmd, strlen(cmd));
HYDU_ERR_POP(status, "error writing PMI line\n");
- HYDU_FREE(ssize);
- HYDU_FREE(srank);
- HYDU_FREE(sdebug);
HYDU_FREE(cmd);
run = pg_list;
@@ -151,41 +142,30 @@
{
int i;
char *tmp[HYDU_NUM_JOIN_STR], *cmd;
- char *maxkvsname, *maxkeylen, *maxvallen;
HYD_Status status = HYD_SUCCESS;
HYDU_FUNC_ENTER();
- status = HYDU_int_to_str(MAXKVSNAME, &maxkvsname);
- HYDU_ERR_POP(status, "unable to convert int to string\n");
-
- status = HYDU_int_to_str(MAXKEYLEN, &maxkeylen);
- HYDU_ERR_POP(status, "unable to convert int to string\n");
-
- status = HYDU_int_to_str(MAXVALLEN, &maxvallen);
- HYDU_ERR_POP(status, "unable to convert int to string\n");
-
i = 0;
- tmp[i++] = "cmd=maxes kvsname_max=";
- tmp[i++] = maxkvsname;
- tmp[i++] = " keylen_max=";
- tmp[i++] = maxkeylen;
- tmp[i++] = " vallen_max=";
- tmp[i++] = maxvallen;
- tmp[i++] = "\n";
+ tmp[i++] = MPIU_Strdup("cmd=maxes kvsname_max=");
+ tmp[i++] = HYDU_int_to_str(MAXKVSNAME);
+ tmp[i++] = MPIU_Strdup(" keylen_max=");
+ tmp[i++] = HYDU_int_to_str(MAXKEYLEN);
+ tmp[i++] = MPIU_Strdup(" vallen_max=");
+ tmp[i++] = HYDU_int_to_str(MAXVALLEN);
+ tmp[i++] = MPIU_Strdup("\n");
tmp[i++] = NULL;
status = HYDU_str_alloc_and_join(tmp, &cmd);
HYDU_ERR_POP(status, "unable to join strings\n");
+ for (i = 0; tmp[i]; i++)
+ HYDU_FREE(tmp[i]);
+
status = HYDU_sock_writeline(fd, cmd, strlen(cmd));
HYDU_ERR_POP(status, "error writing PMI line\n");
HYDU_FREE(cmd);
- HYDU_FREE(maxkvsname);
- HYDU_FREE(maxkeylen);
- HYDU_FREE(maxvallen);
-
fn_exit:
HYDU_FUNC_EXIT();
return status;
@@ -198,7 +178,6 @@
HYD_Status HYD_PMCD_pmi_handle_v1_get_appnum(int fd, char *args[])
{
char *tmp[HYDU_NUM_JOIN_STR], *cmd;
- char *sapp_num;
int i;
HYD_PMCD_pmi_process_t *process;
HYD_Status status = HYD_SUCCESS;
@@ -210,24 +189,22 @@
if (process == NULL) /* We didn't find the process */
HYDU_ERR_SETANDJUMP(status, HYD_INTERNAL_ERROR, "unable to find process structure\n");
- status = HYDU_int_to_str(process->pg->id, &sapp_num);
- HYDU_ERR_POP(status, "unable to convert int to string\n");
-
i = 0;
- tmp[i++] = "cmd=appnum appnum=";
- tmp[i++] = sapp_num;
- tmp[i++] = "\n";
+ tmp[i++] = MPIU_Strdup("cmd=appnum appnum=");
+ tmp[i++] = HYDU_int_to_str(process->pg->id);
+ tmp[i++] = MPIU_Strdup("\n");
tmp[i++] = NULL;
status = HYDU_str_alloc_and_join(tmp, &cmd);
HYDU_ERR_POP(status, "unable to join strings\n");
+ for (i = 0; tmp[i]; i++)
+ HYDU_FREE(tmp[i]);
+
status = HYDU_sock_writeline(fd, cmd, strlen(cmd));
HYDU_ERR_POP(status, "error writing PMI line\n");
HYDU_FREE(cmd);
- HYDU_FREE(sapp_num);
-
fn_exit:
HYDU_FUNC_EXIT();
return status;
@@ -487,7 +464,7 @@
HYD_Status HYD_PMCD_pmi_handle_v1_get_usize(int fd, char *args[])
{
int usize, i;
- char *tmp[HYDU_NUM_JOIN_STR], *cmd, *usize_str;
+ char *tmp[HYDU_NUM_JOIN_STR], *cmd;
HYD_Status status = HYD_SUCCESS;
HYDU_FUNC_ENTER();
@@ -495,12 +472,9 @@
status = HYD_BSCI_get_usize(&usize);
HYDU_ERR_POP(status, "unable to get bootstrap universe size\n");
- status = HYDU_int_to_str(usize, &usize_str);
- HYDU_ERR_POP(status, "unable to convert int to string\n");
-
i = 0;
tmp[i++] = "cmd=universe_size size=";
- tmp[i++] = usize_str;
+ tmp[i++] = HYDU_int_to_str(usize);
tmp[i++] = "\n";
tmp[i++] = NULL;
Modified: mpich2/trunk/src/pm/hydra/pm/pmiserv/pmi_proxy.c
===================================================================
--- mpich2/trunk/src/pm/hydra/pm/pmiserv/pmi_proxy.c 2009-03-22 05:18:11 UTC (rev 4156)
+++ mpich2/trunk/src/pm/hydra/pm/pmiserv/pmi_proxy.c 2009-03-22 06:18:32 UTC (rev 4157)
@@ -61,38 +61,21 @@
HYD_PMCD_pmi_proxy_params.exit_status[i] = -1;
/* For local spawning, set the global environment here itself */
- for (env = HYD_PMCD_pmi_proxy_params.global_env; env; env = env->next) {
- j = 0;
- tmp[j++] = MPIU_Strdup(env->env_name);
- tmp[j++] = MPIU_Strdup("=");
- tmp[j++] = MPIU_Strdup(env->env_value);
- tmp[j++] = NULL;
- status = HYDU_str_alloc_and_join(tmp, &str);
- HYDU_ERR_POP(status, "unable to join strings\n");
- HYDU_putenv(str);
- for (j = 0; tmp[j]; j++)
- HYDU_FREE(tmp[j]);
- }
+ status = HYDU_putenv_list(HYD_PMCD_pmi_proxy_params.global_env);
+ HYDU_ERR_POP(status, "putenv returned error\n");
/* Spawn the processes */
process_id = 0;
for (exec = HYD_PMCD_pmi_proxy_params.exec_list; exec; exec = exec->next) {
for (i = 0; i < exec->proc_count; i++) {
- j = 0;
- tmp[j++] = MPIU_Strdup("PMI_ID=");
- status = HYDU_int_to_str(HYD_PMCD_pmi_proxy_params.pmi_id + process_id, &str);
- HYDU_ERR_POP(status, "unable to convert int to string\n");
- tmp[j++] = MPIU_Strdup(str);
+
+ str = HYDU_int_to_str(HYD_PMCD_pmi_proxy_params.pmi_id + process_id);
+ status = HYDU_env_create(&env, "PMI_ID", str);
+ HYDU_ERR_POP(status, "unable to create env\n");
HYDU_FREE(str);
- tmp[j++] = NULL;
+ status = HYDU_putenv(env);
+ HYDU_ERR_POP(status, "putenv failed\n");
- status = HYDU_str_alloc_and_join(tmp, &str);
- HYDU_ERR_POP(status, "unable to join strings\n");
-
- HYDU_putenv(str);
- for (j = 0; tmp[j]; j++)
- HYDU_FREE(tmp[j]);
-
if (chdir(HYD_PMCD_pmi_proxy_params.wdir) < 0)
HYDU_ERR_SETANDJUMP1(status, HYD_INTERNAL_ERROR,
"unable to change wdir (%s)\n", HYDU_strerror(errno));
@@ -102,14 +85,16 @@
client_args[arg++] = NULL;
if ((process_id + HYD_PMCD_pmi_proxy_params.pmi_id) == 0) {
- status = HYDU_create_process(client_args, &HYD_PMCD_pmi_proxy_params.in,
+ status = HYDU_create_process(client_args, exec->prop_env,
+ &HYD_PMCD_pmi_proxy_params.in,
&HYD_PMCD_pmi_proxy_params.out[process_id],
&HYD_PMCD_pmi_proxy_params.err[process_id],
&HYD_PMCD_pmi_proxy_params.pid[process_id],
process_id);
}
else {
- status = HYDU_create_process(client_args, NULL,
+ status = HYDU_create_process(client_args, exec->prop_env,
+ NULL,
&HYD_PMCD_pmi_proxy_params.out[process_id],
&HYD_PMCD_pmi_proxy_params.err[process_id],
&HYD_PMCD_pmi_proxy_params.pid[process_id],
@@ -117,8 +102,6 @@
}
HYDU_ERR_POP(status, "spawn process returned error\n");
- HYDU_FREE(str);
-
process_id++;
}
}
Modified: mpich2/trunk/src/pm/hydra/pm/pmiserv/pmi_serv_launch.c
===================================================================
--- mpich2/trunk/src/pm/hydra/pm/pmiserv/pmi_serv_launch.c 2009-03-22 05:18:11 UTC (rev 4156)
+++ mpich2/trunk/src/pm/hydra/pm/pmiserv/pmi_serv_launch.c 2009-03-22 06:18:32 UTC (rev 4157)
@@ -36,7 +36,7 @@
*/
HYD_Status HYD_PMCI_launch_procs(void)
{
- char *port_range, *port_str, *sport, *str;
+ char *port_range, *port_str, *sport;
uint16_t port;
int i, arg, process_id;
char hostname[MAX_HOSTNAME_LEN];
@@ -74,8 +74,7 @@
HYDU_ERR_SETANDJUMP2(status, HYD_SOCK_ERROR,
"gethostname error (hostname: %s; errno: %d)\n", hostname, errno);
- status = HYDU_int_to_str(port, &sport);
- HYDU_ERR_POP(status, "cannot convert int to string\n");
+ sport = HYDU_int_to_str(port);
HYDU_MALLOC(port_str, char *, strlen(hostname) + 1 + strlen(sport) + 1, status);
MPIU_Snprintf(port_str, strlen(hostname) + 1 + strlen(sport) + 1,
@@ -105,7 +104,7 @@
process_id = 0;
for (partition = handle.partition_list; partition; partition = partition->next) {
- for (arg = 0; partition->proxy_args[arg]; arg++);
+ arg = HYDU_strlist_lastidx(partition->proxy_args);
i = 0;
path_str[i++] = MPIU_Strdup(handle.base_path);
path_str[i++] = MPIU_Strdup("pmi_proxy");
@@ -114,17 +113,11 @@
HYDU_ERR_POP(status, "unable to join strings\n");
HYDU_free_strlist(path_str);
- status = HYDU_int_to_str(handle.proxy_port, &str);
- HYDU_ERR_POP(status, "unable to convert in to string\n");
partition->proxy_args[arg++] = MPIU_Strdup("--proxy-port");
- partition->proxy_args[arg++] = MPIU_Strdup(str);
- HYDU_FREE(str);
+ partition->proxy_args[arg++] = HYDU_int_to_str(handle.proxy_port);
- status = HYDU_int_to_str(handle.one_pass_count, &str);
- HYDU_ERR_POP(status, "unable to convert in to string\n");
partition->proxy_args[arg++] = MPIU_Strdup("--one-pass-count");
- partition->proxy_args[arg++] = MPIU_Strdup(str);
- HYDU_FREE(str);
+ partition->proxy_args[arg++] = HYDU_int_to_str(handle.one_pass_count);
partition->proxy_args[arg++] = MPIU_Strdup("--wdir");
partition->proxy_args[arg++] = MPIU_Strdup(handle.wdir);
@@ -134,41 +127,30 @@
partition->proxy_args[arg++] = MPIU_Strdup("--global-env");
for (i = 0, env = handle.system_env; env; env = env->next, i++);
for (env = handle.prop_env; env; env = env->next, i++);
- status = HYDU_int_to_str(i, &str);
- HYDU_ERR_POP(status, "unable to convert int to string\n");
- partition->proxy_args[arg++] = MPIU_Strdup(str);
- HYDU_FREE(str);
+ partition->proxy_args[arg++] = HYDU_int_to_str(i);
partition->proxy_args[arg++] = NULL;
HYDU_list_append_env_to_str(handle.system_env, partition->proxy_args);
HYDU_list_append_env_to_str(handle.prop_env, partition->proxy_args);
- status = HYDU_int_to_str(process_id, &str);
- HYDU_ERR_POP(status, "unable to convert int to string\n");
- for (arg = 0; partition->proxy_args[arg]; arg++);
+ arg = HYDU_strlist_lastidx(partition->proxy_args);
partition->proxy_args[arg++] = MPIU_Strdup("--pmi-id");
- partition->proxy_args[arg++] = MPIU_Strdup(str);
- HYDU_FREE(str);
+ partition->proxy_args[arg++] = HYDU_int_to_str(process_id);;
partition->proxy_args[arg++] = NULL;
/* Now pass the local executable information */
for (exec = partition->exec_list; exec; exec = exec->next) {
- for (arg = 0; partition->proxy_args[arg]; arg++);
+ arg = HYDU_strlist_lastidx(partition->proxy_args);
partition->proxy_args[arg++] = MPIU_Strdup("--exec");
- status = HYDU_int_to_str(exec->proc_count, &str);
- HYDU_ERR_POP(status, "unable to convert int to string\n");
partition->proxy_args[arg++] = MPIU_Strdup("--proc-count");
- partition->proxy_args[arg++] = MPIU_Strdup(str);
- HYDU_FREE(str);
+ partition->proxy_args[arg++] = HYDU_int_to_str(exec->proc_count);
partition->proxy_args[arg++] = NULL;
- for (arg = 0; partition->proxy_args[arg]; arg++);
+ arg = HYDU_strlist_lastidx(partition->proxy_args);
partition->proxy_args[arg++] = MPIU_Strdup("--local-env");
for (i = 0, env = exec->prop_env; env; env = env->next, i++);
- status = HYDU_int_to_str(i, &str);
HYDU_ERR_POP(status, "unable to convert int to string\n");
- partition->proxy_args[arg++] = MPIU_Strdup(str);
- HYDU_FREE(str);
+ partition->proxy_args[arg++] = HYDU_int_to_str(i);
partition->proxy_args[arg++] = NULL;
HYDU_list_append_env_to_str(exec->prop_env, partition->proxy_args);
Modified: mpich2/trunk/src/pm/hydra/utils/env/env.c
===================================================================
--- mpich2/trunk/src/pm/hydra/utils/env/env.c 2009-03-22 05:18:11 UTC (rev 4156)
+++ mpich2/trunk/src/pm/hydra/utils/env/env.c 2009-03-22 06:18:32 UTC (rev 4157)
@@ -96,12 +96,11 @@
HYDU_FUNC_ENTER();
- for (i = 0; str_list[i]; i++);
+ i = HYDU_strlist_lastidx(str_list);
env = env_list;
while (env) {
status = env_to_str(env, &str_list[i++]);
HYDU_ERR_POP(status, "env_to_str returned error\n");
-
env = env->next;
}
str_list[i++] = NULL;
@@ -309,17 +308,59 @@
}
-void HYDU_putenv(char *env_str)
+HYD_Status HYDU_putenv(HYD_Env_t * env)
{
+ char *tmp[HYDU_NUM_JOIN_STR], *str;
+ int i;
+ HYD_Status status = HYD_SUCCESS;
+
HYDU_FUNC_ENTER();
- MPIU_PutEnv(env_str);
+ i = 0;
+ tmp[i++] = MPIU_Strdup(env->env_name);
+ tmp[i++] = MPIU_Strdup("=");
+ tmp[i++] = MPIU_Strdup(env->env_value);
+ tmp[i++] = NULL;
+ status = HYDU_str_alloc_and_join(tmp, &str);
+ HYDU_ERR_POP(status, "unable to join strings\n");
+ MPIU_PutEnv(str);
+
+ for (i = 0; tmp[i]; i++)
+ HYDU_FREE(tmp[i]);
+
+ fn_exit:
HYDU_FUNC_EXIT();
- return;
+ return status;
+
+ fn_fail:
+ goto fn_exit;
}
+HYD_Status HYDU_putenv_list(HYD_Env_t * env_list)
+{
+ HYD_Env_t *env;
+ int i;
+ char *tmp[HYDU_NUM_JOIN_STR], *str;
+ HYD_Status status = HYD_SUCCESS;
+
+ HYDU_FUNC_ENTER();
+
+ for (env = env_list; env; env = env->next) {
+ status = HYDU_putenv(env);
+ HYDU_ERR_POP(status, "putenv failed\n");
+ }
+
+ fn_exit:
+ HYDU_FUNC_EXIT();
+ return status;
+
+ fn_fail:
+ goto fn_exit;
+}
+
+
HYD_Status HYDU_comma_list_to_env_list(char *str, HYD_Env_t ** env_list)
{
char *env_name;
Modified: mpich2/trunk/src/pm/hydra/utils/launch/launch.c
===================================================================
--- mpich2/trunk/src/pm/hydra/utils/launch/launch.c 2009-03-22 05:18:11 UTC (rev 4156)
+++ mpich2/trunk/src/pm/hydra/utils/launch/launch.c 2009-03-22 06:18:32 UTC (rev 4157)
@@ -6,8 +6,8 @@
#include "hydra_utils.h"
-HYD_Status HYDU_create_process(char **client_arg, int *in, int *out, int *err,
- int *pid, int core)
+HYD_Status HYDU_create_process(char **client_arg, HYD_Env_t * env_list,
+ int *in, int *out, int *err, int *pid, int core)
{
int inpipe[2], outpipe[2], errpipe[2], tpid;
HYD_Status status = HYD_SUCCESS;
@@ -52,6 +52,9 @@
HYDU_ERR_SETANDJUMP1(status, HYD_SOCK_ERROR, "dup2 error (%s)\n",
HYDU_strerror(errno));
+ status = HYDU_putenv_list(env_list);
+ HYDU_ERR_POP(status, "unable to putenv\n");
+
if (execvp(client_arg[0], client_arg) < 0) {
HYDU_ERR_SETANDJUMP1(status, HYD_INTERNAL_ERROR, "execvp error (%s)\n",
HYDU_strerror(errno));
Modified: mpich2/trunk/src/pm/hydra/utils/string/string.c
===================================================================
--- mpich2/trunk/src/pm/hydra/utils/string/string.c 2009-03-22 05:18:11 UTC (rev 4156)
+++ mpich2/trunk/src/pm/hydra/utils/string/string.c 2009-03-22 06:18:32 UTC (rev 4157)
@@ -13,7 +13,7 @@
HYDU_FUNC_ENTER();
- for (i = 0; dest_strlist[i]; i++);
+ i = HYDU_strlist_lastidx(dest_strlist);
for (j = 0; src_strlist[j]; j++)
dest_strlist[i++] = MPIU_Strdup(src_strlist[j]);
dest_strlist[i++] = NULL;
@@ -109,9 +109,10 @@
}
-HYD_Status HYDU_int_to_str(int x, char **str)
+char *HYDU_int_to_str(int x)
{
int len = 1, max = 10, y;
+ char *str;
HYD_Status status = HYD_SUCCESS;
HYDU_FUNC_ENTER();
@@ -128,15 +129,17 @@
max *= 10;
}
- *str = (char *) MPIU_Malloc(len + 1);
- if (*str == NULL)
+ str = (char *) MPIU_Malloc(len + 1);
+ if (str == NULL) {
HYDU_ERR_SETANDJUMP1(status, HYD_NO_MEM, "unable to allocate %d bytes\n", len + 1);
+ goto fn_fail;
+ }
- MPIU_Snprintf(*str, len + 1, "%d", x);
+ MPIU_Snprintf(str, len + 1, "%d", x);
fn_exit:
HYDU_FUNC_EXIT();
- return status;
+ return str;
fn_fail:
goto fn_exit;
@@ -155,3 +158,13 @@
return str;
}
+
+
+int HYDU_strlist_lastidx(char **strlist)
+{
+ int i;
+
+ for (i = 0; strlist[i]; i++);
+
+ return i;
+}
More information about the mpich2-commits
mailing list