From: mquinson Date: Thu, 25 Nov 2010 09:24:22 +0000 (+0000) Subject: implement refcount on sockets since they are somehow shared between sender and receiv... X-Git-Tag: v3_5~183 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/416aad22db0fd7f20e563e7b8980a2a6f9e4a7c8 implement refcount on sockets since they are somehow shared between sender and receiver in SG. This makes the all2all test pass (yuhu) git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@8647 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/src/gras/Msg/sg_msg.c b/src/gras/Msg/sg_msg.c index fc1b66d695..7f87f667b8 100644 --- a/src/gras/Msg/sg_msg.c +++ b/src/gras/Msg/sg_msg.c @@ -47,7 +47,7 @@ gras_msg_t gras_msg_recv_any(void) rdv_client : sock_data->rdv_server, sock_data->comm_recv); - /* The following assert fails in some valid conditions, we need to + /* If the following assert fails in some valid conditions, we need to * change the code downward looking for the socket again. * * For now it relies on the facts (A) that sockets and comms are aligned @@ -138,6 +138,7 @@ void gras_msg_send_ext(gras_socket_t sock, /*initialize gras message */ msg = xbt_new(s_gras_msg_t, 1); + sock->refcount++; msg->expe = sock; msg->kind = kind; msg->type = msgtype; diff --git a/src/gras/Transport/transport.c b/src/gras/Transport/transport.c index cefc3e9453..e7c51e091b 100644 --- a/src/gras/Transport/transport.c +++ b/src/gras/Transport/transport.c @@ -162,6 +162,7 @@ void gras_trp_socket_new(int incoming, gras_socket_t * dst) sock->valid = 1; sock->moredata = 0; + sock->refcount = 1; sock->sd = -1; sock->data = NULL; @@ -336,6 +337,9 @@ void gras_socket_close_voidp(void *sock) /** \brief Close socket */ void gras_socket_close(gras_socket_t sock) { + if (--sock->refcount) + return; + xbt_dynar_t sockets = ((gras_trp_procdata_t) gras_libdata_by_id(gras_trp_libdata_id))->sockets; @@ -438,6 +442,7 @@ int gras_socket_peer_port(gras_socket_t sock) const char *gras_socket_peer_name(gras_socket_t sock) { + xbt_assert(sock->plugin); return (*sock->plugin->peer_name)(sock); } diff --git a/src/gras/Transport/transport_private.h b/src/gras/Transport/transport_private.h index ad0f55d2f7..c74efd51ee 100644 --- a/src/gras/Transport/transport_private.h +++ b/src/gras/Transport/transport_private.h @@ -70,6 +70,8 @@ typedef struct s_gras_socket { int recvd:1; /* true if the recvd_val field contains one byte of the stream (that we peek'ed to check the socket validity) */ char recvd_val; /* what we peeked from the socket, if any */ + int refcount; /* refcounting on shared sockets */ + unsigned long int buf_size; /* what to say to the OS. Field here to remember it when accepting */