git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@1694
48e7efb5-ca39-0410-a469-
dd3cf9ba447f
unsigned long int size);
void (*chunk_recv)(gras_socket_t sd,
char *data,
unsigned long int size);
void (*chunk_recv)(gras_socket_t sd,
char *data,
- unsigned long int size);
+ unsigned long int size,
+ unsigned long int bufsize);
/* flush has to make sure that the pending communications are achieved */
void (*flush)(gras_socket_t sd);
/* flush has to make sure that the pending communications are achieved */
void (*flush)(gras_socket_t sd);
void gras_trp_buf_chunk_recv(gras_socket_t sd,
char *data,
void gras_trp_buf_chunk_recv(gras_socket_t sd,
char *data,
- unsigned long int size);
+ unsigned long int size,
+ unsigned long int bufsize);
void gras_trp_buf_flush(gras_socket_t sock);
void gras_trp_buf_flush(gras_socket_t sock);
void
gras_trp_buf_chunk_recv(gras_socket_t sock,
char *chunk,
void
gras_trp_buf_chunk_recv(gras_socket_t sock,
char *chunk,
- unsigned long int size) {
+ unsigned long int size,
+ unsigned long int bufsize) {
xbt_ex_t e;
gras_trp_bufdata_t *data=sock->bufdata;
xbt_ex_t e;
gras_trp_bufdata_t *data=sock->bufdata;
if (gras_if_RL()) {
DEBUG0("Recv the size");
TRY {
if (gras_if_RL()) {
DEBUG0("Recv the size");
TRY {
- _buf_super->chunk_recv(sock,(char*)&nextsize, 4);
+ _buf_super->chunk_recv(sock,(char*)&nextsize, 4,4);
} CATCH(e) {
RETHROW3("Unable to get the chunk size on %p (peer = %s:%d): %s",
sock,gras_socket_peer_name(sock),gras_socket_peer_port(sock));
} CATCH(e) {
RETHROW3("Unable to get the chunk size on %p (peer = %s:%d): %s",
sock,gras_socket_peer_name(sock),gras_socket_peer_port(sock));
- _buf_super->chunk_recv(sock, data->in.data, data->in.size);
+ _buf_super->chunk_recv(sock, data->in.data, data->in.size, data->in.size);
if (gras_if_RL()) {
data->in.pos=0;
if (gras_if_RL()) {
data->in.pos=0;
void gras_trp_file_chunk_recv(gras_socket_t sd,
char *data,
void gras_trp_file_chunk_recv(gras_socket_t sd,
char *data,
- unsigned long int size);
+ unsigned long int size,
+ unsigned long int bufsize);
void
gras_trp_file_chunk_recv(gras_socket_t sock,
char *data,
void
gras_trp_file_chunk_recv(gras_socket_t sock,
char *data,
- unsigned long int size) {
+ unsigned long int size,
+ unsigned long int bufsize) {
xbt_assert0(sock, "Cannot recv on an NULL socket");
xbt_assert0(sock->incoming, "Cannot recv on client file socket");
xbt_assert0(size >= 0, "Cannot receive a negative amount of data");
xbt_assert0(sock, "Cannot recv on an NULL socket");
xbt_assert0(sock->incoming, "Cannot recv on client file socket");
xbt_assert0(size >= 0, "Cannot receive a negative amount of data");
+ xbt_assert0(bufsize>=size,"Not enough buffer size to receive that much data");
+
while (size) {
int status = 0;
while (size) {
int status = 0;
- status = read(sock->sd, data, (long int)size);
+ status = read(sock->sd, data, (long int)bufsize);
DEBUG3("read(%d, %p, %ld);", sock->sd, data, size);
if (status == -1) {
DEBUG3("read(%d, %p, %ld);", sock->sd, data, size);
if (status == -1) {
- size -= status;
- data += status;
+ size -= status;
+ bufsize -= status;
+ data += status;
} else {
THROW0(system_error,0,"file descriptor closed");
}
} else {
THROW0(system_error,0,"file descriptor closed");
}
void gras_trp_sg_chunk_recv(gras_socket_t sd,
char *data,
void gras_trp_sg_chunk_recv(gras_socket_t sd,
char *data,
- unsigned long int size);
+ unsigned long int size,
+ unsigned long int bufsize);
/***
*** Specific plugin part
/***
*** Specific plugin part
gras_trp_sg_sock_data_t *sock_data = (gras_trp_sg_sock_data_t *)sock->data;
sg_task_data_t *task_data;
gras_trp_sg_sock_data_t *sock_data = (gras_trp_sg_sock_data_t *)sock->data;
sg_task_data_t *task_data;
+ xbt_assert0(sock->meas, "SG chunk exchange shouldn't be used on non-measurement sockets");
+
sprintf(name,"Chunk[%d]",count++);
task_data=xbt_new(sg_task_data_t,1);
sprintf(name,"Chunk[%d]",count++);
task_data=xbt_new(sg_task_data_t,1);
void gras_trp_sg_chunk_recv(gras_socket_t sock,
char *data,
void gras_trp_sg_chunk_recv(gras_socket_t sock,
char *data,
- unsigned long int size){
+ unsigned long int size,
+ unsigned long int bufsize){
gras_trp_procdata_t pd=(gras_trp_procdata_t)gras_libdata_get("gras_trp");
m_task_t task=NULL;
sg_task_data_t *task_data;
gras_trp_sg_sock_data_t *sock_data = sock->data;
gras_trp_procdata_t pd=(gras_trp_procdata_t)gras_libdata_get("gras_trp");
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),
XBT_IN;
DEBUG4("recv chunk on %s -> %s:%d (size=%ld)",
MSG_host_get_name(sock_data->to_host),
void gras_trp_tcp_chunk_recv(gras_socket_t sd,
char *data,
void gras_trp_tcp_chunk_recv(gras_socket_t sd,
char *data,
- unsigned long int size);
+ unsigned long int size,
+ unsigned long int bufsize);
void gras_trp_tcp_exit(gras_trp_plugin_t plug);
void gras_trp_tcp_exit(gras_trp_plugin_t plug);
void
gras_trp_tcp_chunk_recv(gras_socket_t sock,
char *data,
void
gras_trp_tcp_chunk_recv(gras_socket_t sock,
char *data,
- unsigned long int size) {
+ unsigned long int size,
+ unsigned long int bufsize) {
/* TCP sockets are in duplex mode, don't check direction */
xbt_assert0(sock, "Cannot recv on an NULL socket");
xbt_assert0(size >= 0, "Cannot receive a negative amount of data");
/* TCP sockets are in duplex mode, don't check direction */
xbt_assert0(sock, "Cannot recv on an NULL socket");
xbt_assert0(size >= 0, "Cannot receive a negative amount of data");
+ xbt_assert0(bufsize>=size,"Not enough buffer size to receive that much data");
while (size) {
int status = 0;
DEBUG3("read(%d, %p, %ld);", sock->sd, data, size);
while (size) {
int status = 0;
DEBUG3("read(%d, %p, %ld);", sock->sd, data, size);
- status = tcp_read(sock->sd, data, (size_t)size);
+ status = tcp_read(sock->sd, data, (size_t)bufsize);
if (status < 0) {
THROW4(system_error,0,"read(%d,%p,%d) failed: %s",
if (status < 0) {
THROW4(system_error,0,"read(%d,%p,%d) failed: %s",
- size -= status;
- data += status;
+ size -= status;
+ bufsize -= status;
+ data += status;
- THROW3(system_error,0,
- "file descriptor closed (nothing read(%d, %p, %ld) on the socket)",
- sock->sd, data, size);
+ gras_socket_close(sock);
+ THROW0(system_error,0,"Socket closed by remote side");