Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
some more paranoia to track that damn bug
[simgrid.git] / src / gras / Transport / transport_plugin_sg.c
index 911ae8b..6cd4c72 100644 (file)
@@ -91,8 +91,20 @@ static const char* gras_trp_sg_peer_name(gras_socket_t s) {
   gras_trp_sg_sock_data_t sockdata = s->data;
   if (sockdata->server == SIMIX_process_self())
     return SIMIX_host_get_name(SIMIX_process_get_host(sockdata->client));
-  else
+  else {
+    if (sockdata->client!=SIMIX_process_self()) {
+      /* THAT'S BAD! I should be either client or server of the sockets I get messages on!! */
+      /* This is where the bug is visible. Try to die as loudly as possible */
+      xbt_backtrace_display_current();
+      ((char*)s)[sizeof(*s)+1] = '0'; /* Try to make valgrind angry to see where that damn socket comes from */
+      xbt_die(bprintf("I'm not the client in socket %p (comm:%p, rdvser=%p, rdvcli=%p) to %s, that's %s",
+          socket,sockdata->comm_recv,sockdata->rdv_server,sockdata->rdv_client,
+          SIMIX_host_get_name(SIMIX_process_get_host(sockdata->server)),
+          SIMIX_host_get_name(SIMIX_process_get_host(sockdata->client))));
+    }
+    xbt_assert(sockdata->client_port==gras_os_myport());
     return SIMIX_host_get_name(SIMIX_process_get_host(sockdata->server));
+  }
 }
 static const char* gras_trp_sg_peer_proc(gras_socket_t s) {
   THROW_UNIMPLEMENTED;
@@ -169,10 +181,11 @@ void gras_trp_sg_socket_client(gras_trp_plugin_t self,
   }
 
   /* create simulation data of the socket */
-  data = xbt_new(s_gras_trp_sg_sock_data_t, 1);
+  data = xbt_new0(s_gras_trp_sg_sock_data_t, 1);
   data->client = SIMIX_process_self();
   data->server = pr->server;
   data->server_port = port;
+  data->client_port = gras_os_myport();
 
   /* initialize synchronization stuff on the socket */
   data->rdv_server = pr->rdv;
@@ -183,10 +196,10 @@ void gras_trp_sg_socket_client(gras_trp_plugin_t self,
   sock->data = data;
   sock->incoming = 1;
 
-  DEBUG5("%s (PID %d) connects in %s mode to %s:%d",
+  DEBUG8("%s (PID %d) connects in %s mode to %s:%d (rdv_ser:%p, rdv_cli:%p, comm:%p)",
          SIMIX_process_get_name(SIMIX_process_self()), gras_os_getpid(),
-         sock->meas ? "meas" : "regular", host,
-         port);
+         sock->meas ? "meas" : "regular", host, port,
+         data->rdv_server,data->rdv_client,data->comm_recv);
 }
 
 void gras_trp_sg_socket_server(gras_trp_plugin_t self, int port, gras_socket_t sock)
@@ -218,7 +231,7 @@ void gras_trp_sg_socket_server(gras_trp_plugin_t self, int port, gras_socket_t s
   xbt_dynar_push(hd->ports, &pr);
 
   /* Create the socket */
-  data = xbt_new(s_gras_trp_sg_sock_data_t, 1);
+  data = xbt_new0(s_gras_trp_sg_sock_data_t, 1);
   data->server = SIMIX_process_self();
   data->server_port = port;
   data->client = NULL;
@@ -302,19 +315,21 @@ void gras_trp_sg_chunk_send_raw(gras_socket_t sock,
   gras_msg_procdata_t msg_remote_proc;
   gras_msg_t msg;               /* message to send */
 
-  gras_trp_sg_sock_data_t sock_data = (gras_trp_sg_sock_data_t) sock->data;
+  //gras_trp_sg_sock_data_t sock_data = (gras_trp_sg_sock_data_t) sock->data;
   xbt_assert0(sock->meas,
               "SG chunk exchange shouldn't be used on non-measurement sockets");
 
 
   /* creates simix action and waits its ends, waits in the sender host
      condition */
+  /*
   if (XBT_LOG_ISENABLED(gras_trp_sg, xbt_log_priority_debug)) {
     smx_process_t remote_dude =
         (sock_data->server ==
          SIMIX_process_self())? (sock_data->client) : (sock_data->server);
     smx_host_t remote_host = SIMIX_process_get_host(remote_dude);
   }
+  */
   //SIMIX_network_send(sock_data->rdv,size,1,-1,NULL,0,NULL,NULL);
 #endif
   THROW_UNIMPLEMENTED;