git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@1836
48e7efb5-ca39-0410-a469-
dd3cf9ba447f
if (!hd) {
/* First process on this host */
hd=xbt_new(gras_hostdata_t,1);
if (!hd) {
/* First process on this host */
hd=xbt_new(gras_hostdata_t,1);
hd->ports = xbt_dynar_new(sizeof(gras_sg_portrec_t),NULL);
memset(hd->proc, 0, sizeof(hd->proc[0]) * XBT_MAX_CHANNEL);
if (MSG_host_set_data(MSG_host_self(),(void*)hd) != MSG_OK)
THROW0(system_error,0,"Error in MSG_host_set_data()");
hd->ports = xbt_dynar_new(sizeof(gras_sg_portrec_t),NULL);
memset(hd->proc, 0, sizeof(hd->proc[0]) * XBT_MAX_CHANNEL);
if (MSG_host_set_data(MSG_host_self(),(void*)hd) != MSG_OK)
THROW0(system_error,0,"Error in MSG_host_set_data()");
+ } else {
+ hd->refcount++;
}
/* take a free channel for this process */
}
/* take a free channel for this process */
void
gras_process_exit() {
gras_hostdata_t *hd=(gras_hostdata_t *)MSG_host_get_data(MSG_host_self());
void
gras_process_exit() {
gras_hostdata_t *hd=(gras_hostdata_t *)MSG_host_get_data(MSG_host_self());
+ gras_procdata_t *pd=(gras_procdata_t*)MSG_process_get_data(MSG_process_self());
+
gras_msg_procdata_t msg_pd=(gras_msg_procdata_t)gras_libdata_by_name("gras_msg");
gras_trp_procdata_t trp_pd=(gras_trp_procdata_t)gras_libdata_by_name("gras_trp");
int myPID=MSG_process_self_PID();
gras_msg_procdata_t msg_pd=(gras_msg_procdata_t)gras_libdata_by_name("gras_msg");
gras_trp_procdata_t trp_pd=(gras_trp_procdata_t)gras_libdata_by_name("gras_trp");
int myPID=MSG_process_self_PID();
xbt_dynar_cursor_rm(hd->ports, &cpt);
}
}
xbt_dynar_cursor_rm(hd->ports, &cpt);
}
}
+
+ if ( ! --(hd->refcount)) {
+ xbt_dynar_free(&hd->ports);
+ free(hd);
+ }
+ gras_procdata_exit();
+ free(pd);
}
/* **************************************************************************
}
/* **************************************************************************
/* Data for each host */
typedef struct {
/* Data for each host */
typedef struct {
int proc[XBT_MAX_CHANNEL]; /* PID of who's connected to each channel */
/* If =0, then free */
int proc[XBT_MAX_CHANNEL]; /* PID of who's connected to each channel */
/* If =0, then free */