Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
adapt to lastest changes in GRAS API
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 7 Mar 2007 15:38:12 +0000 (15:38 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 7 Mar 2007 15:38:12 +0000 (15:38 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@3206 48e7efb5-ca39-0410-a469-dd3cf9ba447f

30 files changed:
doc/gtut-files/02-simple.c
doc/gtut-files/03-args.c
doc/gtut-files/04-callback.c
doc/gtut-files/05-globals.c
doc/gtut-files/06-logs.c
doc/gtut-files/07-timers.c
doc/gtut-files/08-exceptions.c
doc/gtut-files/09-simpledata.c
doc/gtut-files/10-rpc.c
doc/gtut-files/11-explicitwait.c
doc/gtut-tour-02-simple.doc
doc/gtut-tour-04-callback.doc
doc/gtut-tour-13-pointers.doc
doc/gtut-tour-recap-messages.doc
examples/amok/saturate/saturate.c
examples/gras/all2all/all2all.c
examples/gras/mmrpc/mmrpc_client.c
examples/gras/mmrpc/mmrpc_common.c
examples/gras/mmrpc/mmrpc_server.c
examples/gras/mutual_exclusion/simple_token/simple_token.c
examples/gras/p2p/can/can.c
examples/gras/p2p/can/can_tests.c
examples/gras/p2p/chord/chord.c
examples/gras/ping/ping_client.c
examples/gras/ping/ping_server.c
examples/gras/pmm/pmm.c
examples/gras/rpc/rpc.c
src/amok/Bandwidth/bandwidth.c
src/amok/Bandwidth/saturate.c
src/amok/PeerManagement/peermanagement.c

index 07ff8d5..e9d4401 100644 (file)
@@ -9,7 +9,7 @@ int server(int argc, char *argv[]) {
   gras_msgtype_declare("hello", NULL);
   mysock = gras_socket_server(12345);
 
-  gras_msg_wait(60, gras_msgtype_by_name("hello"), &toclient, NULL /* no payload */);
+  gras_msg_wait(60, "hello", &toclient, NULL /* no payload */);
   
   fprintf(stderr,"Cool, we received the message from %s:%d.\n",
          gras_socket_peer_name(toclient), gras_socket_peer_port(toclient));
@@ -31,7 +31,7 @@ int client(int argc, char *argv[]) {
   gras_os_sleep(1.5); /* sleep 1 second and half */
   toserver = gras_socket_client("Jacquelin", 12345);
   
-  gras_msg_send(toserver,gras_msgtype_by_name("hello"), NULL);
+  gras_msg_send(toserver,"hello", NULL);
   fprintf(stderr,"That's it, we sent the data to the server\n");
 
   gras_exit();
index e4875ac..43817ad 100644 (file)
@@ -9,7 +9,7 @@ int server(int argc, char *argv[]) {
   gras_msgtype_declare("hello", NULL);
   mysock = gras_socket_server(atoi(argv[1]));
 
-  gras_msg_wait(60, gras_msgtype_by_name("hello"), &toclient, NULL /* no payload */);
+  gras_msg_wait(60, "hello", &toclient, NULL /* no payload */);
   
   fprintf(stderr,"Cool, we received the message from %s:%d.\n",
          gras_socket_peer_name(toclient), gras_socket_peer_port(toclient));
@@ -31,7 +31,7 @@ int client(int argc, char *argv[]) {
   gras_os_sleep(1.5); /* sleep 1 second and half */
   toserver = gras_socket_client(argv[1], atoi(argv[2]));
   
-  gras_msg_send(toserver,gras_msgtype_by_name("hello"), NULL);
+  gras_msg_send(toserver,"hello", NULL);
   fprintf(stderr,"That's it, we sent the data to the server on %s\n", gras_socket_peer_name(toserver));
 
   gras_exit();
index 1749ef2..193efb7 100644 (file)
@@ -6,7 +6,7 @@ int server_hello_cb(gras_msg_cb_ctx_t ctx, void *payload) {
   fprintf(stderr,"Cool, we received the message from %s:%d.\n",
          gras_socket_peer_name(client), gras_socket_peer_port(client));
   
-  return 1;
+  return 0;
 } /* end_of_callback */
 
 int server(int argc, char *argv[]) {
@@ -17,7 +17,7 @@ int server(int argc, char *argv[]) {
   gras_msgtype_declare("hello", NULL);
   mysock = gras_socket_server(atoi(argv[1]));
    
-  gras_cb_register(gras_msgtype_by_name("hello"),&server_hello_cb);   
+  gras_cb_register("hello",&server_hello_cb);   
   gras_msg_handle(60);
     
   gras_exit();
@@ -38,7 +38,7 @@ int client(int argc, char *argv[]) {
   gras_os_sleep(1.5); /* sleep 1 second and half */
   toserver = gras_socket_client(argv[1], atoi(argv[2]));
   
-  gras_msg_send(toserver,gras_msgtype_by_name("hello"), NULL);
+  gras_msg_send(toserver,"hello", NULL);
   fprintf(stderr,"That's it, we sent the data to the server on %s\n", gras_socket_peer_name(toserver));
 
   gras_exit();
index 9ca9c17..6b9d974 100644 (file)
@@ -14,7 +14,7 @@ int server_kill_cb(gras_msg_cb_ctx_t ctx, void *payload) {
   
   globals->killed = 1;
    
-  return 1;
+  return 0;
 } /* end_of_kill_callback */
 
 int server_hello_cb(gras_msg_cb_ctx_t ctx, void *payload) {
@@ -23,7 +23,7 @@ int server_hello_cb(gras_msg_cb_ctx_t ctx, void *payload) {
   fprintf(stderr,"Cool, we received the message from %s:%d.\n",
          gras_socket_peer_name(client), gras_socket_peer_port(client));
   
-  return 1;
+  return 0;
 } /* end_of_hello_callback */
 
 int server(int argc, char *argv[]) {
@@ -39,8 +39,8 @@ int server(int argc, char *argv[]) {
   gras_msgtype_declare("kill", NULL);
   mysock = gras_socket_server(atoi(argv[1]));
    
-  gras_cb_register(gras_msgtype_by_name("hello"),&server_hello_cb);   
-  gras_cb_register(gras_msgtype_by_name("kill"),&server_kill_cb);
+  gras_cb_register("hello",&server_hello_cb);   
+  gras_cb_register("kill",&server_kill_cb);
 
   while (!globals->killed) {
      gras_msg_handle(-1); /* blocking */
@@ -65,13 +65,13 @@ int client(int argc, char *argv[]) {
   gras_os_sleep(1.5); /* sleep 1 second and half */
   toserver = gras_socket_client(argv[1], atoi(argv[2]));
   
-  gras_msg_send(toserver,gras_msgtype_by_name("hello"), NULL);
+  gras_msg_send(toserver,"hello", NULL);
   fprintf(stderr,"we sent the data to the server on %s. Let's do it again for fun\n", gras_socket_peer_name(toserver));
-  gras_msg_send(toserver,gras_msgtype_by_name("hello"), NULL);
+  gras_msg_send(toserver,"hello", NULL);
    
   fprintf(stderr,"Ok. Enough. Have a rest, and then kill the server\n");
   gras_os_sleep(5); /* sleep 1 second and half */
-  gras_msg_send(toserver,gras_msgtype_by_name("kill"), NULL);
+  gras_msg_send(toserver,"kill", NULL);
 
   gras_exit();
   return 0;
index 1fff408..bcacfd6 100644 (file)
@@ -16,7 +16,7 @@ int server_kill_cb(gras_msg_cb_ctx_t ctx, void *payload) {
   
   globals->killed = 1;
    
-  return 1;
+  return 0;
 } /* end_of_kill_callback */
 
 int server_hello_cb(gras_msg_cb_ctx_t ctx, void *payload) {
@@ -25,7 +25,7 @@ int server_hello_cb(gras_msg_cb_ctx_t ctx, void *payload) {
   INFO2("Cool, we received the message from %s:%d.",
        gras_socket_peer_name(client), gras_socket_peer_port(client));
   
-  return 1;
+  return 0;
 } /* end_of_hello_callback */
 
 int server(int argc, char *argv[]) {
@@ -41,8 +41,8 @@ int server(int argc, char *argv[]) {
   gras_msgtype_declare("kill", NULL);
   mysock = gras_socket_server(atoi(argv[1]));
    
-  gras_cb_register(gras_msgtype_by_name("hello"),&server_hello_cb);   
-  gras_cb_register(gras_msgtype_by_name("kill"),&server_kill_cb);
+  gras_cb_register("hello",&server_hello_cb);   
+  gras_cb_register("kill",&server_kill_cb);
 
   while (!globals->killed) {
      gras_msg_handle(-1); /* blocking */
@@ -67,13 +67,13 @@ int client(int argc, char *argv[]) {
   gras_os_sleep(1.5); /* sleep 1 second and half */
   toserver = gras_socket_client(argv[1], atoi(argv[2]));
   
-  gras_msg_send(toserver,gras_msgtype_by_name("hello"), NULL);
+  gras_msg_send(toserver,"hello", NULL);
   INFO1("we sent the data to the server on %s. Let's do it again for fun", gras_socket_peer_name(toserver));
-  gras_msg_send(toserver,gras_msgtype_by_name("hello"), NULL);
+  gras_msg_send(toserver,"hello", NULL);
    
   INFO0("Ok. Enough. Have a rest, and then kill the server");
   gras_os_sleep(5); /* sleep 1 second and half */
-  gras_msg_send(toserver,gras_msgtype_by_name("kill"), NULL);
+  gras_msg_send(toserver,"kill", NULL);
 
   gras_exit();
   return 0;
index 6622034..2258db4 100644 (file)
@@ -16,7 +16,7 @@ int server_kill_cb(gras_msg_cb_ctx_t ctx, void *payload) {
   
   globals->killed = 1;
    
-  return 1;
+  return 0;
 } /* end_of_kill_callback */
 
 int server_hello_cb(gras_msg_cb_ctx_t ctx, void *payload) {
@@ -25,7 +25,7 @@ int server_hello_cb(gras_msg_cb_ctx_t ctx, void *payload) {
   INFO2("Cool, we received the message from %s:%d.",
        gras_socket_peer_name(client), gras_socket_peer_port(client));
   
-  return 1;
+  return 0;
 } /* end_of_hello_callback */
 
 int server(int argc, char *argv[]) {
@@ -41,8 +41,8 @@ int server(int argc, char *argv[]) {
   gras_msgtype_declare("kill", NULL);
   mysock = gras_socket_server(atoi(argv[1]));
    
-  gras_cb_register(gras_msgtype_by_name("hello"),&server_hello_cb);   
-  gras_cb_register(gras_msgtype_by_name("kill"),&server_kill_cb);
+  gras_cb_register("hello",&server_hello_cb);   
+  gras_cb_register("kill",&server_kill_cb);
 
   while (!globals->killed) {
      gras_msg_handle(60);
@@ -63,14 +63,14 @@ typedef struct {
 void client_do_hello(void) {
   client_data_t *globals=(client_data_t*)gras_userdata_get();
    
-  gras_msg_send(globals->toserver,gras_msgtype_by_name("hello"), NULL);
+  gras_msg_send(globals->toserver,"hello", NULL);
   INFO0("Hello sent to server");
 } /* end_of_client_do_hello */
 
 void client_do_stop(void) {
   client_data_t *globals=(client_data_t*)gras_userdata_get();
    
-  gras_msg_send(globals->toserver,gras_msgtype_by_name("kill"), NULL);
+  gras_msg_send(globals->toserver,"kill", NULL);
   INFO0("Kill sent to server");
    
   gras_timer_cancel_repeat(0.5,client_do_hello);
index fd3a407..e4d3ed8 100644 (file)
@@ -16,7 +16,7 @@ int server_kill_cb(gras_msg_cb_ctx_t ctx, void *payload) {
   
   globals->killed = 1;
    
-  return 1;
+  return 0;
 } /* end_of_kill_callback */
 
 int server(int argc, char *argv[]) {
@@ -29,7 +29,7 @@ int server(int argc, char *argv[]) {
   globals->killed=0;
 
   gras_msgtype_declare("kill", NULL);
-  gras_cb_register(gras_msgtype_by_name("kill"),&server_kill_cb);
+  gras_cb_register("kill",&server_kill_cb);
    
   if (argc>1 && !strcmp(argv[1],"--cheat")) {
      mysock = gras_socket_server(9999);
@@ -65,7 +65,7 @@ int client(int argc, char *argv[]) {
   for (port=3000, found=0; port<3010 && !found; port++) {
      TRY {
        toserver = gras_socket_client(argv[1], port);
-       gras_msg_send(toserver,gras_msgtype_by_name("kill"), NULL);
+       gras_msg_send(toserver,"kill", NULL);
        gras_socket_close(toserver);
        found = 1;
        INFO1("Yeah! I found the server on %d! It's eradicated by now.",port);
index c8144f3..351da0d 100644 (file)
@@ -20,7 +20,7 @@ int server_kill_cb(gras_msg_cb_ctx_t ctx, void *payload) {
    
   globals->killed = 1;
    
-  return 1;
+  return 0;
 } /* end_of_kill_callback */
 
 int server_hello_cb(gras_msg_cb_ctx_t ctx, void *payload) {
@@ -31,7 +31,7 @@ int server_hello_cb(gras_msg_cb_ctx_t ctx, void *payload) {
        gras_socket_peer_name(client), gras_socket_peer_port(client),
        msg);
   
-  return 1;
+  return 0;
 } /* end_of_hello_callback */
 
 void message_declaration(void) {
@@ -52,8 +52,8 @@ int server(int argc, char *argv[]) {
   message_declaration();
   mysock = gras_socket_server(atoi(argv[1]));
    
-  gras_cb_register(gras_msgtype_by_name("hello"),&server_hello_cb);   
-  gras_cb_register(gras_msgtype_by_name("kill"),&server_kill_cb);
+  gras_cb_register("hello",&server_hello_cb);   
+  gras_cb_register("kill",&server_kill_cb);
 
   while (!globals->killed) {
      gras_msg_handle(-1); /* blocking */
@@ -78,11 +78,11 @@ int client(int argc, char *argv[]) {
   toserver = gras_socket_client(argv[1], atoi(argv[2]));
   
   char *hello_payload="Nice to meet you";
-  gras_msg_send(toserver,gras_msgtype_by_name("hello"), &hello_payload);
+  gras_msg_send(toserver,"hello", &hello_payload);
   INFO1("we sent the hello to the server on %s.", gras_socket_peer_name(toserver));
    
   double kill_payload=0.5;
-  gras_msg_send(toserver,gras_msgtype_by_name("kill"), &kill_payload);
+  gras_msg_send(toserver,"kill", &kill_payload);
   INFO0("Gave the server more 0.5 second to live");
    
   gras_exit();
index 3c95494..64e7218 100644 (file)
@@ -11,7 +11,7 @@ int server_done_cb(gras_msg_cb_ctx_t ctx, void *payload) {
   globals->done = 1;
   INFO0("Server done");
    
-  return 1;
+  return 0;
 } /* end_of_done_callback */
 
 void message_declaration(void) {
@@ -33,7 +33,7 @@ int server_convert_i2a_cb(gras_msg_cb_ctx_t ctx, void *payload) {
    
   gras_msg_rpcreturn(60,ctx,&result);
   free(result);
-  return 1;
+  return 0;
 } /* end_of_convert_callback */
 
 int server_convert_a2i_cb(gras_msg_cb_ctx_t ctx, void *payload) {
@@ -48,7 +48,7 @@ int server_convert_a2i_cb(gras_msg_cb_ctx_t ctx, void *payload) {
      THROW2(arg_error,0,"Error while converting %s: this does not seem to be a valid number (problem at '%s')",string,p);
              
   gras_msg_rpcreturn(60,ctx,&result);
-  return 1;
+  return 0;
 } /* end_of_convert_callback */
 
 
@@ -64,9 +64,9 @@ int server(int argc, char *argv[]) {
   message_declaration();
   mysock = gras_socket_server(atoi(argv[1]));
    
-  gras_cb_register(gras_msgtype_by_name("convert a2i"),&server_convert_a2i_cb);
-  gras_cb_register(gras_msgtype_by_name("convert i2a"),&server_convert_i2a_cb);
-  gras_cb_register(gras_msgtype_by_name("done"),&server_done_cb);
+  gras_cb_register("convert a2i",&server_convert_a2i_cb);
+  gras_cb_register("convert i2a",&server_convert_i2a_cb);
+  gras_cb_register("done",&server_done_cb);
 
   while (!globals->done) {
      gras_msg_handle(-1); /* blocking */
@@ -93,27 +93,27 @@ int client(int argc, char *argv[]) {
   long long_to_convert=4321;
   char *string_result;
   INFO1("Ask to convert %ld", long_to_convert);
-  gras_msg_rpccall(toserver, 60, gras_msgtype_by_name("convert i2a"), &long_to_convert, &string_result);
+  gras_msg_rpccall(toserver, 60, "convert i2a", &long_to_convert, &string_result);
   INFO2("The server says that %ld is equal to \"%s\".", long_to_convert, string_result);
   free(string_result);
    
   char *string_to_convert="1234";
   long long_result;
   INFO1("Ask to convert %s", string_to_convert);
-  gras_msg_rpccall(toserver, 60, gras_msgtype_by_name("convert a2i"), &string_to_convert, &long_result);
+  gras_msg_rpccall(toserver, 60, "convert a2i", &string_to_convert, &long_result);
   INFO2("The server says that \"%s\" is equal to %d.", string_to_convert, long_result);
    
   xbt_ex_t e;
   string_to_convert = "azerty";
   TRY {
-     gras_msg_rpccall(toserver, 60, gras_msgtype_by_name("convert a2i"), &string_to_convert, &long_result);
+     gras_msg_rpccall(toserver, 60, "convert a2i", &string_to_convert, &long_result);
   } CATCH(e) {
      INFO1("The server refuses to convert %s. Here is the received exception:",string_to_convert);
      xbt_ex_display(&e);
      INFO0("Again, previous exception was excepted");
   }            
    
-  gras_msg_send(toserver,gras_msgtype_by_name("done"), NULL);
+  gras_msg_send(toserver,"done", NULL);
   INFO0("Stopped the server");
    
   gras_exit();
index 70478d8..dc22745 100644 (file)
@@ -24,9 +24,9 @@ int server_request_cb(gras_msg_cb_ctx_t ctx, void *payload) {
   } else {     
      globals->process_in_CS = 1;
      INFO2("grant %s:%d since nobody wanted it",gras_socket_peer_name(s),gras_socket_peer_port(s));
-     gras_msg_send(s, gras_msgtype_by_name("grant"), NULL);     
+     gras_msg_send(s, "grant", NULL);     
   }
-  return 1;
+  return 0;
 } /* end_of_request_callback */
 
 int server_release_cb(gras_msg_cb_ctx_t ctx, void *payload) {
@@ -37,12 +37,12 @@ int server_release_cb(gras_msg_cb_ctx_t ctx, void *payload) {
      xbt_dynar_pop(globals->waiting_queue, &s);
      
      INFO2("grant %s:%d since token released",gras_socket_peer_name(s),gras_socket_peer_port(s));
-     gras_msg_send(s, gras_msgtype_by_name("grant"), NULL);
+     gras_msg_send(s, "grant", NULL);
   } else {
      globals->process_in_CS = 0;
   }
    
-  return 1;
+  return 0;
 } /* end_of_release_callback */
 
 int server(int argc, char *argv[]) { 
@@ -58,8 +58,8 @@ int server(int argc, char *argv[]) {
   globals->waiting_queue=xbt_dynar_new( sizeof(gras_socket_t), NULL /* not closing sockets */);
 
   message_declaration();   
-  gras_cb_register(gras_msgtype_by_name("request"),&server_request_cb);
-  gras_cb_register(gras_msgtype_by_name("release"),&server_release_cb);
+  gras_cb_register("request",&server_request_cb);
+  gras_cb_register("release",&server_release_cb);
 
   for (i=0; i<20; i++)  /* 5 requests of each process, 2 processes, 2 messages per request */
     gras_msg_handle(-1); 
@@ -69,14 +69,14 @@ int server(int argc, char *argv[]) {
 } /* end_of_server */
 
 void lock(gras_socket_t toserver) {
-   gras_msg_send(toserver,gras_msgtype_by_name("request"),NULL);
-   gras_msg_wait(-1, gras_msgtype_by_name("grant"),NULL,NULL);
+   gras_msg_send(toserver,"request",NULL);
+   gras_msg_wait(-1, "grant",NULL,NULL);
    INFO0("Granted by server");
 } /* end_of_lock */
 
 void unlock(gras_socket_t toserver) {
    INFO0("Release the token");
-   gras_msg_send(toserver,gras_msgtype_by_name("release"),NULL);
+   gras_msg_send(toserver,"release",NULL);
 } /* end_of_unlock */
 
 int client(int argc, char *argv[]) {
index 3dfba8f..778b669 100644 (file)
@@ -81,9 +81,8 @@ GRAS offers a plenty of ways to communicate. The simple one is to use \ref
 gras_msg_send on the sender side, and \ref gras_msg_wait on the receiver side.
 
 \ref gras_msg_send expects 3 arguments: the socket on which to send the
-message, the message type, and a pointer to the actual content of the
-message. The simplest way to retrive a message type from its name is to use
-\ref gras_msgtype_by_name. Since we don't have any payload, this becomes:
+message, the message type (described by its name), and a pointer to the actual content of the
+message. Since we don't have any payload, this becomes:
 
 \dontinclude 02-simple.c
 \skip msg_send
index a782ed3..b23d808 100644 (file)
@@ -23,11 +23,8 @@ First of all, we define the callback we want to attach to the arrival of the
 arguments of relative types <tt>gras_msg_cb_ctx_t ctx</tt> and <tt>void
 *</tt>. The first one is a working context we should pass to GRAS when
 speaking about the message we are handling while the second is the payload.
-The callbackreturns an integer indicating whether we managed to deal with
-the message. I admit that this semantic is a bit troublesome, it should be 0
-if we managed to deal properly with the message to mimic "main()" semantic.
-That's historical, but I may change this in the future (no worry, I'll add
-backward compatibility solutions). Here is the actual code of our callback:
+The callback returns an integer being its error code, just like the "main()"
+function. Here is the actual code of our callback:
 
 \dontinclude 04-callback.c
 \skip gras_msg_cb_ctx_t 
@@ -76,9 +73,9 @@ most of the mecanism most program will use.
 
 There is one last thing you should know about callbacks: you can stack them,
 ie attach several callbacks to the same message. GRAS will pass it to the
-lastly attached first, and if the return value is 0, it will pass it also to
-the next one, and so on. I'm not sure there is any sensible use of this
-feature, but it's possible ;)
+lastly attached first, and if the returned error code is not 0, it will pass
+it also to the next one, and so on. I'm not sure there is any sensible use
+of this feature, but it's possible ;)
 
 Go to \ref GRAS_tut_tour_globals
 */
index f75d574..4e03372 100644 (file)
@@ -34,6 +34,30 @@ void declare_ddt() {
 
 */
 
+    and the this example do use structures as payload, 
+    so we have to declare it to GRAS. Hopefully, this can be done easily by enclosing 
+    the structure declaration within a \ref GRAS_DEFINE_TYPE macro call. It will then copy this 
+    declaration into an hidden string variable, which can be automatically parsed at 
+    run time. Of course, the declaration is also copied unmodified by this macro, so that it
+    gets parsed by the compiler also. 
+
+    There is some semantic that GRAS cannot guess alone and you need to  <i>annotate</i>
+    your declaration to add some. For example, the ctn pointer can be a reference to an 
+    object or a whole array (in which case you also has to specify its size). This is done 
+    with the GRAS_ANNOTE call. It is removed from the text passed to the compiler, but it helps
+    GRAS getting some information about the semantic of your data. Here, it says that \a ctn is an 
+    array, which size is the result of the operation \a rows * \a cols (with \a rows and \a cols 
+    being the other fields of the structure). 
+
+    Please note that this annotation mechanism is not as robust and cool as this example seems to 
+    imply. If you want to use it yourself, you'd better use the exact right syntax, which is 
+    detailed in the \ref GRAS_dd section.
+
+    \skip GRAS_DEFINE_TYPE
+    \until matrix_t
+
+
+
 #define COLS 16
 #define MAX_ROUTESET 10
 #define MAX_LEAFSET COLS
index e080308..71269d9 100644 (file)
@@ -136,7 +136,7 @@ After it returned the result this way, you should free any data you
 mallocated in your callback (including the data you returned to the caller:
 GRAS made a copy of it during the call to gras_msg_rpcreturn()).
 
-The callback is expected to return 1 if ok, as detailed in 
+The callback is expected to return 0 if ok, as detailed in 
 \ref GRAS_tut_tour_message_recaping_rpc_aside1.
 
 \subsection GRAS_tut_tour_message_recaping_rpc4 4. Attaching callbacks to the messages
@@ -158,19 +158,18 @@ wait for the answer of your RPC (using gras_msg_rpc_async_wait()).
 
 \subsection GRAS_tut_tour_message_recaping_rpc_aside1 Aside: stacking callbacks
 
-The callback is expected to return 1 if it consumed the message properly.
-This semantic may be troublesome since it really differs from the one used
-in the main() function, but this allows to build callback stacks. It is
-perfectly valid to register several callbacks to a given message. When a
-message arrives, it is passed to the firstly-registered callback. If the
-callback returns 1 (or any other "true" value), it means that it consumed
-the message, which is discarded. If the callback returns 0, the message is
-passed to the next callback of the stack, and so on. At the end, if no
-callback returned 1, an error message is generated.
+The callback is expected to return 0 if everything went well, which is the
+same semantic than the "main()" function. You can also build stacks of
+callbacks. It is perfectly valid to register several callbacks to a given
+message. When a message arrives, it is passed to the firstly-registered
+callback. If the callback returns 0, it means that it consumed the message,
+which is discarded. If the callback returns 1 (or any other "true" value),
+the message is passed to the next callback of the stack, and so on. At the
+end, if no callback returned 0, an exception is raised.
 
 This mecanism can for example be used to introduce dupplication and replay.
 You add a callback simply in charge of storing the message in a database,
-and since it returns 0, the message is then passed to the "real" callback.
+and since it returns 1, the message is then passed to the "real" callback.
 To be perfectly honest, I never had use of this functionnality myself, but I
 feel it could be useful in some cases...
 
index 355c2ab..3249aef 100644 (file)
@@ -96,7 +96,7 @@ static double XP(const char *bw1, const char *bw2,
 
 static void kill_buddy(char *name,int port){
   gras_socket_t sock=gras_socket_client(name,port);
-  gras_msg_send(sock,gras_msgtype_by_name("kill"),NULL);
+  gras_msg_send(sock,"kill",NULL);
   gras_socket_close(sock);
 }
 static void kill_buddy_dynar(void *b) {
index 5c029da..f2f2ba1 100644 (file)
@@ -53,7 +53,7 @@ int receiver (int argc,char *argv[]) {
        todo);
   while (todo>0) {
      gras_msg_wait(60 /* wait up to one minute */,
-                  gras_msgtype_by_name("data"),
+                  "data",
                   &expeditor,
                   &data);
      todo--;
@@ -116,7 +116,7 @@ int sender (int argc,char *argv[]) {
   xbt_dynar_foreach(peers,i,h) {
      
      peer = gras_socket_client(h->name,h->port);
-     gras_msg_send(peer,gras_msgtype_by_name("data"),&data);
+     gras_msg_send(peer,"data",&data);
      INFO2("  Sent Data from %s to %s",
           gras_os_myname(),h->name);
      gras_socket_close(peer);
index acffc9e..2ebb675 100644 (file)
@@ -65,7 +65,7 @@ int client(int argc,char *argv[]) {
   xbt_matrix_dump(request[1],"C:sent1",0,xbt_matrix_dump_display_double);
   */
 
-  gras_msg_send(toserver, gras_msgtype_by_name("request"), &request);
+  gras_msg_send(toserver, "request", &request);
 
   xbt_matrix_free(request[0]);
 
@@ -73,7 +73,7 @@ int client(int argc,char *argv[]) {
        gras_socket_peer_name(toserver),gras_socket_peer_port(toserver));
 
   /* 8. Wait for the answer from the server, and deal with issues */
-  gras_msg_wait(6000,gras_msgtype_by_name("answer"),&from,&answer);
+  gras_msg_wait(6000,"answer",&from,&answer);
 
   /*
   xbt_matrix_dump(answer,"C:answer",0,xbt_matrix_dump_display_double);
index 65719cc..41b3163 100644 (file)
@@ -19,8 +19,6 @@ void mmrpc_register_messages(void) {
   matrix_type=gras_datadesc_matrix(gras_datadesc_by_name("double"),
                                   NULL);
   request_type=gras_datadesc_array_fixed("s_matrix_t(double)[2]",matrix_type,2);
-  //                                    gras_datadesc_by_name("xbt_matrix_t(double)"),2);
-  //    request_type=gras_datadesc_ref("matrix_t(double)[2]",request_type);
   
   gras_msgtype_declare("answer", matrix_type);
   gras_msgtype_declare("request", request_type);
index ebdf498..eed3819 100644 (file)
@@ -28,7 +28,7 @@ static int server_cb_request_handler(gras_msg_cb_ctx_t ctx,
   result = xbt_matrix_double_new_mult(request[0], request[1]);
 
   /* 3. Send it back as payload of a pong message to the expeditor */
-  gras_msg_send(expeditor, gras_msgtype_by_name("answer"), &result);
+  gras_msg_send(expeditor, "answer", &result);
 
   /* 4. Cleanups */
   xbt_matrix_free(request[0]);
@@ -36,7 +36,7 @@ static int server_cb_request_handler(gras_msg_cb_ctx_t ctx,
   xbt_matrix_free(result);
   gras_socket_close(expeditor);
    
-  return 1;
+  return 0;
 } /* end_of_server_cb_request_handler */
 
 int server (int argc,char *argv[]) {
index 0ad688f..2460b60 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[]) {
@@ -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");
     }
index 270c3ee..1d37042 100644 (file)
@@ -66,7 +66,7 @@ static void forward_get_suc(get_suc_t msg, char host[1024], int port){
                RETHROW0("Unable to connect!: %s");
        }
        TRY{
-               gras_msg_send(temp_sock,gras_msgtype_by_name("can_get_suc"),&msg);
+               gras_msg_send(temp_sock,"can_get_suc",&msg);
        }CATCH(e){
                RETHROW0("Unable to send!: %s");
        }
@@ -185,7 +185,7 @@ static int node_get_suc_handler(gras_msg_cb_ctx_t ctx,void *payload_data){
                                RETHROW0("Unable to connect to the node wich has requested for an area!: %s");
                        }
                        TRY{
-                               gras_msg_send(temp_sock,gras_msgtype_by_name("can_rep_suc"),&outgoing);
+                               gras_msg_send(temp_sock,"can_rep_suc",&outgoing);
                                INFO0("Environment informations sent!");
                        }CATCH(e){
                                RETHROW2("%s:Timeout sending environment informations to %s: %s",globals->host,gras_socket_peer_name(expeditor));
@@ -203,7 +203,7 @@ static int node_get_suc_handler(gras_msg_cb_ctx_t ctx,void *payload_data){
        INFO4("My area is [%d;%d;%d;%d]",globals->x1,globals->x2,globals->y1,globals->y2);
          //INFO0("Closing node, all has been done!");
        }
-   return 1;
+   return 0;
 }
 
 
@@ -251,7 +251,7 @@ int node(int argc,char **argv){
                strcpy(get_suc_msg.host,globals->host);
                get_suc_msg.port=globals->port;
                TRY{ // asking.
-                       gras_msg_send(temp_sock,gras_msgtype_by_name("can_get_suc"),&get_suc_msg);
+                       gras_msg_send(temp_sock,"can_get_suc",&get_suc_msg);
                }CATCH(e){
                        gras_socket_close(temp_sock);
                        RETHROW0("Unable to contact known host to get an area!: %s");
@@ -262,7 +262,7 @@ int node(int argc,char **argv){
                gras_socket_t temp_sock2=NULL;
                TRY{ // waiting for a reply.
                        INFO0("Waiting for reply!");
-                       gras_msg_wait(6000,gras_msgtype_by_name("can_rep_suc"),&temp_sock2,&rep_suc_msg);
+                       gras_msg_wait(6000,"can_rep_suc",&temp_sock2,&rep_suc_msg);
                }CATCH(e){
                        RETHROW1("%s: Error waiting for an area:%s",globals->host);
                }
index cdb90b1..8fdbdef 100644 (file)
@@ -44,7 +44,7 @@ int start_war(int argc,char **argv){
   nuke_msg.port=atoi(argv[1]);
 
   TRY{
-    gras_msg_send(temp_sock,gras_msgtype_by_name("can_nuke"),&nuke_msg);
+    gras_msg_send(temp_sock,"can_nuke",&nuke_msg);
   }CATCH(e){
     gras_socket_close(temp_sock);
     RETHROW0("Unable to contact known host so as to declare WAR!!!!!!!!!!!!!!!!!!!!!: %s");
@@ -91,7 +91,7 @@ static int send_nuke(nuke_t *msg, int xId, int yId){
     }
     //INFO4("%s ON %s %d %d <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<",globals->host,host,xId,yId);
     TRY{
-      gras_msg_send(temp_sock,gras_msgtype_by_name("can_nuke"),msg);
+      gras_msg_send(temp_sock,"can_nuke",msg);
     }CATCH(e){
       RETHROW0("Unable to send the nuke!: %s");
     }
@@ -177,7 +177,7 @@ static int node_nuke_handler(gras_msg_cb_ctx_t ctx,void *payload_data){
       RETHROW0("Unable to connect the nuke!: %s");
     }
     TRY{
-      gras_msg_send(temp_sock,gras_msgtype_by_name("can_nuke"),incoming);
+      gras_msg_send(temp_sock,"can_nuke",incoming);
     }CATCH(e){
       RETHROW0("Unable to send the nuke!: %s");
     }
@@ -192,7 +192,7 @@ static int node_nuke_handler(gras_msg_cb_ctx_t ctx,void *payload_data){
     INFO4("My area is [%d;%d;%d;%d]",globals->x1,globals->x2,globals->y1,globals->y2);
     //INFO0("Closing node, all has been done!");
     }
-   return 1;
+   return 0;
 }
 
 // END
index 04b92a4..7d831ae 100644 (file)
@@ -144,24 +144,23 @@ static int node_cb_get_suc_handler(gras_msg_cb_ctx_t ctx,void *payload_data){
         RETHROW0("Unable to connect!: %s");
       }
       TRY{
-        gras_msg_send(temp_sock,gras_msgtype_by_name("chord_get_suc"),&asking);
+        gras_msg_send(temp_sock,"chord_get_suc",&asking);
       }CATCH(e){
         RETHROW0("Unable to ask!: %s");
       }
-      gras_msg_wait(10.,gras_msgtype_by_name("chord_rep_suc"),&temp_sock,
-                    &outgoing);
+      gras_msg_wait(10.,"chord_rep_suc",&temp_sock, &outgoing);
     }
   }
   
   TRY{
-    gras_msg_send(expeditor,gras_msgtype_by_name("chord_rep_suc"),&outgoing);
+    gras_msg_send(expeditor,"chord_rep_suc",&outgoing);
     INFO0("Successor information sent!");
   }CATCH(e){
     RETHROW2("%s:Timeout sending successor information to %s: %s",
              globals->host,gras_socket_peer_name(expeditor));
   }
   gras_socket_close(expeditor);
-  return(1);
+  return 0;
 }
 
 static int closest_preceding_node(int id){
@@ -190,7 +189,7 @@ static int node_cb_notify_handler(gras_msg_cb_ctx_t ctx,void *payload_data){
     globals->pre_port=incoming.port;
     INFO0("Set as my new predecessor!");
   }
-  return(1);
+  return 0;
 }
 
 static void fix_fingers(){
@@ -206,7 +205,7 @@ static void fix_fingers(){
   }
   get_suc_t get_suc_msg;get_suc_msg.id=globals->id;
   TRY{
-    gras_msg_send(temp_sock,gras_msgtype_by_name("chord_get_suc"),&get_suc_msg);
+    gras_msg_send(temp_sock,"chord_get_suc",&get_suc_msg);
   }CATCH(e){
     gras_socket_close(temp_sock);
     RETHROW0("Unable to contact known host to get successor!: %s");
@@ -214,8 +213,7 @@ static void fix_fingers(){
   rep_suc_t rep_suc_msg;
   TRY{
     INFO0("Waiting for reply!");
-    gras_msg_wait(6000,gras_msgtype_by_name("chord_rep_suc"),&temp_sock2,
-                  &rep_suc_msg);
+    gras_msg_wait(6000,"chord_rep_suc",&temp_sock2, &rep_suc_msg);
   }CATCH(e){
     RETHROW1("%s: Error waiting for successor:%s",globals->host);
   }
@@ -247,14 +245,14 @@ static void check_predecessor(){
   pong_t pong;
   ping.id = 0;
   TRY{
-    gras_msg_send( temp_sock, gras_msgtype_by_name("chord_ping"),&ping);
+    gras_msg_send( temp_sock, "chord_ping",&ping);
   }CATCH(e){
     globals->pre_id = -1;
     globals->pre_host[0] = 0;
     globals->pre_port = 0;
   }
   TRY{
-    gras_msg_wait( 60, gras_msgtype_by_name("chord_pong"), &temp_sock, &pong);
+    gras_msg_wait( 60, "chord_pong", &temp_sock, &pong);
   }CATCH(e){
     globals->pre_id = -1;
     globals->pre_host[0] = 0;
@@ -320,8 +318,7 @@ int node(int argc,char **argv){
     }
     get_suc_t get_suc_msg;get_suc_msg.id=globals->id;
     TRY{
-      gras_msg_send(temp_sock,gras_msgtype_by_name("chord_get_suc"),
-                    &get_suc_msg);
+      gras_msg_send(temp_sock,"chord_get_suc", &get_suc_msg);
     }CATCH(e){
       gras_socket_close(temp_sock);
       RETHROW0("Unable to contact known host to get successor!: %s");
@@ -329,8 +326,7 @@ int node(int argc,char **argv){
     rep_suc_t rep_suc_msg;
     TRY{
       INFO0("Waiting for reply!");
-      gras_msg_wait(10.,gras_msgtype_by_name("chord_rep_suc"),&temp_sock2,
-                    &rep_suc_msg);
+      gras_msg_wait(10.,"chord_rep_suc",&temp_sock2, &rep_suc_msg);
     }CATCH(e){
       RETHROW1("%s: Error waiting for successor:%s",globals->host);
     }
@@ -351,7 +347,7 @@ int node(int argc,char **argv){
     snprintf(notify_msg.host,1024,globals->host);
     notify_msg.port=globals->port;
     TRY{
-      gras_msg_send(temp_sock,gras_msgtype_by_name("chord_notify"),&notify_msg);
+      gras_msg_send(temp_sock,"chord_notify",&notify_msg);
     }CATCH(e){
       RETHROW0("Unable to notify successor! %s");
     }
@@ -359,7 +355,7 @@ int node(int argc,char **argv){
   
   gras_cb_register("chord_get_suc", &node_cb_get_suc_handler);
   gras_cb_register("chord_notify",  &node_cb_notify_handler);
-  /*gras_cb_register(gras_msgtype_by_name("chord_ping"),&node_cb_ping_handler);*/
+  /*gras_cb_register("chord_ping",&node_cb_ping_handler);*/
  /* gras_timer_repeat(600.,fix_fingers);*/
   /*while(1){*/
   int l;
index 2afae4b..d213bdb 100644 (file)
@@ -54,7 +54,7 @@ int client(int argc,char *argv[]) {
   /* 7. Prepare and send the ping message to the server */
   ping = 1234;
   TRY {
-    gras_msg_send(toserver, gras_msgtype_by_name("ping"), &ping);
+    gras_msg_send(toserver, "ping", &ping);
   } CATCH(e) {
     gras_socket_close(toserver);
     RETHROW0("Failed to send PING to server: %s");
@@ -65,8 +65,7 @@ int client(int argc,char *argv[]) {
 
   /* 8. Wait for the answer from the server, and deal with issues */
   TRY {
-    gras_msg_wait(6000,gras_msgtype_by_name("pong"),
-                 &from,&pong);
+    gras_msg_wait(6000,"pong", &from,&pong);
   } CATCH(e) {
     gras_socket_close(toserver);
     RETHROW0("Why can't I get my PONG message like everyone else: %s");
index e59dee2..29e853d 100644 (file)
@@ -39,7 +39,7 @@ static int server_cb_ping_handler(gras_msg_cb_ctx_t ctx, void *payload) {
   msg = 4321;
   /* 5. Send it back as payload of a pong message to the expeditor */
   TRY {
-    gras_msg_send(expeditor, gras_msgtype_by_name("pong"), &msg);
+    gras_msg_send(expeditor, "pong", &msg);
 
   /* 6. Deal with errors: add some details to the exception */
   } CATCH(e) {
@@ -56,7 +56,7 @@ static int server_cb_ping_handler(gras_msg_cb_ctx_t ctx, void *payload) {
   gras_socket_close(expeditor);
    
   /* 9. Tell GRAS that we consummed this message */
-  return 1;
+  return 0;
 } /* end_of_server_cb_ping_handler */
 
 int server (int argc,char *argv[]) {
index 6bdd14a..35253ab 100755 (executable)
@@ -172,7 +172,7 @@ int master (int argc,char *argv[]) {
       line++;
     }
                
-    gras_msg_send(socket[i],gras_msgtype_by_name("pmm_slave"),&assignment);
+    gras_msg_send(socket[i],"pmm_slave",&assignment);
     xbt_matrix_free(assignment.A);
     xbt_matrix_free(assignment.B);
   }
@@ -181,7 +181,7 @@ int master (int argc,char *argv[]) {
 
   /* Retrieve the results */
   for( i=0;i< SLAVE_COUNT;i++){
-    gras_msg_wait(6000,gras_msgtype_by_name("result"),&from,&result);
+    gras_msg_wait(6000,"result",&from,&result);
     VERB2("%d slaves are done already. Waiting for %d",i+1, SLAVE_COUNT);
     xbt_matrix_copy_values(C,result.C,   submatrix_size,submatrix_size,
                           submatrix_size*result.linepos,
@@ -275,9 +275,7 @@ static int pmm_worker_cb(gras_msg_cb_ctx_t ctx, void *payload) {
          INFO2("LINE:   Send to %s:%d",
                gras_socket_peer_name(socket_row[l]),
                gras_socket_peer_port(socket_row[l]));
-        gras_msg_send(socket_row[l], 
-                      gras_msgtype_by_name("dataB"), 
-                      &mydataB);
+        gras_msg_send(socket_row[l], "dataB", &mydataB);
        }
        
        
@@ -288,7 +286,7 @@ static int pmm_worker_cb(gras_msg_cb_ctx_t ctx, void *payload) {
     } else {
       TRY {
        xbt_matrix_free(bB);
-       gras_msg_wait(600,gras_msgtype_by_name("dataB"),&from,&bB);
+       gras_msg_wait(600,"dataB",&from,&bB);
       } CATCH(e) {
        RETHROW0("Can't get a data message from line : %s");
       }
@@ -303,7 +301,7 @@ static int pmm_worker_cb(gras_msg_cb_ctx_t ctx, void *payload) {
          INFO2("ROW:   Send to %s:%d",
                gras_socket_peer_name(socket_line[l-1]),
                gras_socket_peer_port(socket_line[l-1]));
-         gras_msg_send(socket_line[l-1],gras_msgtype_by_name("dataA"), &mydataA);
+         gras_msg_send(socket_line[l-1],"dataA", &mydataA);
        }
        xbt_matrix_free(bA);
        bA = xbt_matrix_new_sub(mydataA,
@@ -312,7 +310,7 @@ static int pmm_worker_cb(gras_msg_cb_ctx_t ctx, void *payload) {
     } else {
       TRY {
        xbt_matrix_free(bA);
-       gras_msg_wait(1200,gras_msgtype_by_name("dataA"), &from,&bA);
+       gras_msg_wait(1200,"dataA", &from,&bA);
       } CATCH(e) {
        RETHROW0("Can't get a data message from row : %s");
       }
@@ -329,7 +327,7 @@ static int pmm_worker_cb(gras_msg_cb_ctx_t ctx, void *payload) {
   result.rowpos=myrow;
 
   TRY {
-    gras_msg_send(master, gras_msgtype_by_name("result"),&result);
+    gras_msg_send(master, "result",&result);
   } CATCH(e) {
     RETHROW0("Failed to send answer to server: %s");
   }
@@ -353,7 +351,7 @@ static int pmm_worker_cb(gras_msg_cb_ctx_t ctx, void *payload) {
        gras_socket_close(socket_row[l]); 
   }*/
 
-  return 1;
+  return 0;
 }
 
 int slave(int argc,char *argv[]) {
index d42614b..47d577c 100644 (file)
@@ -115,8 +115,7 @@ int client(int argc,char *argv[]) {
   ping = 1234;
   TRY {
     exception_catching();
-    gras_msg_rpccall(toserver, 6000.0,
-                    gras_msgtype_by_name("plain ping"), &ping, &pong);
+    gras_msg_rpccall(toserver, 6000.0, "plain ping", &ping, &pong);
   } CATCH(e) {
     gras_socket_close(toserver);
     RETHROW0("Failed to execute a PING rpc on the server: %s");
@@ -132,8 +131,7 @@ int client(int argc,char *argv[]) {
   /* 9. Call a RPC which raises an exception (to test exception propagation) */
   INFO0("Call the exception raising RPC");
   TRY {
-    gras_msg_rpccall(toserver, 6000.0,
-                    gras_msgtype_by_name("raise exception"), NULL, NULL);
+    gras_msg_rpccall(toserver, 6000.0, "raise exception", NULL, NULL);
   } CATCH(e) {
     gotit = 1; 
     xbt_assert2(e.category == unknown_error, 
@@ -158,8 +156,7 @@ int client(int argc,char *argv[]) {
        
      INFO1("Call the exception raising RPC (i=%d)",i);
      TRY {
-       gras_msg_rpccall(toserver, 6000.0,
-                        gras_msgtype_by_name("raise exception"), NULL, NULL);
+       gras_msg_rpccall(toserver, 6000.0, "raise exception", NULL, NULL);
      } CATCH(e) {
        gotit = 1;
        xbt_ex_free(e);
@@ -174,8 +171,7 @@ int client(int argc,char *argv[]) {
   for (i=0;i<5;i++) {
     INFO1("Call the exception raising RPC on the forwarder (i=%d)",i);
     TRY {
-      gras_msg_rpccall(toforwarder, 6000.0,
-                      gras_msgtype_by_name("forward exception"), NULL, NULL);
+      gras_msg_rpccall(toforwarder, 6000.0, "forward exception", NULL, NULL);
     } CATCH(e) {
       gotit = 1;
     }
@@ -195,9 +191,9 @@ int client(int argc,char *argv[]) {
   }
 
   INFO2("Ask %s:%d to die",gras_socket_peer_name(toforwarder),gras_socket_peer_port(toforwarder));
-  gras_msg_send(toforwarder,gras_msgtype_by_name("kill"),NULL);
+  gras_msg_send(toforwarder,"kill",NULL);
   INFO2("Ask %s:%d to die",gras_socket_peer_name(toserver),gras_socket_peer_port(toserver));
-  gras_msg_send(toserver,gras_msgtype_by_name("kill"),NULL);
+  gras_msg_send(toserver,"kill",NULL);
 
   /* 11. Cleanup the place before leaving */
   gras_socket_close(toserver);
@@ -222,7 +218,7 @@ static int forwarder_cb_kill(gras_msg_cb_ctx_t ctx,
   INFO2("Asked to die by %s:%d",gras_socket_peer_name(expeditor),gras_socket_peer_port(expeditor));
   forward_data_t fdata=gras_userdata_get();
   fdata->done = 1;
-  return 1;
+  return 0;
 }
 
 static int forwarder_cb_forward_ex(gras_msg_cb_ctx_t ctx,
@@ -230,9 +226,8 @@ static int forwarder_cb_forward_ex(gras_msg_cb_ctx_t ctx,
   forward_data_t fdata=gras_userdata_get();
 
   INFO0("Forward a request");
-  gras_msg_rpccall(fdata->server, 60,
-                  gras_msgtype_by_name("raise exception"),NULL,NULL);
-  return 1;
+  gras_msg_rpccall(fdata->server, 60, "raise exception",NULL,NULL);
+  return 0;
 }
 
 int forwarder (int argc,char *argv[]) {
@@ -285,13 +280,13 @@ static int server_cb_kill(gras_msg_cb_ctx_t ctx,
 
   server_data_t sdata=gras_userdata_get();
   sdata->done = 1;
-  return 1;
+  return 0;
 }
 
 static int server_cb_raise_ex(gras_msg_cb_ctx_t ctx,
                              void             *payload_data) {
   exception_raising();
-  return 1;
+  return 0;
 }
 
 static int server_cb_ping(gras_msg_cb_ctx_t ctx,
@@ -316,7 +311,7 @@ static int server_cb_ping(gras_msg_cb_ctx_t ctx,
   /* 6. Cleanups, if any */
 
   /* 7. Tell GRAS that we consummed this message */
-  return 1;
+  return 0;
 } /* end_of_server_cb_ping */
 
 
index 475193c..a1a8623 100644 (file)
@@ -163,8 +163,7 @@ void amok_bw_test(gras_socket_t peer,
        request->buf_size,request->msg_size,request->msg_amount);
 
   TRY {
-    gras_msg_rpccall(peer,15,
-                    gras_msgtype_by_name("BW handshake"),&request, &request_ack);
+    gras_msg_rpccall(peer,15,"BW handshake",&request, &request_ack);
   } CATCH(e) {
     RETHROW0("Error encountered while sending the BW request: %s");
   }
@@ -217,7 +216,7 @@ void amok_bw_test(gras_socket_t peer,
            request->msg_size, request->msg_amount,
            ((double)request->msg_size) * ((double)request->msg_amount / (*sec) /1024.0/1024.0));
 
-      gras_msg_rpccall(peer, 60, gras_msgtype_by_name("BW reask"),&request, NULL);      
+      gras_msg_rpccall(peer, 60, "BW reask",&request, NULL);      
     }
 
     first_pass = 0;
@@ -245,7 +244,7 @@ void amok_bw_test(gras_socket_t peer,
 
   DEBUG2("This measurement was long enough (%f sec; found %f b/s). Stop peer",
         *sec,*bw);
-  gras_msg_send(peer, gras_msgtype_by_name("BW stop"), NULL);      
+  gras_msg_send(peer, "BW stop", NULL);      
 
   free(request_ack);
   free(request);
@@ -374,7 +373,7 @@ int amok_bw_cb_bw_handshake(gras_msg_cb_ctx_t  ctx,
   free(answer);
   free(request);
   VERB0("BW experiment done.");
-  return 1;
+  return 0;
 }
 
 /**
@@ -430,7 +429,7 @@ void amok_bw_request(const char* from_name,unsigned int from_port,
     
  
   DEBUG4("Ask for a BW test between %s:%d and %s:%d",  from_name,from_port, to_name,to_port);
-  gras_msg_rpccall(sock,20*60,gras_msgtype_by_name("BW request"), &request, &result);
+  gras_msg_rpccall(sock,20*60,"BW request", &request, &result);
 
   if (sec)
     *sec=result->sec;
@@ -474,7 +473,7 @@ int amok_bw_cb_bw_request(gras_msg_cb_ctx_t ctx,
   free(request);
   free(result);
   
-  return 1;
+  return 0;
 }
 
 /** \brief builds a matrix of results of bandwidth measurement
index fe7745c..fe15223 100644 (file)
@@ -79,7 +79,7 @@ void amok_bw_saturate_start(const char* from_name,unsigned int from_port,
   request->duration=duration;
   request->msg_size=msg_size;
 
-  gras_msg_rpccall(sock,60,gras_msgtype_by_name("amok_bw_sat start"),&request, NULL);
+  gras_msg_rpccall(sock,60,"amok_bw_sat start",&request, NULL);
 
   free(request);
   gras_socket_close(sock);
@@ -104,7 +104,7 @@ static int amok_bw_cb_sat_start(gras_msg_cb_ctx_t ctx, void *payload){
   free(request->peer.name);
 
   free(request);
-  return 1;
+  return 0;
 }
 
 /**
@@ -166,9 +166,7 @@ void amok_bw_saturate_begin(const char* to_name,unsigned int to_port,
    
   /* Launch the saturation */
 
-  ctx = gras_msg_rpc_async_call(peer_cmd, 60, 
-                               gras_msgtype_by_name("amok_bw_sat begin"),
-                                                 &request);
+  ctx = gras_msg_rpc_async_call(peer_cmd, 60, "amok_bw_sat begin", &request);
   free(request);
   gras_msg_rpc_async_wait(ctx,&request);
   meas=gras_socket_client_ext( to_name, request->peer.port,
@@ -191,7 +189,7 @@ void amok_bw_saturate_begin(const char* to_name,unsigned int to_port,
     /* Check whether someone asked us to stop saturation */
     saturate_further = 0;
     TRY {
-      gras_msg_wait_ext(0/*no wait*/,gras_msgtype_by_name("amok_bw_sat stop"),
+      gras_msg_wait_ext(0/*no wait*/,"amok_bw_sat stop",
                        NULL /* accept any sender */,
                        NULL, NULL, /* No specific filter */
                        &msg_got);
@@ -297,7 +295,7 @@ static int amok_bw_cb_sat_begin(gras_msg_cb_ctx_t ctx, void *payload){
   if (gras_if_RL()) /* On SG, accepted=master */
     gras_socket_close(measMaster); 
   free(request);
-  return 1;
+  return 0;
 }
 
 /**
@@ -316,7 +314,7 @@ void amok_bw_saturate_stop(const char* from_name,unsigned int from_port,
   bw_res_t answer;
   VERB2("Ask %s:%d to stop the saturation",from_name,from_port);
   TRY {        
-     gras_msg_rpccall(sock,60,gras_msgtype_by_name("amok_bw_sat stop"),NULL,&answer);
+     gras_msg_rpccall(sock,60,"amok_bw_sat stop",NULL,&answer);
   } CATCH(e) {
      RETHROW2("Cannot ask %s:%d to stop saturation: %s",from_name, from_port);
   }
index 1f14436..f0ed25e 100644 (file)
@@ -31,7 +31,7 @@ static int amok_pm_cb_kill(gras_msg_cb_ctx_t ctx,
 
   amok_pm_moddata_t g=gras_moddata_by_id(amok_pm_moddata_id);
   g->done = 1;
-  return 1;
+  return 0;
 }
 static int amok_pm_cb_killrpc(gras_msg_cb_ctx_t ctx,
                              void             *payload_data) {
@@ -39,7 +39,7 @@ static int amok_pm_cb_killrpc(gras_msg_cb_ctx_t ctx,
   amok_pm_moddata_t g=gras_moddata_by_id(amok_pm_moddata_id);
   g->done = 1;
   gras_msg_rpcreturn(30,ctx,NULL);
-  return 1;
+  return 0;
 }
 
 static int amok_pm_cb_get(gras_msg_cb_ctx_t ctx, void *payload) {
@@ -48,7 +48,7 @@ static int amok_pm_cb_get(gras_msg_cb_ctx_t ctx, void *payload) {
   xbt_dynar_t res = xbt_dict_get(g->groups, name);
 
   gras_msg_rpcreturn(30, ctx, &res);
-  return 1;
+  return 0;
 }
 static int amok_pm_cb_join(gras_msg_cb_ctx_t ctx, void *payload) {
   amok_pm_moddata_t g=gras_moddata_by_id(amok_pm_moddata_id);
@@ -64,7 +64,7 @@ static int amok_pm_cb_join(gras_msg_cb_ctx_t ctx, void *payload) {
 
   gras_msg_rpcreturn(10, ctx, NULL);
   free(name);
-  return 1;
+  return 0;
 }
 static int amok_pm_cb_leave(gras_msg_cb_ctx_t ctx, void *payload) {
   amok_pm_moddata_t g=gras_moddata_by_id(amok_pm_moddata_id);
@@ -90,7 +90,7 @@ static int amok_pm_cb_leave(gras_msg_cb_ctx_t ctx, void *payload) {
 
  end:
   gras_msg_rpcreturn(30, ctx, NULL);
-  return 1;
+  return 0;
 }
 
 static int amok_pm_cb_shutdown(gras_msg_cb_ctx_t ctx, void *payload) {
@@ -98,7 +98,7 @@ static int amok_pm_cb_shutdown(gras_msg_cb_ctx_t ctx, void *payload) {
   amok_pm_group_shutdown(name);
 
   gras_msg_rpcreturn(30, ctx, NULL);
-  return 1;
+  return 0;
 }
 
 /** \brief Enter the main loop of the program. It won't return until we get a kill message. */
@@ -119,12 +119,12 @@ void amok_pm_kill_hp(char *name,int port) {
 
 /** \brief kill a buddy to which we have a socket already. Note that it is not removed from any group it may belong to. */
 void amok_pm_kill(gras_socket_t buddy) {
-  gras_msg_send(buddy,gras_msgtype_by_name("amok_pm_kill"),NULL);
+  gras_msg_send(buddy,"amok_pm_kill",NULL);
 }
 
 /** \brief kill syncronously a buddy (do not return before its death). Note that it is not removed from any group it may belong to. */
 void amok_pm_kill_sync(gras_socket_t buddy) {
-  gras_msg_rpccall(buddy,30,gras_msgtype_by_name("amok_pm_killrpc"),NULL,NULL);
+  gras_msg_rpccall(buddy,30,"amok_pm_killrpc",NULL,NULL);
 }
 
 
@@ -151,8 +151,7 @@ xbt_dynar_t amok_pm_group_new(const char *group_name) {
 xbt_dynar_t amok_pm_group_get(gras_socket_t master, const char *group_name) {
   xbt_dynar_t res;
   
-  gras_msg_rpccall(master,30,gras_msgtype_by_name("amok_pm_get"),
-                  &group_name,&res);
+  gras_msg_rpccall(master,30,"amok_pm_get", &group_name,&res);
   return res;
 }
 
@@ -160,8 +159,7 @@ xbt_dynar_t amok_pm_group_get(gras_socket_t master, const char *group_name) {
 void        amok_pm_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_pm_join"),
-                  &group_name,NULL);
+  gras_msg_rpccall(master,30,"amok_pm_join", &group_name,NULL);
   VERB3("Joined group '%s' on %s:%d",
        group_name,gras_socket_peer_name(master),gras_socket_peer_port(master));
 }
@@ -170,8 +168,7 @@ void        amok_pm_group_join(gras_socket_t master, const char *group_name) {
  * If not found, call is ignored 
  */
 void        amok_pm_group_leave(gras_socket_t master, const char *group_name) {
-  gras_msg_rpccall(master,30,gras_msgtype_by_name("amok_pm_leave"),
-                  &group_name,NULL);
+  gras_msg_rpccall(master,30,"amok_pm_leave", &group_name,NULL);
   VERB3("Leaved group '%s' on %s:%d",
        group_name,gras_socket_peer_name(master),gras_socket_peer_port(master));
 }
@@ -193,8 +190,7 @@ void amok_pm_group_shutdown(const char *group_name) {
 }
 /** \brief stops all members of the given remote group */
 void amok_pm_group_shutdown_remote(gras_socket_t master, const char *group_name){
-  gras_msg_rpccall(master,30,gras_msgtype_by_name("amok_pm_shutdown"),
-                  &group_name,NULL);
+  gras_msg_rpccall(master,30,"amok_pm_shutdown", &group_name,NULL);
 }