-int gras_trp_sg_chunk_recv(gras_socket_t sock,
- char *data,
- unsigned long int size){
- gras_trp_procdata_t pd=(gras_trp_procdata_t)gras_libdata_by_id(gras_trp_libdata_id);
-
- m_task_t task=NULL;
- sg_task_data_t *task_data;
- gras_trp_sg_sock_data_t *sock_data = sock->data;
-
- xbt_assert0(sock->meas, "SG chunk exchange shouldn't be used on non-measurement sockets");
- XBT_IN;
- DEBUG4("recv chunk on %s -> %s:%d (size=%ld)",
- MSG_host_get_name(sock_data->to_host),
- MSG_host_get_name(MSG_host_self()), sock_data->to_chan, size);
- if (MSG_task_get(&task, (sock->meas ? pd->measChan : pd->chan)) != MSG_OK)
- THROW0(system_error,0,"Error in MSG_task_get()");
- DEBUG1("Got chuck %s",MSG_task_get_name(task));
-
- task_data = MSG_task_get_data(task);
- if (task_data->size != size)
- THROW5(mismatch_error,0,
- "Got %d bytes when %ld where expected (in %s->%s:%d)",
- task_data->size, size,
- MSG_host_get_name(sock_data->to_host),
- MSG_host_get_name(MSG_host_self()), sock_data->to_chan);
- memcpy(data,task_data->data,size);
- free(task_data->data);
- free(task_data);
-
- if (MSG_task_destroy(task) != MSG_OK)
- THROW0(system_error,0,"Error in MSG_task_destroy()");
-
- XBT_OUT;
- return size;
-}
+ SIMIX_req_mutex_lock(remote_sock_data->mutex);
+ /* wait for communication end */
+ SIMIX_req_cond_wait(remote_sock_data->cond, remote_sock_data->mutex);
+
+ if (msg_got->payl_size != size)
+ THROW5(mismatch_error, 0,
+ "Got %d bytes when %ld where expected (in %s->%s:%d)",
+ msg_got->payl_size, size,
+ SIMIX_req_host_get_name(sock_data->to_host),
+ SIMIX_host_self_get_name(), sock->peer_port);
+
+ if (data)
+ memcpy(data, msg_got->payl, size);