2004-09-08 22:03:05 +04:00
|
|
|
/*
|
2005-11-05 22:57:48 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
2006-08-23 07:32:36 +04:00
|
|
|
* Copyright (c) 2004-2006 The University of Tennessee and The University
|
2005-11-05 22:57:48 +03:00
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2004-11-28 23:09:25 +03:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 15:43:37 +03:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2006-07-18 01:15:56 +04:00
|
|
|
* Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-09-08 22:03:05 +04:00
|
|
|
* $HEADER$
|
2006-03-11 06:09:24 +03:00
|
|
|
*
|
|
|
|
* In windows, many of the socket functions return an EWOULDBLOCK
|
|
|
|
* instead of \ things like EAGAIN, EINPROGRESS, etc. It has been
|
|
|
|
* verified that this will \ not conflict with other error codes that
|
|
|
|
* are returned by these functions \ under UNIX/Linux environments
|
2004-09-08 22:03:05 +04:00
|
|
|
*/
|
2006-03-11 06:09:24 +03:00
|
|
|
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "orte_config.h"
|
2005-05-05 20:31:40 +04:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
#include <fcntl.h>
|
|
|
|
#ifdef HAVE_SYS_UIO_H
|
|
|
|
#include <sys/uio.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
|
|
|
#include <sys/types.h>
|
|
|
|
#endif
|
2006-08-15 00:14:44 +04:00
|
|
|
#include "opal/opal_socket_errno.h"
|
2005-05-05 20:31:40 +04:00
|
|
|
#ifdef HAVE_NETINET_IN_H
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_ARPA_INET_H
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_NETINET_TCP_H
|
|
|
|
#include <netinet/tcp.h>
|
|
|
|
#endif
|
2006-07-18 13:07:53 +04:00
|
|
|
#ifndef __WINDOWS__
|
|
|
|
#include <signal.h>
|
|
|
|
#endif
|
2006-07-18 01:15:56 +04:00
|
|
|
#include "opal/event/event.h"
|
Bring over the update to terminate orteds that are generated by a dynamic spawn such as comm_spawn. This introduces the concept of a job "family" - i.e., jobs that have a parent/child relationship. Comm_spawn'ed jobs have a parent (the one that spawned them). We track that relationship throughout the lineage - i.e., if a comm_spawned job in turn calls comm_spawn, then it has a parent (the one that spawned it) and a "root" job (the original job that started things).
Accordingly, there are new APIs to the name service to support the ability to get a job's parent, root, immediate children, and all its descendants. In addition, the terminate_job, terminate_orted, and signal_job APIs for the PLS have been modified to accept attributes that define the extent of their actions. For example, doing a "terminate_job" with an attribute of ORTE_NS_INCLUDE_DESCENDANTS will terminate the given jobid AND all jobs that descended from it.
I have tested this capability on a MacBook under rsh, Odin under SLURM, and LANL's Flash (bproc). It worked successfully on non-MPI jobs (both simple and including a spawn), and MPI jobs (again, both simple and with a spawn).
This commit was SVN r12597.
2006-11-14 22:34:59 +03:00
|
|
|
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "orte/mca/ns/ns_types.h"
|
Bring over the update to terminate orteds that are generated by a dynamic spawn such as comm_spawn. This introduces the concept of a job "family" - i.e., jobs that have a parent/child relationship. Comm_spawn'ed jobs have a parent (the one that spawned them). We track that relationship throughout the lineage - i.e., if a comm_spawned job in turn calls comm_spawn, then it has a parent (the one that spawned it) and a "root" job (the original job that started things).
Accordingly, there are new APIs to the name service to support the ability to get a job's parent, root, immediate children, and all its descendants. In addition, the terminate_job, terminate_orted, and signal_job APIs for the PLS have been modified to accept attributes that define the extent of their actions. For example, doing a "terminate_job" with an attribute of ORTE_NS_INCLUDE_DESCENDANTS will terminate the given jobid AND all jobs that descended from it.
I have tested this capability on a MacBook under rsh, Odin under SLURM, and LANL's Flash (bproc). It worked successfully on non-MPI jobs (both simple and including a spawn), and MPI jobs (again, both simple and with a spawn).
This commit was SVN r12597.
2006-11-14 22:34:59 +03:00
|
|
|
#include "orte/util/proc_info.h"
|
|
|
|
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "orte/mca/oob/tcp/oob_tcp.h"
|
2004-09-08 22:03:05 +04:00
|
|
|
|
2006-07-18 01:15:56 +04:00
|
|
|
/*
|
|
|
|
* Local functions
|
|
|
|
*/
|
|
|
|
static void noop(int fd, short event, void *arg);
|
2005-05-05 20:31:40 +04:00
|
|
|
|
2004-09-08 22:03:05 +04:00
|
|
|
/*
|
|
|
|
* Ping a peer to see if it is alive.
|
|
|
|
*
|
|
|
|
* @param peer (IN) Opaque name of peer process.
|
|
|
|
* @param tv (IN) Timeout to wait for a response.
|
|
|
|
* @return OMPI error code (<0) on error number of bytes actually sent.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int mca_oob_tcp_ping(
|
2005-05-05 20:31:40 +04:00
|
|
|
const orte_process_name_t* name,
|
|
|
|
const char* uri,
|
2004-09-08 22:03:05 +04:00
|
|
|
const struct timeval *timeout)
|
|
|
|
{
|
2005-05-05 20:31:40 +04:00
|
|
|
int sd, flags, rc;
|
|
|
|
struct sockaddr_in inaddr;
|
|
|
|
fd_set fdset;
|
|
|
|
mca_oob_tcp_hdr_t hdr;
|
2004-09-08 22:03:05 +04:00
|
|
|
struct timeval tv;
|
2006-08-23 07:32:36 +04:00
|
|
|
struct iovec iov;
|
2006-07-18 01:15:56 +04:00
|
|
|
#ifndef __WINDOWS__
|
|
|
|
struct opal_event sigpipe_handler;
|
|
|
|
#endif
|
2004-09-08 22:03:05 +04:00
|
|
|
|
2005-05-05 20:31:40 +04:00
|
|
|
/* parse uri string */
|
2006-02-12 04:33:29 +03:00
|
|
|
if(ORTE_SUCCESS != (rc = mca_oob_tcp_parse_uri(uri, &inaddr))) {
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output(0,
|
2005-05-08 17:22:55 +04:00
|
|
|
"[%lu,%lu,%lu]-[%lu,%lu,%lu] mca_oob_tcp_ping: invalid uri: %s\n",
|
2005-03-14 23:57:21 +03:00
|
|
|
ORTE_NAME_ARGS(orte_process_info.my_name),
|
2005-05-05 20:31:40 +04:00
|
|
|
ORTE_NAME_ARGS(name),
|
|
|
|
uri);
|
|
|
|
return rc;
|
2004-09-08 22:03:05 +04:00
|
|
|
}
|
|
|
|
|
2005-05-05 20:31:40 +04:00
|
|
|
/* create socket */
|
|
|
|
sd = socket(AF_INET, SOCK_STREAM, 0);
|
|
|
|
if (sd < 0) {
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output(0,
|
2006-12-14 21:20:43 +03:00
|
|
|
"[%lu,%lu,%lu]-[%lu,%lu,%lu] mca_oob_tcp_ping: socket() failed: %s (%d)\n",
|
2005-05-05 20:31:40 +04:00
|
|
|
ORTE_NAME_ARGS(orte_process_info.my_name),
|
|
|
|
ORTE_NAME_ARGS(name),
|
2006-12-14 21:20:43 +03:00
|
|
|
strerror(opal_socket_errno),
|
2006-08-15 00:14:44 +04:00
|
|
|
opal_socket_errno);
|
2006-02-12 04:33:29 +03:00
|
|
|
return ORTE_ERR_UNREACH;
|
2005-05-05 20:31:40 +04:00
|
|
|
}
|
2004-09-08 22:03:05 +04:00
|
|
|
|
2005-05-05 20:31:40 +04:00
|
|
|
/* setup the socket as non-blocking */
|
|
|
|
if((flags = fcntl(sd, F_GETFL, 0)) < 0) {
|
2006-12-14 21:20:43 +03:00
|
|
|
opal_output(0, "[%lu,%lu,%lu]-[%lu,%lu,%lu] mca_oob_tcp_ping: fcntl(F_GETFL) failed: %s (%d)\n",
|
2005-05-05 20:31:40 +04:00
|
|
|
ORTE_NAME_ARGS(orte_process_info.my_name),
|
|
|
|
ORTE_NAME_ARGS(name),
|
2006-12-14 21:20:43 +03:00
|
|
|
strerror(opal_socket_errno),
|
2006-08-15 00:14:44 +04:00
|
|
|
opal_socket_errno);
|
2005-03-14 23:57:21 +03:00
|
|
|
} else {
|
2005-05-05 20:31:40 +04:00
|
|
|
flags |= O_NONBLOCK;
|
|
|
|
if(fcntl(sd, F_SETFL, flags) < 0) {
|
2006-12-14 21:20:43 +03:00
|
|
|
opal_output(0, "[%lu,%lu,%lu]-[%lu,%lu,%lu] mca_oob_tcp_ping: fcntl(F_SETFL) failed: %s (%d)\n",
|
2005-05-05 20:31:40 +04:00
|
|
|
ORTE_NAME_ARGS(orte_process_info.my_name),
|
|
|
|
ORTE_NAME_ARGS(name),
|
2006-12-14 21:20:43 +03:00
|
|
|
strerror(opal_socket_errno),
|
2006-08-15 00:14:44 +04:00
|
|
|
opal_socket_errno);
|
2005-05-05 20:31:40 +04:00
|
|
|
}
|
2005-03-14 23:57:21 +03:00
|
|
|
}
|
2004-09-08 22:03:05 +04:00
|
|
|
|
2005-05-05 20:31:40 +04:00
|
|
|
/* start the connect - will likely fail with EINPROGRESS */
|
|
|
|
FD_ZERO(&fdset);
|
|
|
|
if(connect(sd, (struct sockaddr*)&inaddr, sizeof(inaddr)) < 0) {
|
|
|
|
/* connect failed? */
|
2006-08-15 00:14:44 +04:00
|
|
|
if(opal_socket_errno != EINPROGRESS && opal_socket_errno != EWOULDBLOCK) {
|
2006-08-23 07:32:36 +04:00
|
|
|
CLOSE_THE_SOCKET(sd);
|
2006-02-12 04:33:29 +03:00
|
|
|
return ORTE_ERR_UNREACH;
|
2005-05-05 20:31:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* select with timeout to wait for connect to complete */
|
|
|
|
FD_SET(sd, &fdset);
|
|
|
|
tv = *timeout;
|
|
|
|
rc = select(sd+1, NULL, &fdset, NULL, &tv);
|
|
|
|
if(rc <= 0) {
|
2006-08-23 07:32:36 +04:00
|
|
|
CLOSE_THE_SOCKET(sd);
|
2006-02-12 04:33:29 +03:00
|
|
|
return ORTE_ERR_UNREACH;
|
2005-05-05 20:31:40 +04:00
|
|
|
}
|
2004-09-08 22:03:05 +04:00
|
|
|
}
|
|
|
|
|
2005-05-05 20:31:40 +04:00
|
|
|
/* set socket back to blocking */
|
|
|
|
flags &= ~O_NONBLOCK;
|
|
|
|
if(fcntl(sd, F_SETFL, flags) < 0) {
|
2006-12-14 21:20:43 +03:00
|
|
|
opal_output(0, "[%lu,%lu,%lu]-[%lu,%lu,%lu] mca_oob_tcp_ping: fcntl(F_SETFL) failed: %s (%d)\n",
|
2005-05-05 20:31:40 +04:00
|
|
|
ORTE_NAME_ARGS(orte_process_info.my_name),
|
|
|
|
ORTE_NAME_ARGS(name),
|
2006-12-14 21:20:43 +03:00
|
|
|
strerror(opal_socket_errno),
|
2006-08-15 00:14:44 +04:00
|
|
|
opal_socket_errno);
|
2004-09-08 22:03:05 +04:00
|
|
|
}
|
2005-05-05 20:31:40 +04:00
|
|
|
|
|
|
|
/* send a probe message */
|
|
|
|
memset(&hdr, 0, sizeof(hdr));
|
|
|
|
if(orte_process_info.my_name != NULL) {
|
|
|
|
hdr.msg_src = *orte_process_info.my_name;
|
|
|
|
} else {
|
Bring over the update to terminate orteds that are generated by a dynamic spawn such as comm_spawn. This introduces the concept of a job "family" - i.e., jobs that have a parent/child relationship. Comm_spawn'ed jobs have a parent (the one that spawned them). We track that relationship throughout the lineage - i.e., if a comm_spawned job in turn calls comm_spawn, then it has a parent (the one that spawned it) and a "root" job (the original job that started things).
Accordingly, there are new APIs to the name service to support the ability to get a job's parent, root, immediate children, and all its descendants. In addition, the terminate_job, terminate_orted, and signal_job APIs for the PLS have been modified to accept attributes that define the extent of their actions. For example, doing a "terminate_job" with an attribute of ORTE_NS_INCLUDE_DESCENDANTS will terminate the given jobid AND all jobs that descended from it.
I have tested this capability on a MacBook under rsh, Odin under SLURM, and LANL's Flash (bproc). It worked successfully on non-MPI jobs (both simple and including a spawn), and MPI jobs (again, both simple and with a spawn).
This commit was SVN r12597.
2006-11-14 22:34:59 +03:00
|
|
|
hdr.msg_src = *ORTE_NAME_INVALID;
|
2005-05-05 20:31:40 +04:00
|
|
|
}
|
|
|
|
hdr.msg_dst = *name;
|
|
|
|
hdr.msg_type = MCA_OOB_TCP_PROBE;
|
2005-05-18 19:31:23 +04:00
|
|
|
MCA_OOB_TCP_HDR_HTON(&hdr);
|
2006-07-18 01:15:56 +04:00
|
|
|
|
|
|
|
#ifndef __WINDOWS__
|
|
|
|
/* Ignore SIGPIPE in the write -- determine success or failure in
|
|
|
|
the ping by looking at the return code from write() */
|
|
|
|
opal_signal_set(&sigpipe_handler, SIGPIPE,
|
|
|
|
noop, &sigpipe_handler);
|
|
|
|
opal_signal_add(&sigpipe_handler, NULL);
|
|
|
|
#endif
|
2006-08-23 07:32:36 +04:00
|
|
|
/* Do the write and see what happens. Use the writev version just to
|
|
|
|
* make Windows happy as there the write function is limitted to
|
|
|
|
* file operations.
|
|
|
|
*/
|
|
|
|
iov.iov_base = (IOVBASE_TYPE*)&hdr;
|
|
|
|
iov.iov_len = sizeof(hdr);
|
|
|
|
rc = writev(sd, &iov, 1 );
|
2006-07-18 01:15:56 +04:00
|
|
|
#ifndef __WINDOWS__
|
|
|
|
/* Now de-register the handler */
|
|
|
|
opal_signal_del(&sigpipe_handler);
|
|
|
|
#endif
|
|
|
|
if (rc != sizeof(hdr)) {
|
2006-08-23 07:32:36 +04:00
|
|
|
CLOSE_THE_SOCKET(sd);
|
2006-02-12 04:33:29 +03:00
|
|
|
return ORTE_ERR_UNREACH;
|
2005-05-05 20:31:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* select with timeout to wait for response */
|
|
|
|
FD_SET(sd, &fdset);
|
|
|
|
tv = *timeout;
|
|
|
|
rc = select(sd+1, &fdset, NULL, NULL, &tv);
|
|
|
|
if(rc <= 0) {
|
2006-08-23 07:32:36 +04:00
|
|
|
CLOSE_THE_SOCKET(sd);
|
2006-02-12 04:33:29 +03:00
|
|
|
return ORTE_ERR_UNREACH;
|
2005-05-05 20:31:40 +04:00
|
|
|
}
|
|
|
|
if((rc = read(sd, &hdr, sizeof(hdr))) != sizeof(hdr)) {
|
2006-08-23 07:32:36 +04:00
|
|
|
CLOSE_THE_SOCKET(sd);
|
2006-02-12 04:33:29 +03:00
|
|
|
return ORTE_ERR_UNREACH;
|
2005-05-05 20:31:40 +04:00
|
|
|
}
|
2005-05-18 19:31:23 +04:00
|
|
|
MCA_OOB_TCP_HDR_NTOH(&hdr);
|
2005-05-18 19:32:05 +04:00
|
|
|
if(hdr.msg_type != MCA_OOB_TCP_PROBE) {
|
2006-08-23 07:32:36 +04:00
|
|
|
CLOSE_THE_SOCKET(sd);
|
2006-02-12 04:33:29 +03:00
|
|
|
return ORTE_ERR_UNREACH;
|
2005-05-18 19:31:23 +04:00
|
|
|
}
|
2006-08-23 07:32:36 +04:00
|
|
|
CLOSE_THE_SOCKET(sd);
|
2006-02-12 04:33:29 +03:00
|
|
|
return ORTE_SUCCESS;
|
2004-09-08 22:03:05 +04:00
|
|
|
}
|
|
|
|
|
2005-05-05 20:31:40 +04:00
|
|
|
|
2006-07-18 01:15:56 +04:00
|
|
|
static void noop(int fd, short event, void *arg)
|
|
|
|
{
|
|
|
|
/* Nothing */
|
|
|
|
}
|