Several small improvements:
- consistent error message when something fails (via BTL_ERROR macro) - decrease the number of jumps. - cleanup some parts of the code. This commit was SVN r12719.
Этот коммит содержится в:
родитель
657168a74c
Коммит
658879232b
@ -629,15 +629,9 @@ static void mca_btl_tcp_endpoint_recv_handler(int sd, short flags, void* user)
|
||||
btl_endpoint->endpoint_recv_frag = frag;
|
||||
} else {
|
||||
btl_endpoint->endpoint_recv_frag = NULL;
|
||||
switch(frag->hdr.type) {
|
||||
case MCA_BTL_TCP_HDR_TYPE_SEND:
|
||||
{
|
||||
mca_btl_base_recv_reg_t* reg = frag->btl->tcp_reg + frag->hdr.base.tag;
|
||||
reg->cbfunc(&frag->btl->super, frag->hdr.base.tag, &frag->base, reg->cbdata);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
if( MCA_BTL_TCP_HDR_TYPE_SEND == frag->hdr.type ) {
|
||||
mca_btl_base_recv_reg_t* reg = frag->btl->tcp_reg + frag->hdr.base.tag;
|
||||
reg->cbfunc(&frag->btl->super, frag->hdr.base.tag, &frag->base, reg->cbdata);
|
||||
}
|
||||
#if MCA_BTL_TCP_ENDPOINT_CACHE
|
||||
if( 0 != btl_endpoint->endpoint_cache_length ) {
|
||||
|
@ -107,18 +107,17 @@ bool mca_btl_tcp_frag_send(mca_btl_tcp_frag_t* frag, int sd)
|
||||
case EINTR:
|
||||
continue;
|
||||
case EWOULDBLOCK:
|
||||
/* opal_output(0, "mca_btl_tcp_frag_send: EWOULDBLOCK\n"); */
|
||||
return false;
|
||||
case EFAULT:
|
||||
BTL_ERROR(("writev error (%p, %d)\n\t%s(%d)\n",
|
||||
BTL_ERROR(("mca_btl_tcp_frag_send: writev error (%p, %d)\n\t%s(%d)\n",
|
||||
frag->iov_ptr[0].iov_base, frag->iov_ptr[0].iov_len,
|
||||
strerror(opal_socket_errno), frag->iov_cnt));
|
||||
default:
|
||||
{
|
||||
BTL_ERROR(("writev failed with errno=%d", opal_socket_errno));
|
||||
mca_btl_tcp_endpoint_close(frag->endpoint);
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
BTL_ERROR(("mca_btl_tcp_frag_send: writev failed with errno=%d", opal_socket_errno));
|
||||
mca_btl_tcp_endpoint_close(frag->endpoint);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -141,7 +140,6 @@ bool mca_btl_tcp_frag_send(mca_btl_tcp_frag_t* frag, int sd)
|
||||
return (frag->iov_cnt == 0);
|
||||
}
|
||||
|
||||
|
||||
bool mca_btl_tcp_frag_recv(mca_btl_tcp_frag_t* frag, int sd)
|
||||
{
|
||||
int cnt;
|
||||
@ -152,12 +150,12 @@ bool mca_btl_tcp_frag_recv(mca_btl_tcp_frag_t* frag, int sd)
|
||||
num_vecs = frag->iov_cnt;
|
||||
#if MCA_BTL_TCP_ENDPOINT_CACHE
|
||||
if( 0 != btl_endpoint->endpoint_cache_length ) {
|
||||
size_t length = btl_endpoint->endpoint_cache_length;
|
||||
/* It's strange at the first look but cnt have to be set to the full amount of data available.
|
||||
* After going to advance_iov_position we will use cnt to detect if there is still some
|
||||
* data pending.
|
||||
size_t length;
|
||||
/* It's strange at the first look but cnt have to be set to the full amount of data
|
||||
* available. After going to advance_iov_position we will use cnt to detect if there
|
||||
* is still some data pending.
|
||||
*/
|
||||
cnt = btl_endpoint->endpoint_cache_length;
|
||||
cnt = length = btl_endpoint->endpoint_cache_length;
|
||||
for( i = 0; i < frag->iov_cnt; i++ ) {
|
||||
if( length > frag->iov_ptr[i].iov_len )
|
||||
length = frag->iov_ptr[0].iov_len;
|
||||
@ -184,48 +182,45 @@ bool mca_btl_tcp_frag_recv(mca_btl_tcp_frag_t* frag, int sd)
|
||||
cnt = -1;
|
||||
while( cnt < 0 ) {
|
||||
cnt = readv(sd, frag->iov_ptr, num_vecs);
|
||||
if(cnt < 0) {
|
||||
switch(opal_socket_errno) {
|
||||
case EINTR:
|
||||
continue;
|
||||
case EWOULDBLOCK:
|
||||
return false;
|
||||
case EFAULT:
|
||||
opal_output( 0, "mca_btl_tcp_frag_send: writev error (%p, %d)\n\t%s(%d)\n",
|
||||
frag->iov_ptr[0].iov_base, frag->iov_ptr[0].iov_len,
|
||||
strerror(opal_socket_errno), frag->iov_cnt );
|
||||
default:
|
||||
opal_output(0, "mca_btl_tcp_frag_send: writev failed with errno=%d",
|
||||
opal_socket_errno);
|
||||
mca_btl_tcp_endpoint_close(btl_endpoint);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if( cnt == 0 ) {
|
||||
mca_btl_tcp_endpoint_close(btl_endpoint);
|
||||
return false;
|
||||
}
|
||||
goto advance_iov_position;
|
||||
if( 0 < cnt ) goto advance_iov_position;
|
||||
if( cnt == 0 ) {
|
||||
mca_btl_tcp_endpoint_close(btl_endpoint);
|
||||
return false;
|
||||
}
|
||||
switch(opal_socket_errno) {
|
||||
case EINTR:
|
||||
continue;
|
||||
case EWOULDBLOCK:
|
||||
return false;
|
||||
case EFAULT:
|
||||
BTL_ERROR(("mca_btl_tcp_frag_recv: readv error (%p, %d)\n\t%s(%d)\n",
|
||||
frag->iov_ptr[0].iov_base, frag->iov_ptr[0].iov_len,
|
||||
strerror(opal_socket_errno), frag->iov_cnt));
|
||||
mca_btl_tcp_endpoint_close(btl_endpoint);
|
||||
return false;
|
||||
default:
|
||||
BTL_ERROR(("mca_btl_tcp_frag_recv: readv failed with errno=%d", opal_socket_errno));
|
||||
mca_btl_tcp_endpoint_close(btl_endpoint);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
advance_iov_position:
|
||||
/* if the write didn't complete - update the iovec state */
|
||||
num_vecs = frag->iov_cnt;
|
||||
for( i = 0; i < num_vecs; i++ ) {
|
||||
if( cnt >= (int)frag->iov_ptr->iov_len ) {
|
||||
cnt -= frag->iov_ptr->iov_len;
|
||||
frag->iov_idx++;
|
||||
frag->iov_ptr++;
|
||||
frag->iov_cnt--;
|
||||
} else {
|
||||
if( cnt < (int)frag->iov_ptr->iov_len ) {
|
||||
frag->iov_ptr->iov_base = (ompi_iov_base_ptr_t)
|
||||
(((unsigned char*)frag->iov_ptr->iov_base) + cnt);
|
||||
frag->iov_ptr->iov_len -= cnt;
|
||||
cnt = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
cnt -= frag->iov_ptr->iov_len;
|
||||
frag->iov_idx++;
|
||||
frag->iov_ptr++;
|
||||
frag->iov_cnt--;
|
||||
}
|
||||
|
||||
#if MCA_BTL_TCP_ENDPOINT_CACHE
|
||||
btl_endpoint->endpoint_cache_length = cnt;
|
||||
#endif /* MCA_BTL_TCP_ENDPOINT_CACHE */
|
||||
|
@ -80,7 +80,7 @@ OBJ_CLASS_DECLARATION(mca_btl_tcp_frag_user_t);
|
||||
#define MCA_BTL_TCP_FRAG_ALLOC_EAGER(frag, rc) \
|
||||
{ \
|
||||
\
|
||||
ompi_free_list_item_t *item; \
|
||||
ompi_free_list_item_t *item; \
|
||||
OMPI_FREE_LIST_WAIT(&mca_btl_tcp_component.tcp_frag_eager, item, rc); \
|
||||
frag = (mca_btl_tcp_frag_t*) item; \
|
||||
}
|
||||
@ -88,7 +88,7 @@ OBJ_CLASS_DECLARATION(mca_btl_tcp_frag_user_t);
|
||||
#define MCA_BTL_TCP_FRAG_ALLOC_MAX(frag, rc) \
|
||||
{ \
|
||||
\
|
||||
ompi_free_list_item_t *item; \
|
||||
ompi_free_list_item_t *item; \
|
||||
OMPI_FREE_LIST_WAIT(&mca_btl_tcp_component.tcp_frag_max, item, rc); \
|
||||
frag = (mca_btl_tcp_frag_t*) item; \
|
||||
}
|
||||
@ -102,8 +102,7 @@ OBJ_CLASS_DECLARATION(mca_btl_tcp_frag_user_t);
|
||||
|
||||
#define MCA_BTL_TCP_FRAG_RETURN(frag) \
|
||||
{ \
|
||||
OMPI_FREE_LIST_RETURN(frag->my_list, \
|
||||
(ompi_free_list_item_t*)(frag)); \
|
||||
OMPI_FREE_LIST_RETURN(frag->my_list, (ompi_free_list_item_t*)(frag)); \
|
||||
}
|
||||
|
||||
#define MCA_BTL_TCP_FRAG_INIT_DST(frag,ep) \
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user