2004-07-01 18:49:54 +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.
|
2004-11-22 04:38:40 +03:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-07-01 18:49:54 +04:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
/** @file:
|
|
|
|
*
|
|
|
|
* Contains the data structure which describes each connection
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _MCA_OOB_TCP_PEER_H_
|
|
|
|
#define _MCA_OOB_TCP_PEER_H_
|
|
|
|
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "orte_config.h"
|
2008-02-28 04:57:57 +03:00
|
|
|
#include "orte/types.h"
|
|
|
|
|
2004-10-22 20:06:05 +04:00
|
|
|
#ifdef HAVE_NETINET_IN_H
|
2004-09-02 03:07:40 +04:00
|
|
|
#include <netinet/in.h>
|
2004-10-22 20:06:05 +04:00
|
|
|
#endif
|
2004-09-02 03:07:40 +04:00
|
|
|
#include <string.h>
|
|
|
|
|
2005-07-03 20:22:16 +04:00
|
|
|
#include "opal/class/opal_list.h"
|
2005-07-04 02:45:48 +04:00
|
|
|
#include "opal/threads/mutex.h"
|
2008-02-28 04:57:57 +03:00
|
|
|
#include "opal/event/event.h"
|
|
|
|
|
2004-09-02 03:07:40 +04:00
|
|
|
#include "oob_tcp_msg.h"
|
|
|
|
#include "oob_tcp_addr.h"
|
2008-02-28 04:57:57 +03:00
|
|
|
|
|
|
|
BEGIN_C_DECLS
|
2004-09-02 03:07:40 +04:00
|
|
|
|
2004-07-01 18:49:54 +04:00
|
|
|
/**
|
|
|
|
* the state of the connection
|
|
|
|
*/
|
|
|
|
typedef enum {
|
|
|
|
MCA_OOB_TCP_CLOSED,
|
2004-09-02 03:07:40 +04:00
|
|
|
MCA_OOB_TCP_RESOLVE,
|
2004-07-01 18:49:54 +04:00
|
|
|
MCA_OOB_TCP_CONNECTING,
|
|
|
|
MCA_OOB_TCP_CONNECT_ACK,
|
|
|
|
MCA_OOB_TCP_CONNECTED,
|
|
|
|
MCA_OOB_TCP_FAILED
|
|
|
|
} mca_oob_tcp_state_t;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2004-08-03 01:24:00 +04:00
|
|
|
* This structure describes a peer
|
2004-07-01 18:49:54 +04:00
|
|
|
*/
|
|
|
|
struct mca_oob_tcp_peer_t {
|
2006-07-18 01:51:50 +04:00
|
|
|
opal_free_list_item_t super; /**< allow this to be on a list */
|
2005-03-14 23:57:21 +03:00
|
|
|
orte_process_name_t peer_name; /**< the name of the peer */
|
2004-07-13 02:46:57 +04:00
|
|
|
mca_oob_tcp_state_t peer_state; /**< the state of the connection */
|
|
|
|
int peer_retries; /**< number of times connection attempt has failed */
|
2004-09-02 03:07:40 +04:00
|
|
|
mca_oob_tcp_addr_t* peer_addr; /**< the addresses of the peer process */
|
2004-07-13 02:46:57 +04:00
|
|
|
int peer_sd; /**< socket descriptor of the connection */
|
2007-07-20 05:34:02 +04:00
|
|
|
uint16_t peer_current_af; /**< currently connecting af */
|
2005-07-04 03:09:55 +04:00
|
|
|
opal_event_t peer_send_event; /**< registration with event thread for send events */
|
|
|
|
opal_event_t peer_recv_event; /**< registration with event thread for recv events */
|
|
|
|
opal_event_t peer_timer_event; /**< timer for retrying connection failures */
|
2005-07-04 02:45:48 +04:00
|
|
|
opal_mutex_t peer_lock; /**< protect critical data structures */
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_t peer_send_queue; /**< list of messages to send */
|
2004-07-13 02:46:57 +04:00
|
|
|
mca_oob_tcp_msg_t *peer_send_msg; /**< current send in progress */
|
|
|
|
mca_oob_tcp_msg_t *peer_recv_msg; /**< current recv in progress */
|
2004-07-01 18:49:54 +04:00
|
|
|
};
|
2004-08-10 03:07:53 +04:00
|
|
|
/**
|
|
|
|
* Convenience Typedef
|
|
|
|
*/
|
2004-07-01 18:49:54 +04:00
|
|
|
typedef struct mca_oob_tcp_peer_t mca_oob_tcp_peer_t;
|
2004-07-01 21:45:34 +04:00
|
|
|
|
2004-07-14 01:03:03 +04:00
|
|
|
/**
|
|
|
|
* Get a new peer data structure
|
2004-07-15 17:51:40 +04:00
|
|
|
*/
|
2006-07-18 01:51:50 +04:00
|
|
|
#define MCA_OOB_TCP_PEER_ALLOC(peer, rc) \
|
|
|
|
{ \
|
|
|
|
opal_free_list_item_t* item; \
|
2005-07-02 20:46:27 +04:00
|
|
|
OPAL_FREE_LIST_GET(&mca_oob_tcp_component.tcp_peer_free, item, rc); \
|
2006-07-18 01:51:50 +04:00
|
|
|
peer = (mca_oob_tcp_peer_t*)item; \
|
|
|
|
}
|
2004-07-14 01:03:03 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a peer data structure
|
|
|
|
*/
|
2006-07-18 01:51:50 +04:00
|
|
|
#define MCA_OOB_TCP_PEER_RETURN(peer) \
|
|
|
|
{ \
|
|
|
|
mca_oob_tcp_peer_shutdown(peer); \
|
2008-03-06 01:44:35 +03:00
|
|
|
opal_hash_table_remove_value_uint64(&mca_oob_tcp_component.tcp_peers, orte_util_hash_name(&peer->peer_name)); \
|
2006-07-18 01:51:50 +04:00
|
|
|
OPAL_FREE_LIST_RETURN(&mca_oob_tcp_component.tcp_peer_free, \
|
|
|
|
&peer->super); \
|
|
|
|
}
|
2004-07-13 02:46:57 +04:00
|
|
|
|
2006-08-23 07:32:36 +04:00
|
|
|
/*
|
|
|
|
* Class declaration.
|
|
|
|
*/
|
|
|
|
|
|
|
|
OBJ_CLASS_DECLARATION(mca_oob_tcp_peer_t);
|
|
|
|
|
2004-07-01 21:45:34 +04:00
|
|
|
/**
|
2004-07-13 02:46:57 +04:00
|
|
|
* Lookup a peer in the cache - if it doesn't exists
|
|
|
|
* create one and cache it.
|
2004-07-01 18:49:54 +04:00
|
|
|
*
|
|
|
|
* @param peer_name the name of the peer
|
2004-07-14 01:03:03 +04:00
|
|
|
* @retval pointer to the peer's (possibly newly created) struture
|
2004-07-01 18:49:54 +04:00
|
|
|
* @retval NULL if there was a problem
|
|
|
|
*/
|
2005-03-14 23:57:21 +03:00
|
|
|
mca_oob_tcp_peer_t *mca_oob_tcp_peer_lookup(const orte_process_name_t* peer_name);
|
2004-07-01 18:49:54 +04:00
|
|
|
|
|
|
|
/**
|
2004-07-13 02:46:57 +04:00
|
|
|
* Start sending a message to the specified peer. The routine
|
|
|
|
* can return before the send completes.
|
2004-07-01 18:49:54 +04:00
|
|
|
*
|
2004-07-13 02:46:57 +04:00
|
|
|
* @param peer The peer process.
|
|
|
|
* @param msg The message to send.
|
2006-02-12 04:33:29 +03:00
|
|
|
* @retval ORTE_SUCCESS or error code on failure.
|
2004-07-01 18:49:54 +04:00
|
|
|
*/
|
2004-07-13 02:46:57 +04:00
|
|
|
int mca_oob_tcp_peer_send(mca_oob_tcp_peer_t* peer, mca_oob_tcp_msg_t* msg);
|
|
|
|
|
2004-08-03 01:24:00 +04:00
|
|
|
/**
|
|
|
|
* Connection request for this peer. Check the status of our connection
|
|
|
|
* before accepting the peers.
|
|
|
|
*
|
|
|
|
* @param peer The peer process.
|
|
|
|
* @param sd Incoming connection request.
|
|
|
|
*/
|
|
|
|
bool mca_oob_tcp_peer_accept(mca_oob_tcp_peer_t* peer, int sd);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Cleanup/close the connection to the peer.
|
|
|
|
*
|
|
|
|
* @param peer The peer process.
|
|
|
|
*/
|
|
|
|
void mca_oob_tcp_peer_close(mca_oob_tcp_peer_t* peer);
|
2005-03-14 23:57:21 +03:00
|
|
|
void mca_oob_tcp_peer_shutdown(mca_oob_tcp_peer_t* peer);
|
2004-08-03 01:24:00 +04:00
|
|
|
|
2004-08-16 23:39:54 +04:00
|
|
|
/**
|
2004-09-02 03:07:40 +04:00
|
|
|
* The peers address has been resolved.
|
|
|
|
*/
|
|
|
|
void mca_oob_tcp_peer_resolved(mca_oob_tcp_peer_t* peer, mca_oob_tcp_addr_t* addr);
|
|
|
|
|
|
|
|
/*
|
2004-09-02 18:20:13 +04:00
|
|
|
* Send the process identifier to the peer - so that
|
|
|
|
* temporary names can be updated to actuals.
|
2004-08-16 23:39:54 +04:00
|
|
|
*/
|
2004-09-02 03:07:40 +04:00
|
|
|
int mca_oob_tcp_peer_send_ident(mca_oob_tcp_peer_t* peer);
|
2004-08-16 23:39:54 +04:00
|
|
|
|
2004-09-16 18:12:22 +04:00
|
|
|
/*
|
|
|
|
* Remove any references to the message from the peers send/recv queue.
|
|
|
|
*/
|
|
|
|
void mca_oob_tcp_peer_dequeue_msg(mca_oob_tcp_peer_t* peer, mca_oob_tcp_msg_t* msg);
|
|
|
|
|
2008-04-23 04:17:12 +04:00
|
|
|
void mca_oob_tcp_peer_dump(mca_oob_tcp_peer_t* peer, const char* msg);
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
END_C_DECLS
|
2004-07-01 21:45:34 +04:00
|
|
|
|
2004-07-01 18:49:54 +04:00
|
|
|
#endif /* _MCA_OOB_TCP_PEER_H */
|
|
|
|
|