1
1
openmpi/src/mca/oob/tcp/oob_tcp_peer.h

132 строки
3.6 KiB
C
Исходник Обычный вид История

/*
* $HEADER$
*/
/** @file:
*
* Contains the data structure which describes each connection
*/
#ifndef _MCA_OOB_TCP_PEER_H_
#define _MCA_OOB_TCP_PEER_H_
#include "mca/ns/ns.h"
#include "class/ompi_list.h"
#include "class/ompi_rb_tree.h"
#include <netinet/in.h>
#include "threads/mutex.h"
#include <string.h>
#include "mca/oob/tcp/oob_tcp.h"
#include "mca/oob/tcp/oob_tcp_msg.h"
/**
* the state of the connection
*/
typedef enum {
MCA_OOB_TCP_CLOSED,
MCA_OOB_TCP_CONNECTING,
MCA_OOB_TCP_CONNECT_ACK,
MCA_OOB_TCP_CONNECTED,
MCA_OOB_TCP_FAILED
} mca_oob_tcp_state_t;
/**
* This structure describes a peer
*/
struct mca_oob_tcp_peer_t {
ompi_list_item_t super; /**< allow this to be on a list */
ompi_process_name_t peer_name; /**< the name of the peer */
mca_oob_tcp_state_t peer_state; /**< the state of the connection */
int peer_retries; /**< number of times connection attempt has failed */
struct sockaddr_in peer_addr; /**< the address of the peer process */
int peer_sd; /**< socket descriptor of the connection */
ompi_event_t peer_send_event; /**< registration with event thread for send events */
ompi_event_t peer_recv_event; /**< registration with event thread for recv events */
ompi_event_t peer_timer_event; /**< used for timer callback */
ompi_mutex_t peer_lock; /**< protect critical data structures */
ompi_list_t peer_send_queue; /**< list of messages to send */
mca_oob_tcp_msg_t *peer_send_msg; /**< current send in progress */
mca_oob_tcp_msg_t *peer_recv_msg; /**< current recv in progress */
};
/**
* Convenience Typedef
*/
typedef struct mca_oob_tcp_peer_t mca_oob_tcp_peer_t;
/*
* Class declaration.
*/
OBJ_CLASS_DECLARATION(mca_oob_tcp_peer_t);
/**
* Get a new peer data structure
*/
#define MCA_OOB_TCP_PEER_ALLOC(peer, rc) \
{ \
ompi_list_item_t* item; \
- massive change for module<-->component name fixes throughout the code base. - many (most) mca type names have "component" or "module" in them, as relevant, just to further distinguish the difference between component data/actions and module data/actions. All developers are encouraged to perpetuate this convention when you create types that are specific to a framework, component, or module - did very little to entire framework (just the basics to make it compile) because it's just about to be almost entirely replaced - ditto for io / romio - did not work on elan or ib components; have to commit and then convert those on a different machine with the right libraries and headers - renamed a bunch of *_module.c files to *_component.c and *module*c to *component*c (a few still remain, e.g., ptl/ib, ptl/elan, etc.) - modified autogen/configure/build process to match new filenames (e.g., output static-components.h instead of static-modules.h) - removed DOS-style cr/lf stuff in ns/ns.h - added newline to end of file src/util/numtostr.h - removed some redundant error checking in the top-level topo functions - added a few {} here and there where people "forgot" to put them in for 1 line blocks ;-) - removed a bunch of MPI_* types from mca header files (replaced with corresponding ompi_* types) - all the ptl components had version numbers in their structs; removed - converted a few more elements in the MCA base to use the OBJ interface -- removed some old manual reference counting kruft This commit was SVN r1830.
2004-08-02 04:24:22 +04:00
OMPI_FREE_LIST_GET(&mca_oob_tcp_component.tcp_peer_free, item, rc); \
peer = (mca_oob_tcp_peer_t*)item; \
}
/**
* Return a peer data structure
*/
#define MCA_OOB_TCP_PEER_RETURN(peer) \
{ \
- massive change for module<-->component name fixes throughout the code base. - many (most) mca type names have "component" or "module" in them, as relevant, just to further distinguish the difference between component data/actions and module data/actions. All developers are encouraged to perpetuate this convention when you create types that are specific to a framework, component, or module - did very little to entire framework (just the basics to make it compile) because it's just about to be almost entirely replaced - ditto for io / romio - did not work on elan or ib components; have to commit and then convert those on a different machine with the right libraries and headers - renamed a bunch of *_module.c files to *_component.c and *module*c to *component*c (a few still remain, e.g., ptl/ib, ptl/elan, etc.) - modified autogen/configure/build process to match new filenames (e.g., output static-components.h instead of static-modules.h) - removed DOS-style cr/lf stuff in ns/ns.h - added newline to end of file src/util/numtostr.h - removed some redundant error checking in the top-level topo functions - added a few {} here and there where people "forgot" to put them in for 1 line blocks ;-) - removed a bunch of MPI_* types from mca header files (replaced with corresponding ompi_* types) - all the ptl components had version numbers in their structs; removed - converted a few more elements in the MCA base to use the OBJ interface -- removed some old manual reference counting kruft This commit was SVN r1830.
2004-08-02 04:24:22 +04:00
OMPI_FREE_LIST_RETURN(&mca_oob_tcp_component.tcp_peer_free, (ompi_list_item_t*)peer); \
}
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
#endif
/**
* Lookup a peer in the cache - if it doesn't exists
* create one and cache it.
*
* @param peer_name the name of the peer
* @param get_lock get the lock on the tcp struct. This should always be true
* unless the caller already owns the lock.
* @retval pointer to the peer's (possibly newly created) struture
* @retval NULL if there was a problem
*/
mca_oob_tcp_peer_t *mca_oob_tcp_peer_lookup(ompi_process_name_t* peer_name, bool get_lock);
/**
* Start sending a message to the specified peer. The routine
* can return before the send completes.
*
* @param peer The peer process.
* @param msg The message to send.
* @retval OMPI_SUCCESS or error code on failure.
*/
int mca_oob_tcp_peer_send(mca_oob_tcp_peer_t* peer, mca_oob_tcp_msg_t* msg);
/**
* 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);
/**
* Attempt to resolve peer address.
*/
int mca_oob_tcp_peer_name_lookup(mca_oob_tcp_peer_t* peer);
#if defined(c_plusplus) || defined(__cplusplus)
}
#endif
#endif /* _MCA_OOB_TCP_PEER_H */