From: mquinson Date: Mon, 27 Jun 2005 22:22:55 +0000 (+0000) Subject: Unstar the gras_trp_plugin_t type, even if internal, I'm now used to it; cleanups... X-Git-Tag: v3.3~3923 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/d11b30e2f4ac9920cf350e76147d065907b71418 Unstar the gras_trp_plugin_t type, even if internal, I'm now used to it; cleanups; documentation improvement; plugin_buf now declares its super plugin as static global, not in the data field in plugin (easier, cleaner and faster) git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@1432 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/src/gras/Transport/rl_transport.c b/src/gras/Transport/rl_transport.c index 962431602f..b4d23e1792 100644 --- a/src/gras/Transport/rl_transport.c +++ b/src/gras/Transport/rl_transport.c @@ -202,7 +202,7 @@ gras_trp_select(double timeout, return timeout_error; } -xbt_error_t gras_trp_sg_setup(gras_trp_plugin_t *plug) { +xbt_error_t gras_trp_sg_setup(gras_trp_plugin_t plug) { return mismatch_error; } diff --git a/src/gras/Transport/sg_transport.c b/src/gras/Transport/sg_transport.c index 53019f5605..d78607c999 100644 --- a/src/gras/Transport/sg_transport.c +++ b/src/gras/Transport/sg_transport.c @@ -33,7 +33,7 @@ gras_trp_select(double timeout, double startTime=gras_os_time(); gras_trp_procdata_t pd=(gras_trp_procdata_t)gras_libdata_get("gras_trp"); gras_trp_sg_sock_data_t *sockdata; - gras_trp_plugin_t *trp; + gras_trp_plugin_t trp; gras_socket_t sock_iter; /* iterating over all sockets */ int cursor,cpt; @@ -149,10 +149,10 @@ gras_trp_select(double timeout, /* dummy implementations of the functions used in RL mode */ -xbt_error_t gras_trp_tcp_setup(gras_trp_plugin_t *plug) { +xbt_error_t gras_trp_tcp_setup(gras_trp_plugin_t plug) { return mismatch_error; } -xbt_error_t gras_trp_file_setup(gras_trp_plugin_t *plug) { +xbt_error_t gras_trp_file_setup(gras_trp_plugin_t plug) { return mismatch_error; } diff --git a/src/gras/Transport/transport.c b/src/gras/Transport/transport.c index 5a0c35a38a..13b92aafd2 100644 --- a/src/gras/Transport/transport.c +++ b/src/gras/Transport/transport.c @@ -21,7 +21,7 @@ static void gras_trp_plugin_new(const char *name, gras_trp_setup_t setup) { xbt_error_t errcode; - gras_trp_plugin_t *plug = xbt_new0(gras_trp_plugin_t, 1); + gras_trp_plugin_t plug = xbt_new0(s_gras_trp_plugin_t, 1); DEBUG1("Create plugin %s",name); @@ -126,7 +126,7 @@ gras_trp_exit(void){ void gras_trp_plugin_free(void *p) { - gras_trp_plugin_t *plug = p; + gras_trp_plugin_t plug = p; if (plug) { if (plug->exit) { @@ -155,18 +155,20 @@ void gras_trp_socket_new(int incoming, DEBUG1("Create a new socket (%p)", (void*)sock); sock->plugin = NULL; - sock->sd = -1; - sock->data = NULL; sock->incoming = incoming ? 1:0; sock->outgoing = incoming ? 0:1; sock->accepting = incoming ? 1:0; + sock->meas = 0; + sock->sd = -1; sock->port = -1; sock->peer_port = -1; sock->peer_name = NULL; - sock->meas = 0; + sock->data = NULL; + sock->bufdata = NULL; + *dst = sock; xbt_dynar_push(gras_socketset_get(),dst); @@ -189,7 +191,7 @@ gras_socket_server_ext(unsigned short port, /* OUT */ gras_socket_t *dst) { xbt_error_t errcode; - gras_trp_plugin_t *trp; + gras_trp_plugin_t trp; gras_socket_t sock; *dst = NULL; @@ -242,7 +244,7 @@ gras_socket_client_ext(const char *host, /* OUT */ gras_socket_t *dst) { xbt_error_t errcode; - gras_trp_plugin_t *trp; + gras_trp_plugin_t trp; gras_socket_t sock; *dst = NULL; @@ -376,7 +378,7 @@ gras_trp_flush(gras_socket_t sd) { xbt_error_t gras_trp_plugin_get_by_name(const char *name, - gras_trp_plugin_t **dst){ + gras_trp_plugin_t *dst){ return xbt_dict_get(_gras_trp_plugins,name,(void**)dst); } @@ -391,6 +393,25 @@ char *gras_socket_peer_name(gras_socket_t sock) { return sock->peer_name; } +/** \brief Check if the provided socket is a measurement one (or a regular one) */ +int gras_socket_is_meas(gras_socket_t sock) { + return sock->meas; +} + +/** \brief Send a chunk of (random) data over a measurement socket + * + * @param peer measurement socket to use for the experiment + * @param timeout timeout (in seconds) + * @param exp_size total amount of data to send (in bytes). + * @param msg_size size of each chunk sent over the socket (in bytes). + * + * Calls to gras_socket_meas_send() and gras_socket_meas_recv() on + * each side of the socket should be paired. + * + * The exchanged data is zeroed to make sure it's initialized, but + * there is no way to control what is sent (ie, you cannot use these + * functions to exchange data out of band). + */ xbt_error_t gras_socket_meas_send(gras_socket_t peer, unsigned int timeout, unsigned long int exp_size, @@ -419,6 +440,11 @@ xbt_error_t gras_socket_meas_send(gras_socket_t peer, return no_error; } +/** \brief Receive a chunk of data over a measurement socket + * + * Calls to gras_socket_meas_send() and gras_socket_meas_recv() on + * each side of the socket should be paired. + */ xbt_error_t gras_socket_meas_recv(gras_socket_t peer, unsigned int timeout, unsigned long int exp_size, @@ -452,14 +478,13 @@ xbt_error_t gras_socket_meas_recv(gras_socket_t peer, * \brief Something similar to the good old accept system call. * * Make sure that there is someone speaking to the provided server socket. - * In RL, it does an accept(2), close the master socket, and put the accepted - * socket in place of the provided one. In SG, it does not do anything for + * In RL, it does an accept(2) and return the result as last argument. + * In SG, as accepts are useless, it returns the provided argument as result. + * You should thus test whether (peer != accepted) before closing both of them. * * You should only call this on measurement sockets. It is automatically * done for regular sockets, but you usually want more control about * what's going on with measurement sockets. - * - * */ xbt_error_t gras_socket_meas_accept(gras_socket_t peer, gras_socket_t *accepted){ xbt_error_t errcode; diff --git a/src/gras/Transport/transport_interface.h b/src/gras/Transport/transport_interface.h index 595deabe44..ba43fe5185 100644 --- a/src/gras/Transport/transport_interface.h +++ b/src/gras/Transport/transport_interface.h @@ -34,7 +34,7 @@ gras_trp_select(double timeout, ***/ /* A plugin type */ -typedef struct gras_trp_plugin_ gras_trp_plugin_t; +typedef struct gras_trp_plugin_ s_gras_trp_plugin_t, *gras_trp_plugin_t; /* A plugin type */ struct gras_trp_plugin_ { @@ -43,10 +43,10 @@ struct gras_trp_plugin_ { /* dst pointers are created and initialized with default values before call to socket_client/server. Retrive the info you need from there. */ - xbt_error_t (*socket_client)(gras_trp_plugin_t *self, - gras_socket_t dst); - xbt_error_t (*socket_server)(gras_trp_plugin_t *self, - gras_socket_t dst); + xbt_error_t (*socket_client)(gras_trp_plugin_t self, + gras_socket_t dst); + xbt_error_t (*socket_server)(gras_trp_plugin_t self, + gras_socket_t dst); xbt_error_t (*socket_accept)(gras_socket_t sock, gras_socket_t *dst); @@ -70,12 +70,12 @@ struct gras_trp_plugin_ { /* exit is responsible for freeing data and telling the OS this plugin goes */ /* exit=NULL, data gets freed. (ie exit function needed only when data contains pointers) */ - void (*exit)(gras_trp_plugin_t *); + void (*exit)(gras_trp_plugin_t); }; xbt_error_t gras_trp_plugin_get_by_name(const char *name, - gras_trp_plugin_t **dst); + gras_trp_plugin_t *dst); /* Data of this module specific to each process * (used by sg_process.c to cleanup the SG channel cruft) diff --git a/src/gras/Transport/transport_plugin_buf.c b/src/gras/Transport/transport_plugin_buf.c index 767c246062..dde6dc8f87 100644 --- a/src/gras/Transport/transport_plugin_buf.c +++ b/src/gras/Transport/transport_plugin_buf.c @@ -18,14 +18,17 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(trp_buf,transport, "Generic buffered transport (works on top of TCP or SG)"); + +static gras_trp_plugin_t _buf_super; + /*** *** Prototypes ***/ void hexa_print(const char*name, unsigned char *data, int size); /* in gras.c */ -xbt_error_t gras_trp_buf_socket_client(gras_trp_plugin_t *self, +xbt_error_t gras_trp_buf_socket_client(gras_trp_plugin_t self, gras_socket_t sock); -xbt_error_t gras_trp_buf_socket_server(gras_trp_plugin_t *self, +xbt_error_t gras_trp_buf_socket_server(gras_trp_plugin_t self, gras_socket_t sock); xbt_error_t gras_trp_buf_socket_accept(gras_socket_t sock, gras_socket_t *dst); @@ -47,7 +50,7 @@ xbt_error_t gras_trp_buf_flush(gras_socket_t sock); ***/ typedef struct { - gras_trp_plugin_t *super; + int junk; } gras_trp_buf_plug_data_t; /*** @@ -86,18 +89,17 @@ void gras_trp_buf_init_sock(gras_socket_t sock) { sock->bufdata = data; } - /*** *** Code ***/ xbt_error_t -gras_trp_buf_setup(gras_trp_plugin_t *plug) { +gras_trp_buf_setup(gras_trp_plugin_t plug) { xbt_error_t errcode; gras_trp_buf_plug_data_t *data =xbt_new(gras_trp_buf_plug_data_t,1); XBT_IN; TRY(gras_trp_plugin_get_by_name(gras_if_RL() ? "tcp" : "sg", - &(data->super))); + &_buf_super)); DEBUG1("Derivate a buffer plugin from %s",gras_if_RL() ? "tcp" : "sg"); plug->socket_client = gras_trp_buf_socket_client; @@ -116,13 +118,12 @@ gras_trp_buf_setup(gras_trp_plugin_t *plug) { return no_error; } -xbt_error_t gras_trp_buf_socket_client(gras_trp_plugin_t *self, +xbt_error_t gras_trp_buf_socket_client(gras_trp_plugin_t self, /* OUT */ gras_socket_t sock){ xbt_error_t errcode; - gras_trp_plugin_t *super=((gras_trp_buf_plug_data_t*)self->data)->super; XBT_IN; - TRY(super->socket_client(super,sock)); + TRY(_buf_super->socket_client(_buf_super,sock)); sock->plugin = self; gras_trp_buf_init_sock(sock); @@ -134,13 +135,12 @@ xbt_error_t gras_trp_buf_socket_client(gras_trp_plugin_t *self, * * Open a socket used to receive messages. */ -xbt_error_t gras_trp_buf_socket_server(gras_trp_plugin_t *self, +xbt_error_t gras_trp_buf_socket_server(gras_trp_plugin_t self, /* OUT */ gras_socket_t sock){ xbt_error_t errcode; - gras_trp_plugin_t *super=((gras_trp_buf_plug_data_t*)self->data)->super; XBT_IN; - TRY(super->socket_server(super,sock)); + TRY(_buf_super->socket_server(_buf_super,sock)); sock->plugin = self; gras_trp_buf_init_sock(sock); return no_error; @@ -150,10 +150,9 @@ xbt_error_t gras_trp_buf_socket_accept(gras_socket_t sock, gras_socket_t *dst) { xbt_error_t errcode; - gras_trp_plugin_t *super=((gras_trp_buf_plug_data_t*)sock->plugin->data)->super; XBT_IN; - TRY(super->socket_accept(sock,dst)); + TRY(_buf_super->socket_accept(sock,dst)); (*dst)->plugin = sock->plugin; gras_trp_buf_init_sock(*dst); XBT_OUT; @@ -161,7 +160,7 @@ gras_trp_buf_socket_accept(gras_socket_t sock, } void gras_trp_buf_socket_close(gras_socket_t sock){ - gras_trp_plugin_t *super=((gras_trp_buf_plug_data_t*)sock->plugin->data)->super; + xbt_error_t errcode; gras_trp_bufdata_t *data=sock->bufdata; XBT_IN; @@ -181,7 +180,7 @@ void gras_trp_buf_socket_close(gras_socket_t sock){ free(data->out.data); free(data); - super->socket_close(sock); + _buf_super->socket_close(sock); } /** @@ -236,10 +235,9 @@ gras_trp_buf_chunk_recv(gras_socket_t sock, unsigned long int size) { xbt_error_t errcode; - gras_trp_plugin_t *super=((gras_trp_buf_plug_data_t*)sock->plugin->data)->super; gras_trp_bufdata_t *data=sock->bufdata; long int chunck_pos = 0; - + /* Let underneath plugin check for direction, we work even in duplex */ xbt_assert0(sock, "Cannot recv on an NULL socket"); xbt_assert0(size >= 0, "Cannot receive a negative amount of data"); @@ -254,14 +252,17 @@ gras_trp_buf_chunk_recv(gras_socket_t sock, int nextsize; if (gras_if_RL()) { DEBUG0("Recv the size"); - TRY(super->chunk_recv(sock,(char*)&nextsize, 4)); + errcode=_buf_super->chunk_recv(sock,(char*)&nextsize, 4); + if (errcode!=no_error) + RAISE4(errcode,"Got '%s' while trying to get the chunk size on %p (peer = %s:%d)", + xbt_error_name(errcode),sock,gras_socket_peer_name(sock),gras_socket_peer_port(sock)); data->in.size = (int)ntohl(nextsize); VERB1("Recv the chunk (size=%d)",data->in.size); } else { data->in.size = -1; } - TRY(super->chunk_recv(sock, data->in.data, data->in.size)); + TRY(_buf_super->chunk_recv(sock, data->in.data, data->in.size)); if (gras_if_RL()) { data->in.pos=0; @@ -302,10 +303,9 @@ xbt_error_t gras_trp_buf_flush(gras_socket_t sock) { xbt_error_t errcode; int size; - gras_trp_plugin_t *super=((gras_trp_buf_plug_data_t*)sock->plugin->data)->super; gras_trp_bufdata_t *data=sock->bufdata; - - XBT_IN; + XBT_IN; + DEBUG0("Flush"); if (XBT_LOG_ISENABLED(trp_buf,xbt_log_priority_debug)) hexa_print("chunck to send ",data->out.data,data->out.size); @@ -319,7 +319,7 @@ gras_trp_buf_flush(gras_socket_t sock) { gras_socket_peer_name(sock),gras_socket_peer_port(sock)); if (gras_if_RL()) { size = (int)htonl(size); - TRY(super->chunk_send(sock,(char*) &size, 4)); + TRY(_buf_super->chunk_send(sock,(char*) &size, 4)); } else { memcpy(data->out.data, &size, 4); } @@ -327,7 +327,7 @@ gras_trp_buf_flush(gras_socket_t sock) { DEBUG3("Send the chunk (size=%d) to %s:%d",data->out.size, gras_socket_peer_name(sock),gras_socket_peer_port(sock)); - TRY(super->chunk_send(sock, data->out.data, data->out.size)); + TRY(_buf_super->chunk_send(sock, data->out.data, data->out.size)); VERB1("Chunk sent (size=%d)",data->out.size); if (XBT_LOG_ISENABLED(trp_buf,xbt_log_priority_debug)) hexa_print("chunck sent ",data->out.data,data->out.size); diff --git a/src/gras/Transport/transport_plugin_file.c b/src/gras/Transport/transport_plugin_file.c index 2e54bf1462..f99f7593a2 100644 --- a/src/gras/Transport/transport_plugin_file.c +++ b/src/gras/Transport/transport_plugin_file.c @@ -49,7 +49,7 @@ typedef struct { *** Code ***/ xbt_error_t -gras_trp_file_setup(gras_trp_plugin_t *plug) { +gras_trp_file_setup(gras_trp_plugin_t plug) { gras_trp_file_plug_data_t *file = xbt_new(gras_trp_file_plug_data_t,1); @@ -74,7 +74,7 @@ xbt_error_t gras_socket_client_from_file(const char*path, /* OUT */ gras_socket_t *dst) { xbt_error_t errcode; - gras_trp_plugin_t *trp; + gras_trp_plugin_t trp; xbt_assert0(gras_if_RL(), "Cannot use file as socket in the simulator"); @@ -117,7 +117,7 @@ xbt_error_t gras_socket_server_from_file(const char*path, /* OUT */ gras_socket_t *dst) { xbt_error_t errcode; - gras_trp_plugin_t *trp; + gras_trp_plugin_t trp; xbt_assert0(gras_if_RL(), "Cannot use file as socket in the simulator"); diff --git a/src/gras/Transport/transport_plugin_sg.c b/src/gras/Transport/transport_plugin_sg.c index c12cb01f85..bc687158d3 100644 --- a/src/gras/Transport/transport_plugin_sg.c +++ b/src/gras/Transport/transport_plugin_sg.c @@ -29,9 +29,9 @@ static xbt_error_t find_port(gras_hostdata_t *hd, int port, gras_sg_portrec_t *hpd); -xbt_error_t gras_trp_sg_socket_client(gras_trp_plugin_t *self, +xbt_error_t gras_trp_sg_socket_client(gras_trp_plugin_t self, /* OUT */ gras_socket_t sock); -xbt_error_t gras_trp_sg_socket_server(gras_trp_plugin_t *self, +xbt_error_t gras_trp_sg_socket_server(gras_trp_plugin_t self, /* OUT */ gras_socket_t sock); void gras_trp_sg_socket_close(gras_socket_t sd); @@ -72,7 +72,7 @@ static xbt_error_t find_port(gras_hostdata_t *hd, int port, xbt_error_t -gras_trp_sg_setup(gras_trp_plugin_t *plug) { +gras_trp_sg_setup(gras_trp_plugin_t plug) { gras_trp_sg_plug_data_t *data=xbt_new(gras_trp_sg_plug_data_t,1); @@ -90,7 +90,7 @@ gras_trp_sg_setup(gras_trp_plugin_t *plug) { return no_error; } -xbt_error_t gras_trp_sg_socket_client(gras_trp_plugin_t *self, +xbt_error_t gras_trp_sg_socket_client(gras_trp_plugin_t self, /* OUT */ gras_socket_t sock){ xbt_error_t errcode; @@ -149,7 +149,7 @@ xbt_error_t gras_trp_sg_socket_client(gras_trp_plugin_t *self, return no_error; } -xbt_error_t gras_trp_sg_socket_server(gras_trp_plugin_t *self, +xbt_error_t gras_trp_sg_socket_server(gras_trp_plugin_t self, gras_socket_t sock){ xbt_error_t errcode; diff --git a/src/gras/Transport/transport_plugin_tcp.c b/src/gras/Transport/transport_plugin_tcp.c index ee776c819e..2122896005 100644 --- a/src/gras/Transport/transport_plugin_tcp.c +++ b/src/gras/Transport/transport_plugin_tcp.c @@ -22,9 +22,9 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(trp_tcp,transport,"TCP transport"); /*** *** Prototypes ***/ -xbt_error_t gras_trp_tcp_socket_client(gras_trp_plugin_t *self, +xbt_error_t gras_trp_tcp_socket_client(gras_trp_plugin_t self, gras_socket_t sock); -xbt_error_t gras_trp_tcp_socket_server(gras_trp_plugin_t *self, +xbt_error_t gras_trp_tcp_socket_server(gras_trp_plugin_t self, gras_socket_t sock); xbt_error_t gras_trp_tcp_socket_accept(gras_socket_t sock, gras_socket_t *dst); @@ -39,7 +39,7 @@ xbt_error_t gras_trp_tcp_chunk_recv(gras_socket_t sd, char *data, unsigned long int size); -void gras_trp_tcp_exit(gras_trp_plugin_t *plug); +void gras_trp_tcp_exit(gras_trp_plugin_t plug); static int TcpProtoNumber(void); @@ -64,7 +64,7 @@ typedef struct { /*** *** Code ***/ -xbt_error_t gras_trp_tcp_setup(gras_trp_plugin_t *plug) { +xbt_error_t gras_trp_tcp_setup(gras_trp_plugin_t plug) { gras_trp_tcp_plug_data_t *data = xbt_new(gras_trp_tcp_plug_data_t,1); @@ -87,12 +87,12 @@ xbt_error_t gras_trp_tcp_setup(gras_trp_plugin_t *plug) { return no_error; } -void gras_trp_tcp_exit(gras_trp_plugin_t *plug) { +void gras_trp_tcp_exit(gras_trp_plugin_t plug) { DEBUG1("Exit plugin TCP (free %p)", plug->data); free(plug->data); } -xbt_error_t gras_trp_tcp_socket_client(gras_trp_plugin_t *self, +xbt_error_t gras_trp_tcp_socket_client(gras_trp_plugin_t self, gras_socket_t sock){ struct sockaddr_in addr; @@ -129,14 +129,14 @@ xbt_error_t gras_trp_tcp_socket_client(gras_trp_plugin_t *self, addr.sin_family = AF_INET; addr.sin_port = htons (sock->peer_port); - DEBUG2("Connect to %s:%d",sock->peer_name, sock->peer_port); if (connect (sock->sd, (struct sockaddr*) &addr, sizeof (addr)) < 0) { tcp_close(sock->sd); RAISE3(system_error, "Failed to connect socket to %s:%d (%s)", sock->peer_name, sock->peer_port, sock_errstr); } - + VERB4("Connect to %s:%d (sd=%d, port %d here)",sock->peer_name, sock->peer_port, sock->sd, sock->port); + return no_error; } @@ -145,7 +145,7 @@ xbt_error_t gras_trp_tcp_socket_client(gras_trp_plugin_t *self, * * Open a socket used to receive messages. */ -xbt_error_t gras_trp_tcp_socket_server(gras_trp_plugin_t *self, +xbt_error_t gras_trp_tcp_socket_server(gras_trp_plugin_t self, /* OUT */ gras_socket_t sock){ int size = sock->bufSize * 1024; int on = 1; @@ -178,7 +178,7 @@ xbt_error_t gras_trp_tcp_socket_server(gras_trp_plugin_t *self, RAISE2(system_error,"Cannot bind to port %d: %s",sock->port, sock_errstr); } - DEBUG1("Listen on port %d",sock->port); + DEBUG2("Listen on port %d (sd=%d)",sock->port, sock->sd); if (listen(sock->sd, 5) < 0) { tcp_close(sock->sd); RAISE2(system_error,"Cannot listen on port %d: %s",sock->port,sock_errstr); @@ -189,7 +189,7 @@ xbt_error_t gras_trp_tcp_socket_server(gras_trp_plugin_t *self, else FD_SET(sock->sd, &(tcp->msg_socks)); - DEBUG2("Openned a server socket on port %d (sock %d)",sock->port,sock->sd); + VERB2("Openned a server socket on port %d (sd=%d)",sock->port,sock->sd); return no_error; } @@ -259,7 +259,7 @@ gras_trp_tcp_socket_accept(gras_socket_t sock, } } - VERB3("Accepted socket %d to %s:%d", sd, res->peer_name,res->peer_port); + VERB3("Accepted from %s:%d (sd=%d)", res->peer_name,res->peer_port,sd); *dst = res; @@ -274,7 +274,7 @@ void gras_trp_tcp_socket_close(gras_socket_t sock){ if (!sock) return; /* close only once */ tcp=sock->plugin->data; - DEBUG1("close tcp connection %d", sock->sd); + VERB1("close tcp connection %d", sock->sd); /* FIXME: no pipe in GRAS so far if(!FD_ISSET(sd, &connectedPipes)) { @@ -375,7 +375,8 @@ gras_trp_tcp_chunk_recv(gras_socket_t sock, size -= status; data += status; } else { - RAISE0(system_error,"file descriptor closed (nothing read on the socket)"); + RAISE3(system_error,"file descriptor closed (nothing read(%d, %p, %ld) on the socket)", + sock->sd, data, size); } } @@ -401,56 +402,6 @@ static int TcpProtoNumber(void) { return returnValue; } -#if 0 /* KILLME */ -/* Data exchange over measurement sockets. Placing this in there is a kind of crude hack. - It means that the only possible measurement sockets are TCP where we may want to do UDP for them. - But I fail to find a good internal organization for now. We may want to split - meas and regular sockets more efficiently. -*/ -xbt_error_t gras_socket_meas_exchange(gras_socket_t peer, - int sender, - unsigned int timeout, - unsigned long int exp_size, - unsigned long int msg_size) { - char *chunk; - int res_last, msg_sofar, exp_sofar; - - fd_set rd_set; -/* int rv; */ - - struct timeval timeOut; - - chunk = xbt_malloc(msg_size); - - for (exp_sofar=0; exp_sofar < exp_size; exp_sofar += msg_size) { - for(msg_sofar=0; msg_sofar < msg_size; msg_sofar += res_last) { - - if(sender) { - res_last = send(peer->sd, chunk, msg_size - msg_sofar, 0); - } else { - res_last = 0; - FD_ZERO(&rd_set); - FD_SET(peer->sd,&rd_set); - timeOut.tv_sec = timeout; - timeOut.tv_usec = 0; - - if (0 < select(peer->sd+1,&rd_set,NULL,NULL,&timeOut)) - res_last = recv(peer->sd, chunk, msg_size-msg_sofar, 0); - - } - if (res_last == 0) { - /* No progress done, bail out */ - free(chunk); - RAISE0(unknown_error,"Not exchanged a single byte, bailing out"); - } - } - } - - free(chunk); - return no_error; -} -#endif - #ifdef HAVE_WINSOCK_H #define RETSTR( x ) case x: return #x diff --git a/src/gras/Transport/transport_private.h b/src/gras/Transport/transport_private.h index b578cd3ae3..dae72ff401 100644 --- a/src/gras/Transport/transport_private.h +++ b/src/gras/Transport/transport_private.h @@ -34,7 +34,7 @@ typedef struct gras_trp_bufdata_ gras_trp_bufdata_t; typedef struct s_gras_socket { - gras_trp_plugin_t *plugin; + gras_trp_plugin_t plugin; int incoming :1; /* true if we can read from this sock */ int outgoing :1; /* true if we can write on this sock */ @@ -58,12 +58,12 @@ void gras_trp_socket_new(int incomming, gras_socket_t *dst); /* The drivers */ -typedef xbt_error_t (*gras_trp_setup_t)(gras_trp_plugin_t *dst); +typedef xbt_error_t (*gras_trp_setup_t)(gras_trp_plugin_t dst); -xbt_error_t gras_trp_tcp_setup(gras_trp_plugin_t *plug); -xbt_error_t gras_trp_file_setup(gras_trp_plugin_t *plug); -xbt_error_t gras_trp_sg_setup(gras_trp_plugin_t *plug); -xbt_error_t gras_trp_buf_setup(gras_trp_plugin_t *plug); +xbt_error_t gras_trp_tcp_setup(gras_trp_plugin_t plug); +xbt_error_t gras_trp_file_setup(gras_trp_plugin_t plug); +xbt_error_t gras_trp_sg_setup(gras_trp_plugin_t plug); +xbt_error_t gras_trp_buf_setup(gras_trp_plugin_t plug); /*