Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
just a little mistake on this example
[simgrid.git] / examples / gras / mutual_exclusion / simple_token / simple_token.c
index 06b0762..7931730 100644 (file)
@@ -72,8 +72,7 @@ static int node_cb_stoken_handler(gras_msg_cb_ctx_t ctx, void *payload) {
      
     /* 5. Send the token as payload of a stoken message to the successor */
     TRY {
-      gras_msg_send(globals->tosuccessor, 
-                   gras_msgtype_by_name("stoken"), &msg);
+      gras_msg_send(globals->tosuccessor, "stoken", &msg);
      
     /* 6. Deal with errors */
     } CATCH(e) {
@@ -96,7 +95,7 @@ static int node_cb_stoken_handler(gras_msg_cb_ctx_t ctx, void *payload) {
   }
 
   /* 9. Tell GRAS that we consummed this message */
-  return 1;
+  return 0;
 } /* end_of_node_cb_stoken_handler */
 
 int node (int argc,char *argv[]) {
@@ -146,11 +145,11 @@ int node (int argc,char *argv[]) {
   gras_msgtype_declare("stoken", gras_datadesc_by_name("int"));
    
   /* 7. Register my callback */
-  gras_cb_register(gras_msgtype_by_name("stoken"),&node_cb_stoken_handler);  
+  gras_cb_register("stoken",&node_cb_stoken_handler);  
 
   /* 8. One node has to create the token at startup. 
         It's specified by a command line argument */
-  if (argc >= 5 && !strncmp("--create-token", argv[4],strlen(argv[4])))
+  if (argc >= 5 && !strncmp("--create-token", argv[4],strlen("--create-token")))
     globals->create=1;
 
   if (globals->create) {
@@ -162,8 +161,7 @@ int node (int argc,char *argv[]) {
          token, host, peerport);
 
     TRY {        
-      gras_msg_send(globals->tosuccessor,
-                 gras_msgtype_by_name("stoken"), &token);
+      gras_msg_send(globals->tosuccessor, "stoken", &token);
     } CATCH(e) {
       RETHROW0("Unable to send the freshly created token: %s");
     }