Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
garde-fou
[simgrid.git] / src / amok / HostManagement / hostmanagement.c
index c8947bc..f417e8a 100644 (file)
@@ -16,7 +16,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(amok_hm,amok,"Host management");
 
 
 /* libdata management */
 
 
 /* libdata management */
-static int amok_hm_libdata_id;
+static int amok_hm_libdata_id=-1;
 typedef struct {
   /* set headers */
   unsigned int ID;
 typedef struct {
   /* set headers */
   unsigned int ID;
@@ -77,9 +77,10 @@ static int amok_hm_cb_join(gras_msg_cb_ctx_t ctx, void *payload) {
   xbt_host_t dude = xbt_host_new(gras_socket_peer_name(exp),
                                 gras_socket_peer_port(exp));
 
   xbt_host_t dude = xbt_host_new(gras_socket_peer_name(exp),
                                 gras_socket_peer_port(exp));
 
+  VERB2("Contacted by %s:%d",dude->name,dude->port);
   xbt_dynar_push(group,&dude);
 
   xbt_dynar_push(group,&dude);
 
-  gras_msg_rpcreturn(30, ctx, NULL);
+  gras_msg_rpcreturn(10, ctx, NULL);
   free(name);
   return 1;
 }
   free(name);
   return 1;
 }
@@ -226,10 +227,13 @@ void amok_hm_kill_sync(gras_socket_t buddy) {
  * The dynar elements are of type xbt_host_t
  */
 xbt_dynar_t amok_hm_group_new(const char *group_name) {
  * The dynar elements are of type xbt_host_t
  */
 xbt_dynar_t amok_hm_group_new(const char *group_name) {
-  amok_hm_libdata_t g=gras_libdata_by_id(amok_hm_libdata_id);
+  amok_hm_libdata_t g;
   xbt_dynar_t res = xbt_dynar_new(sizeof(xbt_host_t),
                                  xbt_host_free_voidp);
 
   xbt_dynar_t res = xbt_dynar_new(sizeof(xbt_host_t),
                                  xbt_host_free_voidp);
 
+  xbt_assert0(amok_hm_libdata_id != -1,"Run amok_hm_init first!");
+  g=gras_libdata_by_id(amok_hm_libdata_id);
+   
   xbt_dict_set(g->groups,group_name,res,NULL); /*FIXME: leaking xbt_dynar_free_voidp);*/
   VERB1("Group %s created",group_name);
 
   xbt_dict_set(g->groups,group_name,res,NULL); /*FIXME: leaking xbt_dynar_free_voidp);*/
   VERB1("Group %s created",group_name);
 
@@ -246,6 +250,8 @@ xbt_dynar_t amok_hm_group_get(gras_socket_t master, const char *group_name) {
 
 /** \brief add current host to the given remote group */
 void        amok_hm_group_join(gras_socket_t master, const char *group_name) {
 
 /** \brief add current host to the given remote group */
 void        amok_hm_group_join(gras_socket_t master, const char *group_name) {
+  VERB3("Join group '%s' on %s:%d",
+       group_name,gras_socket_peer_name(master),gras_socket_peer_port(master));
   gras_msg_rpccall(master,30,gras_msgtype_by_name("amok_hm_join"),
                   &group_name,NULL);
   VERB3("Joined group '%s' on %s:%d",
   gras_msg_rpccall(master,30,gras_msgtype_by_name("amok_hm_join"),
                   &group_name,NULL);
   VERB3("Joined group '%s' on %s:%d",
@@ -274,6 +280,7 @@ void amok_hm_group_shutdown(const char *group_name) {
     amok_hm_kill_hp(host_it->name, host_it->port);
   }
 
     amok_hm_kill_hp(host_it->name, host_it->port);
   }
 
+  xbt_dynar_free(&group);
   xbt_dict_remove(g->groups,group_name);
 }
 /** \brief stops all members of the given remote group */
   xbt_dict_remove(g->groups,group_name);
 }
 /** \brief stops all members of the given remote group */