2004-01-29 01:52:51 +03:00
|
|
|
/*
|
2004-11-22 04:38:40 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University.
|
|
|
|
* All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
|
|
|
|
* 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-01-29 01:52:51 +03:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
2004-10-20 05:03:09 +04:00
|
|
|
#include "ompi_config.h"
|
2004-10-22 20:06:05 +04:00
|
|
|
#ifdef HAVE_UNISTD_H
|
2004-01-29 01:52:51 +03:00
|
|
|
#include <unistd.h>
|
2004-10-22 20:06:05 +04:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
2004-01-29 01:52:51 +03:00
|
|
|
#include <sys/types.h>
|
2004-10-22 20:06:05 +04:00
|
|
|
#endif
|
2005-09-13 00:20:51 +04:00
|
|
|
#include "ompi/include/ompi_socket_errno.h"
|
|
|
|
#include "ompi/mca/ptl/base/ptl_base_sendreq.h"
|
|
|
|
#include "opal/util/output.h"
|
2004-01-29 01:52:51 +03:00
|
|
|
#include "ptl_tcp.h"
|
|
|
|
#include "ptl_tcp_peer.h"
|
|
|
|
#include "ptl_tcp_recvfrag.h"
|
2004-03-15 17:46:12 +03:00
|
|
|
#include "ptl_tcp_sendfrag.h"
|
2004-01-29 01:52:51 +03:00
|
|
|
|
|
|
|
|
2004-03-12 01:02:01 +03:00
|
|
|
|
2004-02-10 17:04:27 +03:00
|
|
|
static void mca_ptl_tcp_recv_frag_construct(mca_ptl_tcp_recv_frag_t* frag);
|
|
|
|
static void mca_ptl_tcp_recv_frag_destruct(mca_ptl_tcp_recv_frag_t* frag);
|
2004-02-05 03:50:37 +03:00
|
|
|
static bool mca_ptl_tcp_recv_frag_header(mca_ptl_tcp_recv_frag_t* frag, int sd, size_t);
|
|
|
|
static bool mca_ptl_tcp_recv_frag_ack(mca_ptl_tcp_recv_frag_t* frag, int sd);
|
|
|
|
static bool mca_ptl_tcp_recv_frag_frag(mca_ptl_tcp_recv_frag_t* frag, int sd);
|
|
|
|
static bool mca_ptl_tcp_recv_frag_match(mca_ptl_tcp_recv_frag_t* frag, int sd);
|
|
|
|
static bool mca_ptl_tcp_recv_frag_data(mca_ptl_tcp_recv_frag_t* frag, int sd);
|
|
|
|
static bool mca_ptl_tcp_recv_frag_discard(mca_ptl_tcp_recv_frag_t* frag, int sd);
|
|
|
|
|
|
|
|
|
2005-07-03 20:06:07 +04:00
|
|
|
opal_class_t mca_ptl_tcp_recv_frag_t_class = {
|
2004-01-29 01:52:51 +03:00
|
|
|
"mca_ptl_tcp_recv_frag_t",
|
2004-02-13 01:42:39 +03:00
|
|
|
OBJ_CLASS(mca_ptl_base_recv_frag_t),
|
2005-07-03 20:06:07 +04:00
|
|
|
(opal_construct_t)mca_ptl_tcp_recv_frag_construct,
|
|
|
|
(opal_destruct_t)mca_ptl_tcp_recv_frag_destruct
|
2004-01-29 01:52:51 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2004-06-04 02:13:01 +04:00
|
|
|
/*
|
|
|
|
* TCP fragment constructor
|
|
|
|
*/
|
|
|
|
|
2004-02-10 17:04:27 +03:00
|
|
|
static void mca_ptl_tcp_recv_frag_construct(mca_ptl_tcp_recv_frag_t* frag)
|
2004-01-29 01:52:51 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2004-02-04 00:33:29 +03:00
|
|
|
|
2004-06-04 02:13:01 +04:00
|
|
|
/*
|
|
|
|
* TCP fragment destructor
|
|
|
|
*/
|
|
|
|
|
2004-02-10 17:04:27 +03:00
|
|
|
static void mca_ptl_tcp_recv_frag_destruct(mca_ptl_tcp_recv_frag_t* frag)
|
2004-01-29 01:52:51 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2004-06-04 02:13:01 +04:00
|
|
|
/*
|
|
|
|
* Callback from event library when socket has data available
|
|
|
|
* for receive.
|
|
|
|
*/
|
2004-01-29 01:52:51 +03:00
|
|
|
|
|
|
|
bool mca_ptl_tcp_recv_frag_handler(mca_ptl_tcp_recv_frag_t* frag, int sd)
|
|
|
|
{
|
2004-02-05 03:50:37 +03:00
|
|
|
/* read common header */
|
2004-10-13 01:50:25 +04:00
|
|
|
if(frag->frag_hdr_cnt < sizeof(mca_ptl_base_header_t)) {
|
2004-04-06 20:13:17 +04:00
|
|
|
if(mca_ptl_tcp_recv_frag_header(frag, sd, sizeof(mca_ptl_base_header_t)) == false)
|
2004-01-29 01:52:51 +03:00
|
|
|
return false;
|
|
|
|
|
2004-10-13 01:50:25 +04:00
|
|
|
/* convert this to host byte order if required */
|
2004-11-18 01:47:08 +03:00
|
|
|
if(frag->frag_recv.frag_base.frag_peer->peer_nbo) {
|
2004-10-13 01:50:25 +04:00
|
|
|
/* note this field is only a byte - so doesn't matter what the byte ordering is */
|
|
|
|
switch(frag->frag_recv.frag_base.frag_header.hdr_common.hdr_type) {
|
|
|
|
case MCA_PTL_HDR_TYPE_MATCH:
|
2005-04-13 20:11:20 +04:00
|
|
|
MCA_PTL_BASE_MATCH_HDR_NTOH(frag->frag_recv.frag_base.frag_header.hdr_match);
|
2004-10-13 01:50:25 +04:00
|
|
|
break;
|
2004-11-18 01:47:08 +03:00
|
|
|
case MCA_PTL_HDR_TYPE_RNDV:
|
|
|
|
MCA_PTL_BASE_RNDV_HDR_NTOH(frag->frag_recv.frag_base.frag_header.hdr_rndv);
|
|
|
|
break;
|
2004-10-13 01:50:25 +04:00
|
|
|
case MCA_PTL_HDR_TYPE_FRAG:
|
|
|
|
MCA_PTL_BASE_FRAG_HDR_NTOH(frag->frag_recv.frag_base.frag_header.hdr_frag);
|
|
|
|
break;
|
|
|
|
case MCA_PTL_HDR_TYPE_ACK:
|
|
|
|
case MCA_PTL_HDR_TYPE_NACK:
|
2004-10-14 11:05:46 +04:00
|
|
|
MCA_PTL_BASE_ACK_HDR_NTOH(frag->frag_recv.frag_base.frag_header.hdr_ack);
|
2004-10-13 01:50:25 +04:00
|
|
|
break;
|
|
|
|
default:
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output(0, "mca_ptl_tcp_recv_frag_handler: invalid message type: %08X",
|
2004-10-13 01:50:25 +04:00
|
|
|
*(unsigned long*)&frag->frag_recv.frag_base.frag_header);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2005-04-13 20:11:20 +04:00
|
|
|
if( (MCA_PTL_HDR_TYPE_MATCH == frag->frag_recv.frag_base.frag_header.hdr_common.hdr_type) ||
|
|
|
|
(MCA_PTL_HDR_TYPE_RNDV == frag->frag_recv.frag_base.frag_header.hdr_common.hdr_type) ) {
|
|
|
|
/* first pass through - attempt a match */
|
|
|
|
mca_ptl_base_module_t* ptl = frag->frag_recv.frag_base.frag_owner;
|
|
|
|
/* attempt to match a posted recv */
|
|
|
|
if (ptl->ptl_match( ptl, &frag->frag_recv,
|
|
|
|
&frag->frag_recv.frag_base.frag_header.hdr_match)) {
|
|
|
|
mca_ptl_tcp_recv_frag_matched(frag, 0, frag->frag_recv.frag_base.frag_header.hdr_rndv.hdr_frag_length);
|
|
|
|
} else {
|
|
|
|
/* match was not made - so allocate buffer for eager send */
|
|
|
|
if(frag->frag_recv.frag_base.frag_header.hdr_match.hdr_msg_length > 0) {
|
|
|
|
frag->frag_size = frag->frag_recv.frag_base.frag_header.hdr_rndv.hdr_frag_length;
|
|
|
|
frag->frag_recv.frag_base.frag_addr = malloc(frag->frag_size);
|
|
|
|
frag->frag_recv.frag_base.frag_size = frag->frag_size;
|
|
|
|
frag->frag_recv.frag_is_buffered = true;
|
|
|
|
} else {
|
|
|
|
frag->frag_recv.frag_base.frag_size = 0;
|
|
|
|
frag->frag_recv.frag_is_buffered = false;
|
|
|
|
frag->frag_size = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-10-13 01:50:25 +04:00
|
|
|
}
|
|
|
|
|
2004-07-15 22:08:20 +04:00
|
|
|
switch(frag->frag_recv.frag_base.frag_header.hdr_common.hdr_type) {
|
2004-02-05 03:50:37 +03:00
|
|
|
case MCA_PTL_HDR_TYPE_MATCH:
|
2004-11-18 01:47:08 +03:00
|
|
|
case MCA_PTL_HDR_TYPE_RNDV:
|
2004-02-05 03:50:37 +03:00
|
|
|
return mca_ptl_tcp_recv_frag_match(frag, sd);
|
|
|
|
case MCA_PTL_HDR_TYPE_FRAG:
|
|
|
|
return mca_ptl_tcp_recv_frag_frag(frag, sd);
|
|
|
|
case MCA_PTL_HDR_TYPE_ACK:
|
|
|
|
case MCA_PTL_HDR_TYPE_NACK:
|
|
|
|
return mca_ptl_tcp_recv_frag_ack(frag, sd);
|
|
|
|
default:
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output(0, "mca_ptl_tcp_recv_frag_handler: invalid message type: %08X",
|
2004-07-15 22:08:20 +04:00
|
|
|
*(unsigned long*)&frag->frag_recv.frag_base.frag_header);
|
2004-10-13 01:50:25 +04:00
|
|
|
return true;
|
2004-02-04 00:33:29 +03:00
|
|
|
}
|
2004-01-29 01:52:51 +03:00
|
|
|
}
|
|
|
|
|
2004-06-04 02:13:01 +04:00
|
|
|
/*
|
|
|
|
* Receive fragment header
|
|
|
|
*/
|
2004-02-04 00:33:29 +03:00
|
|
|
|
2004-02-05 03:50:37 +03:00
|
|
|
static bool mca_ptl_tcp_recv_frag_header(mca_ptl_tcp_recv_frag_t* frag, int sd, size_t size)
|
2004-01-29 01:52:51 +03:00
|
|
|
{
|
|
|
|
/* non-blocking read - continue if interrupted, otherwise wait until data available */
|
2004-07-15 22:08:20 +04:00
|
|
|
unsigned char* ptr = (unsigned char*)&frag->frag_recv.frag_base.frag_header;
|
2004-04-23 05:38:41 +04:00
|
|
|
while(frag->frag_hdr_cnt < size) {
|
2004-10-28 22:13:43 +04:00
|
|
|
int cnt = recv(sd, (char *)(ptr + frag->frag_hdr_cnt), size - frag->frag_hdr_cnt, 0);
|
2004-01-29 01:52:51 +03:00
|
|
|
if(cnt == 0) {
|
2004-07-15 22:08:20 +04:00
|
|
|
mca_ptl_tcp_peer_close(frag->frag_recv.frag_base.frag_peer);
|
2005-07-03 20:22:16 +04:00
|
|
|
OMPI_FREE_LIST_RETURN(&mca_ptl_tcp_component.tcp_recv_frags, (opal_list_item_t*)frag);
|
2004-01-29 01:52:51 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(cnt < 0) {
|
2005-01-20 03:03:23 +03:00
|
|
|
switch(ompi_socket_errno) {
|
2004-01-29 01:52:51 +03:00
|
|
|
case EINTR:
|
|
|
|
continue;
|
|
|
|
case EWOULDBLOCK:
|
2005-07-04 03:31:27 +04:00
|
|
|
/* opal_output(0, "mca_ptl_tcp_recv_frag_header: EWOULDBLOCK\n"); */
|
2004-01-29 01:52:51 +03:00
|
|
|
return false;
|
|
|
|
default:
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output(0, "mca_ptl_tcp_recv_frag_header: recv() failed with errno=%d", ompi_socket_errno);
|
2004-07-15 22:08:20 +04:00
|
|
|
mca_ptl_tcp_peer_close(frag->frag_recv.frag_base.frag_peer);
|
2005-07-03 20:22:16 +04:00
|
|
|
OMPI_FREE_LIST_RETURN(&mca_ptl_tcp_component.tcp_recv_frags, (opal_list_item_t*)frag);
|
2004-01-29 01:52:51 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2004-04-23 05:38:41 +04:00
|
|
|
frag->frag_hdr_cnt += cnt;
|
|
|
|
#if MCA_PTL_TCP_STATISTICS
|
2004-08-02 04:24:22 +04:00
|
|
|
((mca_ptl_tcp_module_t*)frag->frag_owner)->ptl_bytes_recv += cnt;
|
2004-04-23 05:38:41 +04:00
|
|
|
#endif
|
2004-01-29 01:52:51 +03:00
|
|
|
}
|
2004-04-23 05:38:41 +04:00
|
|
|
return true;
|
2004-02-05 03:50:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-04 02:13:01 +04:00
|
|
|
/*
|
|
|
|
* Receive and process an ack.
|
|
|
|
*/
|
|
|
|
|
2004-02-05 03:50:37 +03:00
|
|
|
static bool mca_ptl_tcp_recv_frag_ack(mca_ptl_tcp_recv_frag_t* frag, int sd)
|
|
|
|
{
|
2004-02-10 19:53:41 +03:00
|
|
|
mca_ptl_tcp_send_frag_t* sendfrag;
|
2005-05-09 23:37:10 +04:00
|
|
|
mca_ptl_base_send_request_t* sendreq;
|
2004-07-15 22:08:20 +04:00
|
|
|
sendfrag = (mca_ptl_tcp_send_frag_t*)frag->frag_recv.frag_base.frag_header.hdr_ack.hdr_src_ptr.pval;
|
|
|
|
sendreq = sendfrag->frag_send.frag_request;
|
|
|
|
sendreq->req_peer_match = frag->frag_recv.frag_base.frag_header.hdr_ack.hdr_dst_match;
|
2004-05-19 01:06:11 +04:00
|
|
|
mca_ptl_tcp_send_frag_progress(sendfrag);
|
2004-07-15 22:08:20 +04:00
|
|
|
mca_ptl_tcp_recv_frag_return(frag->frag_recv.frag_base.frag_owner, frag);
|
2004-02-05 03:50:37 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-04 02:13:01 +04:00
|
|
|
/*
|
|
|
|
* Receive and process a match request - first fragment.
|
|
|
|
*/
|
|
|
|
|
2004-02-05 03:50:37 +03:00
|
|
|
static bool mca_ptl_tcp_recv_frag_match(mca_ptl_tcp_recv_frag_t* frag, int sd)
|
|
|
|
{
|
2004-03-31 21:00:38 +04:00
|
|
|
/* receive fragment data */
|
2004-07-15 22:08:20 +04:00
|
|
|
if(frag->frag_msg_cnt < frag->frag_recv.frag_base.frag_size) {
|
2004-03-31 21:00:38 +04:00
|
|
|
if(mca_ptl_tcp_recv_frag_data(frag, sd) == false) {
|
2004-02-05 03:50:37 +03:00
|
|
|
return false;
|
2004-03-31 21:00:38 +04:00
|
|
|
}
|
2004-02-05 03:50:37 +03:00
|
|
|
}
|
|
|
|
|
2004-03-31 21:00:38 +04:00
|
|
|
/* discard any data that exceeds the posted receive */
|
2004-11-18 01:47:08 +03:00
|
|
|
if(frag->frag_msg_cnt < frag->frag_size) {
|
2004-03-31 21:00:38 +04:00
|
|
|
if(mca_ptl_tcp_recv_frag_discard(frag, sd) == false) {
|
2004-02-05 03:50:37 +03:00
|
|
|
return false;
|
2004-11-18 01:47:08 +03:00
|
|
|
}
|
2004-03-31 21:00:38 +04:00
|
|
|
}
|
2004-02-05 03:50:37 +03:00
|
|
|
|
2004-11-18 01:47:08 +03:00
|
|
|
mca_ptl_tcp_recv_frag_progress(frag);
|
2004-02-05 03:50:37 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-04 02:13:01 +04:00
|
|
|
/*
|
|
|
|
* Receive and process 2nd+ fragments of a multi-fragment message.
|
|
|
|
*/
|
|
|
|
|
2004-02-05 03:50:37 +03:00
|
|
|
static bool mca_ptl_tcp_recv_frag_frag(mca_ptl_tcp_recv_frag_t* frag, int sd)
|
|
|
|
{
|
2004-03-15 17:46:12 +03:00
|
|
|
/* get request from header */
|
2004-02-05 03:50:37 +03:00
|
|
|
if(frag->frag_msg_cnt == 0) {
|
2005-05-09 23:37:10 +04:00
|
|
|
frag->frag_recv.frag_request = (mca_ptl_base_recv_request_t *)frag->frag_recv.frag_base.frag_header.hdr_frag.hdr_dst_ptr.pval;
|
2004-11-18 01:47:08 +03:00
|
|
|
mca_ptl_tcp_recv_frag_matched(frag,
|
|
|
|
frag->frag_recv.frag_base.frag_header.hdr_frag.hdr_frag_offset,
|
|
|
|
frag->frag_recv.frag_base.frag_header.hdr_frag.hdr_frag_length);
|
2004-03-15 17:46:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* continue to receive user data */
|
2004-07-15 22:08:20 +04:00
|
|
|
if(frag->frag_msg_cnt < frag->frag_recv.frag_base.frag_size) {
|
2004-02-05 03:50:37 +03:00
|
|
|
if(mca_ptl_tcp_recv_frag_data(frag, sd) == false)
|
|
|
|
return false;
|
2004-01-29 01:52:51 +03:00
|
|
|
}
|
2004-02-05 03:50:37 +03:00
|
|
|
|
2004-11-18 01:47:08 +03:00
|
|
|
if(frag->frag_msg_cnt < frag->frag_size) {
|
2004-02-05 03:50:37 +03:00
|
|
|
if(mca_ptl_tcp_recv_frag_discard(frag, sd) == false)
|
|
|
|
return false;
|
2004-11-18 01:47:08 +03:00
|
|
|
}
|
2004-02-05 03:50:37 +03:00
|
|
|
|
|
|
|
/* indicate completion status */
|
2004-03-16 18:12:11 +03:00
|
|
|
mca_ptl_tcp_recv_frag_progress(frag);
|
2004-01-29 01:52:51 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2004-02-05 03:50:37 +03:00
|
|
|
|
2004-01-29 01:52:51 +03:00
|
|
|
/*
|
|
|
|
* Continue with non-blocking recv() calls until the entire
|
|
|
|
* fragment is received.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static bool mca_ptl_tcp_recv_frag_data(mca_ptl_tcp_recv_frag_t* frag, int sd)
|
|
|
|
{
|
2004-07-15 22:08:20 +04:00
|
|
|
while(frag->frag_msg_cnt < frag->frag_recv.frag_base.frag_size) {
|
2004-10-28 22:13:43 +04:00
|
|
|
int cnt = recv(sd, (char*)frag->frag_recv.frag_base.frag_addr+frag->frag_msg_cnt,
|
2004-07-15 22:08:20 +04:00
|
|
|
frag->frag_recv.frag_base.frag_size-frag->frag_msg_cnt, 0);
|
2004-01-29 01:52:51 +03:00
|
|
|
if(cnt == 0) {
|
2004-07-15 22:08:20 +04:00
|
|
|
mca_ptl_tcp_peer_close(frag->frag_recv.frag_base.frag_peer);
|
2005-07-03 20:22:16 +04:00
|
|
|
OMPI_FREE_LIST_RETURN(&mca_ptl_tcp_component.tcp_recv_frags, (opal_list_item_t*)frag);
|
2004-01-29 01:52:51 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(cnt < 0) {
|
2005-01-20 03:03:23 +03:00
|
|
|
switch(ompi_socket_errno) {
|
2004-01-29 01:52:51 +03:00
|
|
|
case EINTR:
|
|
|
|
continue;
|
|
|
|
case EWOULDBLOCK:
|
|
|
|
return false;
|
|
|
|
default:
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output(0, "mca_ptl_tcp_recv_frag_data: recv() failed with errno=%d", ompi_socket_errno);
|
2004-07-15 22:08:20 +04:00
|
|
|
mca_ptl_tcp_peer_close(frag->frag_recv.frag_base.frag_peer);
|
2005-07-03 20:22:16 +04:00
|
|
|
OMPI_FREE_LIST_RETURN(&mca_ptl_tcp_component.tcp_recv_frags, (opal_list_item_t*)frag);
|
2004-01-29 01:52:51 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2004-04-23 05:38:41 +04:00
|
|
|
frag->frag_msg_cnt += cnt;
|
|
|
|
#if MCA_PTL_TCP_STATISTICS
|
2004-08-02 04:24:22 +04:00
|
|
|
((mca_ptl_tcp_module_t*)frag->frag_owner)->ptl_bytes_recv += cnt;
|
2004-04-23 05:38:41 +04:00
|
|
|
#endif
|
2004-01-29 01:52:51 +03:00
|
|
|
}
|
2004-04-23 05:38:41 +04:00
|
|
|
return true;
|
2004-01-29 01:52:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the app posted a receive buffer smaller than the
|
|
|
|
* fragment, receive and discard remaining bytes.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static bool mca_ptl_tcp_recv_frag_discard(mca_ptl_tcp_recv_frag_t* frag, int sd)
|
|
|
|
{
|
2004-11-18 01:47:08 +03:00
|
|
|
while(frag->frag_msg_cnt < frag->frag_size) {
|
|
|
|
size_t count = frag->frag_size - frag->frag_msg_cnt;
|
2004-05-19 01:06:11 +04:00
|
|
|
void *rbuf = malloc(count);
|
2004-10-28 22:13:43 +04:00
|
|
|
int cnt = recv(sd, (char *)rbuf, count, 0);
|
2004-02-10 03:09:36 +03:00
|
|
|
free(rbuf);
|
2004-01-29 01:52:51 +03:00
|
|
|
if(cnt == 0) {
|
2004-07-15 22:08:20 +04:00
|
|
|
mca_ptl_tcp_peer_close(frag->frag_recv.frag_base.frag_peer);
|
2005-07-03 20:22:16 +04:00
|
|
|
OMPI_FREE_LIST_RETURN(&mca_ptl_tcp_component.tcp_recv_frags, (opal_list_item_t*)frag);
|
2004-01-29 01:52:51 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(cnt < 0) {
|
2005-01-20 03:03:23 +03:00
|
|
|
switch(ompi_socket_errno) {
|
2004-01-29 01:52:51 +03:00
|
|
|
case EINTR:
|
|
|
|
continue;
|
|
|
|
case EWOULDBLOCK:
|
2005-07-04 03:31:27 +04:00
|
|
|
/* opal_output(0, "mca_ptl_tcp_recv_frag_discard: EWOULDBLOCK\n"); */
|
2004-01-29 01:52:51 +03:00
|
|
|
return false;
|
|
|
|
default:
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output(0, "mca_ptl_tcp_recv_frag_discard: recv() failed with errno=%d", ompi_socket_errno);
|
2004-07-15 22:08:20 +04:00
|
|
|
mca_ptl_tcp_peer_close(frag->frag_recv.frag_base.frag_peer);
|
2005-07-03 20:22:16 +04:00
|
|
|
OMPI_FREE_LIST_RETURN(&mca_ptl_tcp_component.tcp_recv_frags, (opal_list_item_t*)frag);
|
2004-01-29 01:52:51 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2004-04-23 05:38:41 +04:00
|
|
|
frag->frag_msg_cnt += cnt;
|
|
|
|
#if MCA_PTL_TCP_STATISTICS
|
2004-08-02 04:24:22 +04:00
|
|
|
((mca_ptl_tcp_module_t*)frag->frag_owner)->ptl_bytes_recv += cnt;
|
2004-04-23 05:38:41 +04:00
|
|
|
#endif
|
2004-01-29 01:52:51 +03:00
|
|
|
}
|
2004-04-23 05:38:41 +04:00
|
|
|
return true;
|
2004-01-29 01:52:51 +03:00
|
|
|
}
|
2004-02-10 19:53:41 +03:00
|
|
|
|