Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
do not use malloc directly since AIX does not like it. Use the gras stuff instead
[simgrid.git] / src / gras / Virtu / sg_process.c
index fad11a9..869111f 100644 (file)
 
 #include "Virtu/virtu_sg.h"
 
-GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(process,GRAS);
+GRAS_LOG_EXTERNAL_CATEGORY(process);
 
 gras_error_t
 gras_process_init() {
   gras_error_t errcode;
   gras_hostdata_t *hd=(gras_hostdata_t *)MSG_host_get_data(MSG_host_self());
   gras_procdata_t *pd;
+  gras_sg_portrec_t prraw,pr;
   int i;
   
   if (!(pd=(gras_procdata_t *)malloc(sizeof(gras_procdata_t)))) 
@@ -48,9 +49,14 @@ gras_process_init() {
            MSG_host_get_name(MSG_host_self()),GRAS_MAX_CHANNEL);
 
   pd->chan = i;
-  pd->sock = NULL;
   hd->proc[ i ] = MSG_process_self_PID();
 
+  /* regiter it to the ports structure */
+  pr.port = -1;
+  pr.tochan = i;
+  pr.raw = 0;
+  TRY(gras_dynar_push(hd->ports,&pr));
+
   /* take a free RAW channel for this process */
   for (i=0; i<GRAS_MAX_CHANNEL && hd->proc[i]; i++);
   if (i == GRAS_MAX_CHANNEL) {
@@ -59,9 +65,15 @@ gras_process_init() {
            MSG_host_get_name(MSG_host_self()),GRAS_MAX_CHANNEL);
   }
   pd->rawChan = i;
-  pd->rawSock = NULL;
+
   hd->proc[ i ] = MSG_process_self_PID();
 
+  /* regiter it to the ports structure */
+  prraw.port = -1;
+  prraw.tochan = i;
+  prraw.raw = 1;
+  TRY(gras_dynar_push(hd->ports,&prraw));
+
   VERB2("Creating process '%s' (%d)",
           MSG_process_get_name(MSG_process_self()),
           MSG_process_self_PID());
@@ -76,7 +88,7 @@ gras_process_exit() {
   int cpt;
   gras_sg_portrec_t pr;
 
-  gras_assert0(hd && pd,"Run gras_process_init!!\n");
+  gras_assert0(hd && pd,"Run gras_process_init!!");
 
   INFO2("GRAS: Finalizing process '%s' (%d)",
        MSG_process_get_name(MSG_process_self()),MSG_process_self_PID());