A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Move datadesc and TCP sockets from GRAS to XBT.
[simgrid.git]
/
examples
/
gras
/
mmrpc
/
mmrpc_server.c
diff --git
a/examples/gras/mmrpc/mmrpc_server.c
b/examples/gras/mmrpc/mmrpc_server.c
index
bcaf5f1
..
e3a1910
100644
(file)
--- a/
examples/gras/mmrpc/mmrpc_server.c
+++ b/
examples/gras/mmrpc/mmrpc_server.c
@@
-6,7
+6,7
@@
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-#define
GRAS
_DEFINE_TYPE_EXTERN
+#define
XBT
_DEFINE_TYPE_EXTERN
#include "xbt/matrix.h"
#include "mmrpc.h"
#include "xbt/matrix.h"
#include "mmrpc.h"
@@
-18,7
+18,7
@@
static int server_cb_request_handler(gras_msg_cb_ctx_t ctx,
void *payload_data)
{
void *payload_data)
{
-
gras
_socket_t expeditor = gras_msg_cb_ctx_from(ctx);
+
xbt
_socket_t expeditor = gras_msg_cb_ctx_from(ctx);
/* 1. Get the payload into the data variable */
xbt_matrix_t *request = (xbt_matrix_t *) payload_data;
/* 1. Get the payload into the data variable */
xbt_matrix_t *request = (xbt_matrix_t *) payload_data;
@@
-38,9
+38,21
@@
static int server_cb_request_handler(gras_msg_cb_ctx_t ctx,
return 0;
} /* end_of_server_cb_request_handler */
return 0;
} /* end_of_server_cb_request_handler */
+static xbt_socket_t try_gras_socket_server(int port)
+{
+ volatile xbt_socket_t sock = NULL;
+ TRY {
+ sock = gras_socket_server(port);
+ }
+ CATCH_ANONYMOUS {
+ RETHROWF("Unable to establish a server socket: %s");
+ }
+ return sock;
+}
+
int server(int argc, char *argv[])
{
int server(int argc, char *argv[])
{
-
gras
_socket_t sock = NULL;
+
xbt
_socket_t sock = NULL;
int port = 4002;
/* 1. Init the GRAS infrastructure */
int port = 4002;
/* 1. Init the GRAS infrastructure */
@@
-59,12
+71,7
@@
int server(int argc, char *argv[])
/* 5. Create my master socket */
XBT_INFO("Launch server (port=%d)", port);
/* 5. Create my master socket */
XBT_INFO("Launch server (port=%d)", port);
- TRY {
- sock = gras_socket_server(port);
- }
- CATCH_ANONYMOUS {
- RETHROWF("Unable to establish a server socket: %s");
- }
+ sock = try_gras_socket_server(port);
/* 6. Wait up to 10 minutes for an incomming message to handle */
gras_msg_handle(600.0);
/* 6. Wait up to 10 minutes for an incomming message to handle */
gras_msg_handle(600.0);