2004-07-13 02:46:57 +04:00
|
|
|
/*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
/** @file:
|
|
|
|
*
|
|
|
|
* contains the data structure we will use to describe a message
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _MCA_OOB_TCP_MESSAGE_H_
|
|
|
|
#define _MCA_OOB_TCP_MESSAGE_H_
|
|
|
|
|
|
|
|
#include "class/ompi_list.h"
|
|
|
|
#include "mca/oob/tcp/oob_tcp_peer.h"
|
|
|
|
#include "mca/oob/oob.h"
|
2004-07-15 17:51:40 +04:00
|
|
|
#include <errno.h>
|
2004-07-15 23:08:54 +04:00
|
|
|
struct mca_oob_tcp_peer_t;
|
2004-07-13 02:46:57 +04:00
|
|
|
/**
|
|
|
|
* describes each message being progressed.
|
|
|
|
*/
|
|
|
|
struct mca_oob_tcp_msg_t {
|
|
|
|
ompi_list_item_t super; /**< make it so we can put this on a list */
|
2004-07-15 17:51:40 +04:00
|
|
|
int msg_state; /**< the amount sent or recieved or errno */
|
|
|
|
uint32_t msg_size; /**< the total size of the message */
|
2004-07-13 02:46:57 +04:00
|
|
|
const struct iovec * msg_user; /**< the data of the message */
|
|
|
|
struct iovec * msg_iov; /**< copy of iovec array - not data */
|
|
|
|
struct iovec * msg_rwptr; /**< current read/write pointer into msg_iov */
|
|
|
|
int msg_rwcnt; /**< number of iovecs left for read/write */
|
|
|
|
int msg_count; /**< the number of items in the iovec array */
|
|
|
|
mca_oob_callback_fn_t msg_cbfunc; /**< the callback function for the send/recieve */
|
|
|
|
void *msg_cbdata; /**< the data for the callback fnuction */
|
2004-07-15 17:51:40 +04:00
|
|
|
bool msg_complete; /**< whether the message is done sending or not */
|
2004-07-15 23:08:54 +04:00
|
|
|
ompi_process_name_t * msg_peer; /**< the name of the peer */
|
2004-07-15 17:51:40 +04:00
|
|
|
ompi_mutex_t msg_lock; /**< lock for the condition variable */
|
|
|
|
ompi_condition_t msg_condition; /**< the message condition */
|
2004-07-13 02:46:57 +04:00
|
|
|
};
|
2004-07-15 17:51:40 +04:00
|
|
|
/**
|
|
|
|
* Convenience typedef
|
|
|
|
*/
|
2004-07-13 02:46:57 +04:00
|
|
|
typedef struct mca_oob_tcp_msg_t mca_oob_tcp_msg_t;
|
|
|
|
|
|
|
|
OBJ_CLASS_DECLARATION(mca_oob_tcp_msg_t);
|
|
|
|
|
2004-07-14 01:03:03 +04:00
|
|
|
/**
|
|
|
|
* Get a new structure for use with a message
|
|
|
|
*/
|
2004-07-13 02:46:57 +04:00
|
|
|
#define MCA_OOB_TCP_MSG_ALLOC(msg, rc) \
|
|
|
|
{ \
|
|
|
|
ompi_list_item_t* item; \
|
2004-08-02 04:24:22 +04:00
|
|
|
OMPI_FREE_LIST_GET(&mca_oob_tcp_component.tcp_msgs, item, rc); \
|
2004-07-13 02:46:57 +04:00
|
|
|
msg = (mca_oob_tcp_msg_t*)item; \
|
|
|
|
}
|
|
|
|
|
2004-07-14 01:03:03 +04:00
|
|
|
/**
|
|
|
|
* return a message structure that is no longer needed
|
|
|
|
*/
|
2004-07-13 02:46:57 +04:00
|
|
|
#define MCA_OOB_TCP_MSG_RETURN(msg) \
|
|
|
|
{ \
|
2004-07-15 17:51:40 +04:00
|
|
|
/* frees the iovec allocated during the send/recieve */ \
|
2004-07-15 23:08:54 +04:00
|
|
|
if(NULL != msg->msg_iov) free(msg->msg_iov); \
|
2004-08-02 04:24:22 +04:00
|
|
|
OMPI_FREE_LIST_RETURN(&mca_oob_tcp_component.tcp_msgs, (ompi_list_item_t*)msg); \
|
2004-07-13 02:46:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Wait for a msg to complete.
|
|
|
|
* @param msg (IN) Message to wait on.
|
|
|
|
* @param size (OUT) Number of bytes delivered.
|
|
|
|
* @retval OMPI_SUCCESS or error code on failure.
|
|
|
|
*/
|
|
|
|
int mca_oob_tcp_msg_wait(mca_oob_tcp_msg_t* msg, int* size);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Signal that a message has completed. Wakes up any pending threads (for blocking send)
|
|
|
|
* or invokes callbacks for non-blocking case.
|
|
|
|
* @param msg (IN) Message send/recv that has completed.
|
2004-07-15 23:08:54 +04:00
|
|
|
* @param peer (IN) The peer the send/recieve was from
|
2004-07-13 02:46:57 +04:00
|
|
|
* @retval OMPI_SUCCESS or error code on failure.
|
|
|
|
*/
|
2004-07-15 23:08:54 +04:00
|
|
|
int mca_oob_tcp_msg_complete(mca_oob_tcp_msg_t* msg, ompi_process_name_t * peer);
|
2004-07-13 02:46:57 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called asynchronously to progress sending a message from the event library thread.
|
|
|
|
* @param msg (IN) Message send that is in progress.
|
|
|
|
* @param sd (IN) Socket descriptor to use for send.
|
|
|
|
* @retval bool Bool flag indicating wether operation has completed.
|
|
|
|
*/
|
2004-07-15 17:51:40 +04:00
|
|
|
bool mca_oob_tcp_msg_send_handler(mca_oob_tcp_msg_t* msg, struct mca_oob_tcp_peer_t * peer);
|
2004-07-13 02:46:57 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called asynchronously to progress sending a message from the event library thread.
|
|
|
|
* @param msg (IN) Message send that is in progress.
|
|
|
|
* @param sd (IN) Socket descriptor to use for send.
|
|
|
|
* @retval bool Bool flag indicating wether operation has completed.
|
|
|
|
*/
|
|
|
|
|
2004-07-15 17:51:40 +04:00
|
|
|
bool mca_oob_tcp_msg_recv_handler(mca_oob_tcp_msg_t* msg, struct mca_oob_tcp_peer_t * peer);
|
2004-07-13 02:46:57 +04:00
|
|
|
|
|
|
|
#endif /* _MCA_OOB_TCP_MESSAGE_H_ */
|
|
|
|
|