Commit c852a5d5 authored by Pavan Balaji's avatar Pavan Balaji
Browse files

[svn-r3998] Squashing several compile warnings in Hydra. Also made the demux...

[svn-r3998] Squashing several compile warnings in Hydra. Also made the demux engine independent of the central Hydra handle so it can be used by the proxy more cleanly.
parent 1e609160
......@@ -11,15 +11,10 @@
HYD_Status HYD_BSCI_Finalize(void)
{
struct HYD_Proc_params *proc_params;
HYD_Status status = HYD_SUCCESS;
HYDU_FUNC_ENTER();
fn_exit:
HYDU_FUNC_EXIT();
return status;
fn_fail:
goto fn_exit;
}
......@@ -97,8 +97,8 @@ HYD_Status HYD_BSCI_Cleanup_procs(void)
{
struct HYD_Proc_params *proc_params;
struct HYD_Partition_list *partition;
char *client_arg[HYD_EXEC_ARGS], *hostname, **proc_list, *execname;
int i, arg, host_id, host_id_max;
char *client_arg[HYD_EXEC_ARGS], *execname;
int arg;
HYD_Status status = HYD_SUCCESS;
HYDU_FUNC_ENTER();
......
......@@ -60,8 +60,6 @@ HYD_Status HYD_BSCU_Set_common_signals(void (*handler) (int))
void HYD_BSCU_Signal_handler(int signal)
{
int status, pid, i;
HYDU_FUNC_ENTER();
if (signal == SIGINT || signal == SIGQUIT || signal == SIGTERM
......
......@@ -19,7 +19,7 @@ HYD_Handle handle;
*/
HYD_Status HYD_BSCU_Wait_for_completion(void)
{
int pid, ret_status, i, not_completed;
int pid, ret_status, not_completed;
struct HYD_Proc_params *proc_params;
struct HYD_Partition_list *partition;
HYD_Status status = HYD_SUCCESS;
......@@ -52,7 +52,7 @@ HYD_Status HYD_BSCU_Wait_for_completion(void)
}
}
}
if (HYD_CSU_Time_left() == 0)
if (HYDU_Time_left(handle.start, handle.timeout) == 0)
break;
/* FIXME: If we did not break out yet, add a small usleep to
......
......@@ -261,6 +261,7 @@ AC_OUTPUT(Makefile \
utils/sock/Makefile \
utils/signals/Makefile \
utils/launch/Makefile \
utils/timer/Makefile \
launcher/Makefile \
launcher/utils/Makefile \
launcher/${HYDRA_LAUNCHER}/Makefile \
......
......@@ -15,7 +15,6 @@ HYD_Handle handle;
HYD_Status HYD_CSI_Close_fd(int fd)
{
int i;
struct HYD_Proc_params *proc_params;
struct HYD_Partition_list *partition;
HYD_Status status = HYD_SUCCESS;
......
......@@ -16,7 +16,7 @@ HYD_Status HYD_CSI_Launch_procs(void)
{
struct HYD_Proc_params *proc_params;
struct HYD_Partition_list *partition;
int stdin_fd, flags, count;
int stdin_fd;
HYD_Status status = HYD_SUCCESS;
HYDU_FUNC_ENTER();
......
......@@ -6,6 +6,7 @@
#include "hydra.h"
#include "csi.h"
#include "csiu.h"
#include "pmci.h"
#include "bsci.h"
#include "demux.h"
......@@ -14,7 +15,7 @@ HYD_Handle handle;
HYD_Status HYD_CSI_Wait_for_completion(void)
{
int sockets_open, i;
int sockets_open;
struct HYD_Proc_params *proc_params;
struct HYD_Partition_list *partition;
HYD_Status status = HYD_SUCCESS;
......@@ -23,7 +24,7 @@ HYD_Status HYD_CSI_Wait_for_completion(void)
while (1) {
/* Wait for some event to occur */
status = HYD_DMX_Wait_for_event();
status = HYD_DMX_Wait_for_event(HYDU_Time_left(handle.start, handle.timeout));
if (status != HYD_SUCCESS) {
HYDU_Error_printf("demux engine returned error when waiting for event\n");
goto fn_fail;
......@@ -43,7 +44,7 @@ HYD_Status HYD_CSI_Wait_for_completion(void)
break;
}
if (sockets_open && HYD_CSU_Time_left())
if (sockets_open && HYDU_Time_left(handle.start, handle.timeout))
continue;
/* Make sure all the processes have terminated. The bootstrap
......
......@@ -5,28 +5,3 @@
*/
#include "hydra.h"
HYD_Handle handle;
int HYD_CSU_Time_left(void)
{
struct timeval now;
int time_left;
HYDU_FUNC_ENTER();
if (handle.timeout.tv_sec < 0) {
time_left = -1;
goto fn_exit;
}
else {
gettimeofday(&now, NULL);
time_left = (1000 * (handle.timeout.tv_sec - now.tv_sec + handle.start.tv_sec));
if (time_left < 0)
time_left = 0;
}
fn_exit:
HYDU_FUNC_EXIT();
return time_left;
}
......@@ -7,6 +7,4 @@
#ifndef CSIU_H_INCLUDED
#define CSIU_H_INCLUDED
int HYD_CSU_Time_left(void);
#endif /* CSIU_H_INCLUDED */
......@@ -21,27 +21,6 @@ typedef struct HYD_DMXI_Callback {
static HYD_DMXI_Callback_t *cb_list = NULL;
static void print_callback_list()
{
HYD_DMXI_Callback_t *run;
int i, j;
run = cb_list;
i = 0;
printf("Callback list: ");
while (run) {
for (j = 0; j < run->num_fds; j++) {
if (run->fd[j] == -1)
continue;
printf("%d ", run->fd[j]);
i++;
}
run = run->next;
}
printf("\n");
}
HYD_Status HYD_DMX_Register_fd(int num_fds, int *fd, HYD_Event_t events,
HYD_Status(*callback) (int fd, HYD_Event_t events))
{
......@@ -122,10 +101,10 @@ HYD_Status HYD_DMX_Deregister_fd(int fd)
}
HYD_Status HYD_DMX_Wait_for_event(void)
HYD_Status HYD_DMX_Wait_for_event(int time)
{
int total_fds, i, j, events, ret;
HYD_DMXI_Callback_t *cb_element, *run;
HYD_DMXI_Callback_t *run;
struct pollfd *pollfds = NULL;
HYD_Status status = HYD_SUCCESS;
......@@ -155,7 +134,7 @@ HYD_Status HYD_DMX_Wait_for_event(void)
total_fds = i;
while (1) {
ret = poll(pollfds, total_fds, HYD_CSU_Time_left());
ret = poll(pollfds, total_fds, time);
if (ret < 0) {
if (errno == EINTR) {
/* We were interrupted by a system call; loop back */
......
......@@ -12,7 +12,7 @@
HYD_Status HYD_DMX_Register_fd(int num_fds, int *fd, HYD_Event_t events,
HYD_Status(*callback) (int fd, HYD_Event_t events));
HYD_Status HYD_DMX_Deregister_fd(int fd);
HYD_Status HYD_DMX_Wait_for_event(void);
HYD_Status HYD_DMX_Wait_for_event(int time);
HYD_Status HYD_DMX_Finalize(void);
#endif /* DEMUX_H_INCLUDED */
......@@ -31,8 +31,8 @@ struct HYD_Handle_ {
/* Start time and timeout. These are filled in by the launcher,
* but are utilized by the demux engine and the boot-strap server
* to decide how long we need to wait for. */
struct timeval start;
struct timeval timeout;
HYD_Time start;
HYD_Time timeout;
/* Each structure will contain all hosts/cores that use the same
* executable and environment. */
......
......@@ -158,6 +158,16 @@ extern char *strsignal(int);
HYD_Status HYDU_Set_signal(int signum, void (*handler) (int));
/* Timer utilities */
/* FIXME: HYD_Time should be OS specific */
#ifdef HAVE_TIME
#include <time.h>
#endif /* HAVE_TIME */
typedef struct timeval HYD_Time;
void HYDU_Time_set(HYD_Time time, int * val);
int HYDU_Time_left(HYD_Time start, HYD_Time timeout);
/* Sock utilities */
#include <poll.h>
#include <fcntl.h>
......
......@@ -45,8 +45,7 @@ HYD_Status HYD_LCHI_stdout_cb(int fd, HYD_Event_t events)
HYD_Status HYD_LCHI_stderr_cb(int fd, HYD_Event_t events)
{
int count, closed;
char buf[HYD_TMPBUF_SIZE];
int closed;
HYD_Status status = HYD_SUCCESS;
HYDU_FUNC_ENTER();
......@@ -78,7 +77,7 @@ HYD_Status HYD_LCHI_stderr_cb(int fd, HYD_Event_t events)
HYD_Status HYD_LCHI_stdin_cb(int fd, HYD_Event_t events)
{
int count, closed;
int closed;
HYD_Status status = HYD_SUCCESS;
HYDU_FUNC_ENTER();
......
......@@ -45,7 +45,8 @@ int main(int argc, char **argv)
{
struct HYD_Proc_params *proc_params;
struct HYD_Partition_list *partition;
int exit_status, i;
int exit_status;
int timeout;
HYD_Status status = HYD_SUCCESS;
HYDU_FUNC_ENTER();
......@@ -86,13 +87,12 @@ int main(int argc, char **argv)
}
handle.stdin_cb = HYD_LCHI_stdin_cb;
gettimeofday(&handle.start, NULL);
HYDU_Time_set(&handle.start, NULL); /* NULL implies right now */
if (getenv("MPIEXEC_TIMEOUT"))
handle.timeout.tv_sec = atoi(getenv("MPIEXEC_TIMEOUT"));
else {
handle.timeout.tv_sec = -1; /* Set a negative timeout */
handle.timeout.tv_usec = 0;
}
timeout = atoi(getenv("MPIEXEC_TIMEOUT"));
else
timeout = -1; /* Set a negative timeout */
HYD_Time_set(&handle.timeout, &timeout);
/* Launch the processes */
status = HYD_CSI_Launch_procs();
......
......@@ -97,7 +97,6 @@ HYD_Status HYD_LCHI_Get_parameters(int t_argc, char **t_argv)
int argc = t_argc, i;
char **argv = t_argv;
int local_params_started;
char *arg;
char *env_name, *env_value;
HYD_Env_t *env;
struct HYD_Proc_params *proc_params;
......
......@@ -6,6 +6,7 @@
#include "hydra.h"
#include "hydra_utils.h"
#include "lchu.h"
HYD_Handle handle;
......@@ -109,8 +110,9 @@ HYD_Status HYD_LCHU_Free_host_list(void)
for (partition = proc_params->partition; partition;) {
HYDU_FREE(partition->name);
if (partition->mapping) {
if (partition->mapping[i])
HYDU_FREE(partition->mapping[i]);
for (i = 0;; i++)
if (partition->mapping[i])
HYDU_FREE(partition->mapping[i]);
HYDU_FREE(partition->mapping);
}
for (i = 0; partition->args[i]; i++)
......
......@@ -37,14 +37,13 @@ HYD_Handle handle;
HYD_Status HYD_PMCI_Launch_procs(void)
{
char *port_range, *port_str, *sport, *str;
uint16_t low_port, high_port, port;
int one = 1, i, j, arg;
int num_procs, process_id, group_id;
uint16_t port;
int i, arg;
int process_id, group_id;
char hostname[MAX_HOSTNAME_LEN];
struct sockaddr_in sa;
HYD_Env_t *env;
struct HYD_Proc_params *proc_params;
struct HYD_Partition_list *partition, *run, *next_partition;
struct HYD_Partition_list *partition;
HYD_Status status = HYD_SUCCESS;
HYDU_FUNC_ENTER();
......@@ -157,12 +156,12 @@ HYD_Status HYD_PMCI_Launch_procs(void)
partition->args[arg++] = MPIU_Strdup(str);
HYDU_FREE(str);
j = 0;
i = 0;
for (env = handle.system_env; env; env = env->next)
j++;
i++;
for (env = proc_params->prop_env; env; env = env->next)
j++;
HYDU_Int_to_str(j, str, status);
i++;
HYDU_Int_to_str(i, str, status);
partition->args[arg++] = MPIU_Strdup("--environment");
partition->args[arg++] = MPIU_Strdup(str);
for (env = handle.system_env; env; env = env->next)
......
......@@ -14,9 +14,10 @@ int HYD_Proxy_listenfd;
int main(int argc, char **argv)
{
int i, j, arg, high_port, low_port, port, sockets_open;
int HYD_Proxy_listenfd, stdin_fd;
char *port_range, *port_str, *str;
int i, j, arg, sockets_open;
uint16_t port;
int HYD_Proxy_listenfd, stdin_fd, timeout;
char *port_range, *str, *timeout_str;
HYD_Env_t *env, pmi;
char *client_args[HYD_EXEC_ARGS];
HYD_Status status = HYD_SUCCESS;
......@@ -147,9 +148,15 @@ int main(int argc, char **argv)
}
}
timeout_str = getenv("MPIEXEC_TIMEOUT");
if (timeout_str)
timeout = atoi(timeout_str);
else
timeout = -1;
while (1) {
/* Wait for some event to occur */
status = HYD_DMX_Wait_for_event();
status = HYD_DMX_Wait_for_event(timeout);
if (status != HYD_SUCCESS) {
HYDU_Error_printf("demux engine returned error when waiting for event\n");
goto fn_fail;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment