OpenMPI  0.1.1
oob_tcp_peer.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
3  * University Research and Technology
4  * Corporation. All rights reserved.
5  * Copyright (c) 2004-2006 The University of Tennessee and The University
6  * of Tennessee Research Foundation. All rights
7  * reserved.
8  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9  * University of Stuttgart. All rights reserved.
10  * Copyright (c) 2004-2005 The Regents of the University of California.
11  * All rights reserved.
12  * $COPYRIGHT$
13  *
14  * Additional copyrights may follow
15  *
16  * $HEADER$
17  */
18 /** @file:
19  *
20  * Contains the data structure which describes each connection
21  */
22 
23 #ifndef _MCA_OOB_TCP_PEER_H_
24 #define _MCA_OOB_TCP_PEER_H_
25 
26 #include "orte_config.h"
27 #include "orte/types.h"
28 
29 #ifdef HAVE_NETINET_IN_H
30 #include <netinet/in.h>
31 #endif
32 #include <string.h>
33 
34 #include "opal/class/opal_list.h"
35 #include "opal/threads/mutex.h"
36 #include "opal/mca/event/event.h"
37 
38 #include "oob_tcp_msg.h"
39 #include "oob_tcp_addr.h"
40 
41 BEGIN_C_DECLS
42 
43 /**
44  * the state of the connection
45  */
46 typedef enum {
47  MCA_OOB_TCP_CLOSED,
48  MCA_OOB_TCP_RESOLVE,
49  MCA_OOB_TCP_CONNECTING,
50  MCA_OOB_TCP_CONNECT_ACK,
51  MCA_OOB_TCP_CONNECTED,
52  MCA_OOB_TCP_FAILED
54 
55 
56 /**
57  * This structure describes a peer
58  */
60  opal_free_list_item_t super; /**< allow this to be on a list */
61  orte_process_name_t peer_name; /**< the name of the peer */
62  mca_oob_tcp_state_t peer_state; /**< the state of the connection */
63  int peer_retries; /**< number of times connection attempt has failed */
64  mca_oob_tcp_addr_t* peer_addr; /**< the addresses of the peer process */
65  int peer_sd; /**< socket descriptor of the connection */
66  uint16_t peer_current_af; /**< currently connecting af */
67  opal_event_t peer_send_event; /**< registration with event thread for send events */
68  opal_event_t peer_recv_event; /**< registration with event thread for recv events */
69  opal_event_t peer_timer_event; /**< timer for retrying connection failures */
70  opal_mutex_t peer_lock; /**< protect critical data structures */
71  opal_list_t peer_send_queue; /**< list of messages to send */
72  mca_oob_tcp_msg_t *peer_send_msg; /**< current send in progress */
73  mca_oob_tcp_msg_t *peer_recv_msg; /**< current recv in progress */
74 };
75 /**
76  * Convenience Typedef
77  */
79 
80 /**
81  * Get a new peer data structure
82  */
83 #define MCA_OOB_TCP_PEER_ALLOC(peer, rc) \
84 { \
85  opal_free_list_item_t* item; \
86  OPAL_FREE_LIST_GET(&mca_oob_tcp_component.tcp_peer_free, item, rc); \
87  peer = (mca_oob_tcp_peer_t*)item; \
88 }
89 
90 /**
91  * Return a peer data structure
92  */
93 #define MCA_OOB_TCP_PEER_RETURN(peer) \
94 { \
95  mca_oob_tcp_peer_shutdown(peer); \
96  opal_hash_table_remove_value_uint64(&mca_oob_tcp_component.tcp_peers, orte_util_hash_name(&peer->peer_name)); \
97  OPAL_FREE_LIST_RETURN(&mca_oob_tcp_component.tcp_peer_free, \
98  &peer->super); \
99 }
100 
101 /*
102  * Class declaration.
103  */
104 
106 
107 /**
108  * Lookup a peer in the cache - if it doesn't exists
109  * create one and cache it.
110  *
111  * @param peer_name the name of the peer
112  * @retval pointer to the peer's (possibly newly created) struture
113  * @retval NULL if there was a problem
114  */
116 
117 /**
118  * Start sending a message to the specified peer. The routine
119  * can return before the send completes.
120  *
121  * @param peer The peer process.
122  * @param msg The message to send.
123  * @retval ORTE_SUCCESS or error code on failure.
124  */
126 
127 /**
128  * Connection request for this peer. Check the status of our connection
129  * before accepting the peers.
130  *
131  * @param peer The peer process.
132  * @param sd Incoming connection request.
133  */
134 bool mca_oob_tcp_peer_accept(mca_oob_tcp_peer_t* peer, int sd);
135 
136 /**
137  * Cleanup/close the connection to the peer.
138  *
139  * @param peer The peer process.
140  */
142 void mca_oob_tcp_peer_shutdown(mca_oob_tcp_peer_t* peer);
143 
144 /**
145  * The peers address has been resolved.
146  */
148 
149 /*
150  * Send the process identifier to the peer - so that
151  * temporary names can be updated to actuals.
152  */
153 int mca_oob_tcp_peer_send_ident(mca_oob_tcp_peer_t* peer);
154 
155 /*
156  * Remove any references to the message from the peers send/recv queue.
157  */
158 void mca_oob_tcp_peer_dequeue_msg(mca_oob_tcp_peer_t* peer, mca_oob_tcp_msg_t* msg);
159 
160 void mca_oob_tcp_peer_dump(mca_oob_tcp_peer_t* peer, const char* msg);
161 
162 END_C_DECLS
163 
164 #endif /* _MCA_OOB_TCP_PEER_H */
165 
int peer_sd
socket descriptor of the connection
Definition: oob_tcp_peer.h:65
int peer_retries
number of times connection attempt has failed
Definition: oob_tcp_peer.h:63
mca_oob_tcp_peer_t * mca_oob_tcp_peer_lookup(const orte_process_name_t *peer_name)
Lookup a peer in the cache - if it doesn't exists create one and cache it.
Definition: oob_tcp_peer.c:223
opal_free_list_item_t super
allow this to be on a list
Definition: oob_tcp_peer.h:60
uint16_t peer_current_af
currently connecting af
Definition: oob_tcp_peer.h:66
Definition: types.h:146
void mca_oob_tcp_peer_close(mca_oob_tcp_peer_t *peer)
Cleanup/close the connection to the peer.
Definition: oob_tcp_peer.c:590
Structure to represent a single event.
Definition: event_struct.h:87
Definition: mutex_unix.h:53
Address info published to registry.
Definition: oob_tcp_addr.h:56
opal_event_t peer_timer_event
timer for retrying connection failures
Definition: oob_tcp_peer.h:69
The opal_list_t interface is used to provide a generic doubly-linked list container for Open MPI...
opal_list_t peer_send_queue
list of messages to send
Definition: oob_tcp_peer.h:71
int mca_oob_tcp_peer_send(mca_oob_tcp_peer_t *peer, mca_oob_tcp_msg_t *msg)
Start sending a message to the specified peer.
Definition: oob_tcp_peer.c:162
describes each message being progressed.
Definition: oob_tcp_msg.h:47
Definition: opal_free_list.h:47
mca_oob_tcp_state_t
the state of the connection
Definition: oob_tcp_peer.h:46
bool mca_oob_tcp_peer_accept(mca_oob_tcp_peer_t *peer, int sd)
Connection request for this peer.
Definition: oob_tcp_peer.c:1088
opal_event_t peer_recv_event
registration with event thread for recv events
Definition: oob_tcp_peer.h:68
contains the data structure we will use to describe a message
Contains header used by tcp oob.
opal_mutex_t peer_lock
protect critical data structures
Definition: oob_tcp_peer.h:70
mca_oob_tcp_addr_t * peer_addr
the addresses of the peer process
Definition: oob_tcp_peer.h:64
mca_oob_tcp_state_t peer_state
the state of the connection
Definition: oob_tcp_peer.h:62
orte_process_name_t peer_name
the name of the peer
Definition: oob_tcp_peer.h:61
This structure describes a peer.
Definition: oob_tcp_peer.h:59
Definition: opal_list.h:147
mca_oob_tcp_msg_t * peer_send_msg
current send in progress
Definition: oob_tcp_peer.h:72
void mca_oob_tcp_peer_resolved(mca_oob_tcp_peer_t *peer, mca_oob_tcp_addr_t *addr)
The peers address has been resolved.
Definition: oob_tcp_peer.c:1133
mca_oob_tcp_msg_t * peer_recv_msg
current recv in progress
Definition: oob_tcp_peer.h:73
Mutual exclusion functions.
opal_event_t peer_send_event
registration with event thread for send events
Definition: oob_tcp_peer.h:67
#define OBJ_CLASS_DECLARATION(NAME)
Declaration for class descriptor.
Definition: opal_object.h:236