Add some further initialization and protection for zero-byte messages
This commit was SVN r32644.
Этот коммит содержится в:
родитель
2b225e3776
Коммит
8faabed2cd
@ -75,6 +75,16 @@ int opal_dss_load(opal_buffer_t *buffer, void *payload,
|
||||
free(buffer->base_ptr);
|
||||
}
|
||||
|
||||
/* if it's a NULL payload, just set things and return */
|
||||
if (NULL == payload) {
|
||||
buffer->base_ptr = NULL;
|
||||
buffer->pack_ptr = buffer->base_ptr;
|
||||
buffer->unpack_ptr = buffer->base_ptr;
|
||||
buffer->bytes_used = 0;
|
||||
buffer->bytes_allocated = 0;
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
/* populate the buffer */
|
||||
buffer->base_ptr = (char*)payload;
|
||||
|
||||
|
@ -246,6 +246,7 @@ OBJ_CLASS_INSTANCE(orte_rml_send_request_t,
|
||||
static void recv_cons(orte_rml_recv_t *ptr)
|
||||
{
|
||||
ptr->iov.iov_base = NULL;
|
||||
ptr->iov.iov_len = 0;
|
||||
}
|
||||
static void recv_des(orte_rml_recv_t *ptr)
|
||||
{
|
||||
|
@ -160,13 +160,15 @@ static void send_msg(int fd, short args, void *cbdata)
|
||||
bytes += req->post.iov[i].iov_len;
|
||||
}
|
||||
/* get the required memory allocation */
|
||||
rcv->iov.iov_base = (IOVBASE_TYPE*)malloc(bytes);
|
||||
rcv->iov.iov_len = bytes;
|
||||
/* transfer the bytes */
|
||||
ptr = (char*)rcv->iov.iov_base;
|
||||
for (i = 0 ; i < req->post.count ; ++i) {
|
||||
memcpy(ptr, req->post.iov[i].iov_base, req->post.iov[i].iov_len);
|
||||
ptr += req->post.iov[i].iov_len;
|
||||
if (0 < bytes) {
|
||||
rcv->iov.iov_base = (IOVBASE_TYPE*)malloc(bytes);
|
||||
rcv->iov.iov_len = bytes;
|
||||
/* transfer the bytes */
|
||||
ptr = (char*)rcv->iov.iov_base;
|
||||
for (i = 0 ; i < req->post.count ; ++i) {
|
||||
memcpy(ptr, req->post.iov[i].iov_base, req->post.iov[i].iov_len);
|
||||
ptr += req->post.iov[i].iov_len;
|
||||
}
|
||||
}
|
||||
} else if (0 < req->post.buffer->bytes_used) {
|
||||
rcv->iov.iov_base = (IOVBASE_TYPE*)malloc(req->post.buffer->bytes_used);
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user