-gras_error_t gras_trp_sg_chunk_recv(gras_socket_t *sock,
- char *data,
- long int size){
- gras_procdata_t *pd=gras_procdata_get();
-
- m_task_t task=NULL;
- sg_task_data_t *task_data;
- gras_trp_sg_sock_data_t *sock_data = sock->data;
-
- GRAS_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->raw ? pd->rawChan : pd->chan)) != MSG_OK)
- RAISE0(unknown_error,"Error in MSG_task_get()");
-
- task_data = MSG_task_get_data(task);
- if (task_data->size != size)
- RAISE5(mismatch_error,
- "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)
- RAISE0(unknown_error,"Error in MSG_task_destroy()");
-
- GRAS_OUT;
- return no_error;
+int gras_trp_sg_chunk_recv(gras_socket_t sock,
+ char *data, unsigned long int size)
+{
+ //gras_trp_sg_sock_data_t *sock_data =
+ // (gras_trp_sg_sock_data_t *) sock->data;
+
+ //SIMIX_req_comm_recv(sock_data->rdv,-1,NULL,0,NULL);
+ THROW_UNIMPLEMENTED;
+#ifdef KILLME
+ gras_trp_sg_sock_data_t *remote_sock_data;
+ gras_socket_t remote_socket = NULL;
+ gras_msg_t msg_got;
+ gras_msg_procdata_t msg_procdata =
+ (gras_msg_procdata_t) gras_libdata_by_name("gras_msg");
+ gras_trp_procdata_t trp_proc =
+ (gras_trp_procdata_t) gras_libdata_by_id(gras_trp_libdata_id);
+
+ xbt_assert0(sock->meas,
+ "SG chunk exchange shouldn't be used on non-measurement sockets");
+ xbt_queue_shift_timed(trp_proc->meas_selectable_sockets,
+ &remote_socket, 60);
+
+ if (remote_socket == NULL) {
+ THROW0(timeout_error, 0, "Timeout");
+ }
+
+ remote_sock_data = (gras_trp_sg_sock_data_t *) remote_socket->data;
+ msg_got = xbt_fifo_shift(msg_procdata->msg_to_receive_queue_meas);
+
+ sock_data = (gras_trp_sg_sock_data_t *) sock->data;
+
+ /* ok, I'm here, you can continue the communication */
+ SIMIX_req_cond_signal(remote_sock_data->cond);
+
+ 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);
+
+ if (msg_got->payl)
+ xbt_free(msg_got->payl);
+
+ xbt_free(msg_got);
+ SIMIX_req_mutex_unlock(remote_sock_data->mutex);
+#endif
+ return 0;