gras_exit();
INFO0("Done.");
- return no_error;
+ return 0;
} /* end_of_server */
/* **********************************************************************
nobase_include_HEADERS = \
xbt/misc.h \
xbt/sysdep.h \
- xbt/asserts.h xbt/error.h xbt/ex.h \
+ xbt/asserts.h xbt/ex.h \
xbt/log.h \
xbt/module.h \
xbt/dynar.h xbt/dict.h xbt/set.h \
void amok_bw_init(void);
void amok_bw_exit(void);
-xbt_error_t amok_bw_test(gras_socket_t peer,
- unsigned long int buf_size,unsigned long int exp_size,unsigned long int msg_size,
- /*OUT*/ double *sec, double *bw);
+void amok_bw_test(gras_socket_t peer,
+ unsigned long int buf_size,unsigned long int exp_size,unsigned long int msg_size,
+ /*OUT*/ double *sec, double *bw);
-xbt_error_t amok_bw_request(const char* from_name,unsigned int from_port,
- const char* to_name,unsigned int to_port,
- unsigned long int bufSize,unsigned long int expSize,unsigned long int msgSize,
- /*OUT*/ double *sec, double*bw);
+void amok_bw_request(const char* from_name,unsigned int from_port,
+ const char* to_name,unsigned int to_port,
+ unsigned long int bufSize,unsigned long int expSize,unsigned long int msgSize,
+ /*OUT*/ double *sec, double*bw);
/** @} */
#if 0
* Ask the process 'from_name:from_port' to start to saturate the link between itself
* and to_name:to_name.
*/
-xbt_error_t grasbw_saturate_start(const char* from_name,unsigned int from_port,
+void grasbw_saturate_start(const char* from_name,unsigned int from_port,
const char* to_name,unsigned int to_port,
unsigned int msgSize, unsigned int timeout);
* Ask the process 'from_name:from_port' to stop saturating the link between itself
* and to_name:to_name.
*/
-xbt_error_t grasbw_saturate_stop(const char* from_name,unsigned int from_port,
+void grasbw_saturate_stop(const char* from_name,unsigned int from_port,
const char* to_name,unsigned int to_port);
* The common types used as payload in the messages and their definitions
* ****************************************************************************/
-/**
- * amok_remoterr_t:
- *
- * how to indicate an eventual error
- */
-
-typedef struct {
- char *msg;
- unsigned int code;
-} s_amok_remoterr_t,*amok_remoterr_t;
-
-amok_remoterr_t amok_remoterr_new(xbt_error_t errcode,
- const char* format, ...);
-amok_remoterr_t amok_remoterr_new_va(xbt_error_t param_errcode,
- const char* format,va_list ap);
-void amok_remoterr_free(amok_remoterr_t *err);
-
-
/**
* amok_result_t:
*
double value;
} amok_result_t;
-/**
- * amok_repport_error:
- *
- * Repports an error to the process listening on socket sock.
- *
- * The information will be embeeded in a message of type id, which must take a msgError_t as first
- * sequence (and SeqCount sequences in total). Other sequences beside the error one will be of
- * length 0.
- *
- * The message will be builded as sprintf would, using the given format and extra args.
- *
- * If the message cannot be builded and sent to recipient, the string severeError will be printed
- * on localhost's stderr.
- */
-void
-amok_repport_error (gras_socket_t sock, gras_msgtype_t msgtype,
- xbt_error_t errcode, const char* format,...);
-
-
void amok_base_init(void);
void amok_base_exit(void);
/* @{ */
-xbt_error_t
- gras_cbps_v_pop (gras_cbps_t ps,
- const char *name,
- /* OUT */ gras_datadesc_type_t *ddt,
- /* OUT */ void **res);
-xbt_error_t
-gras_cbps_v_push(gras_cbps_t ps,
- const char *name,
- void *data,
- gras_datadesc_type_t ddt);
-void
-gras_cbps_v_set (gras_cbps_t ps,
- const char *name,
- void *data,
- gras_datadesc_type_t ddt);
-
-void *
-gras_cbps_v_get (gras_cbps_t ps,
- const char *name,
- /* OUT */ gras_datadesc_type_t *ddt);
-
-void
-gras_cbps_block_begin(gras_cbps_t ps);
-void
-gras_cbps_block_end(gras_cbps_t ps);
+void gras_cbps_v_pop (gras_cbps_t ps,
+ const char *name,
+ /* OUT */ gras_datadesc_type_t *ddt,
+ /* OUT */ void **res);
+void gras_cbps_v_push(gras_cbps_t ps,
+ const char *name,
+ void *data,
+ gras_datadesc_type_t ddt);
+void gras_cbps_v_set (gras_cbps_t ps,
+ const char *name,
+ void *data,
+ gras_datadesc_type_t ddt);
+
+void * gras_cbps_v_get (gras_cbps_t ps,
+ const char *name,
+ /* OUT */ gras_datadesc_type_t *ddt);
+
+void gras_cbps_block_begin(gras_cbps_t ps);
+void gras_cbps_block_end(gras_cbps_t ps);
/* @} */
/* @} */
sizeof(structType) - offsetof(structType, lastMember) - \
sizeof(memberType) * repetitions
-xbt_error_t
+gras_datadesc_type_t
gras_datadesc_import_nws(const char *name,
const DataDescriptor *desc,
- unsigned long howmany,
- /* OUT */ gras_datadesc_type_t *dst);
+ unsigned long howmany);
END_DECL()
+++ /dev/null
-/* $Id$ */
-
-/* gras_bandwidth - GRAS mecanism to do Bandwidth tests between to hosts */
-
-/* Copyright (c) 2003, 2004 Martin Quinson. All rights reserved. */
-
-/* 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. */
-
-#ifndef GRAS_BANDWIDTH_H
-#define GRAS_BANDWIDTH_H
-
-#include <gras/modules/base.h>
-
-/* ****************************************************************************
- * The messages themselves
- * ****************************************************************************/
-
-#ifndef GRAS_BANDWIDTH_FIRST_MESSAGE
-#define GRAS_BANDWIDTH_FIRST_MESSAGE 0
-#endif
-
-#define GRASMSG_BW_REQUEST GRAS_BANDWIDTH_FIRST_MESSAGE
-#define GRASMSG_BW_RESULT GRAS_BANDWIDTH_FIRST_MESSAGE+1
-#define GRASMSG_BW_HANDSHAKE GRAS_BANDWIDTH_FIRST_MESSAGE+2
-#define GRASMSG_BW_HANDSHAKED GRAS_BANDWIDTH_FIRST_MESSAGE+3
-
-#define GRASMSG_SAT_START GRAS_BANDWIDTH_FIRST_MESSAGE+4
-#define GRASMSG_SAT_STARTED GRAS_BANDWIDTH_FIRST_MESSAGE+5
-#define GRASMSG_SAT_STOP GRAS_BANDWIDTH_FIRST_MESSAGE+6
-#define GRASMSG_SAT_STOPPED GRAS_BANDWIDTH_FIRST_MESSAGE+7
-
-#define GRASMSG_SAT_BEGIN GRAS_BANDWIDTH_FIRST_MESSAGE+8
-#define GRASMSG_SAT_BEGUN GRAS_BANDWIDTH_FIRST_MESSAGE+9
-#define GRASMSG_SAT_END GRAS_BANDWIDTH_FIRST_MESSAGE+10
-#define GRASMSG_SAT_ENDED GRAS_BANDWIDTH_FIRST_MESSAGE+11
-
-/* ****************************************************************************
- * The functions to triger those messages
- * ****************************************************************************/
-
-/**
- * grasbw_register_messages:
- *
- * Register all messages and callbacks needed for the current process to be ready
- * to do BW tests
- */
-xbt_error_t grasbw_register_messages(void);
-
-/* ***************************************************************************
- * Bandwidth tests
- * ***************************************************************************/
-/**
- * grasbw_test:
- * @to_name: Name of the host with which we should conduct the experiment
- * @to_port: port on which the peer process is listening (for message, do not
- * give a raw socket here. The needed raw socket will be negociated between
- * the peers)
- * @bufSize: Size of the socket buffer
- * @expSize: Total size of data sent across the network
- * @msgSize: Size of each message sent. Ie, (@expSize % @msgSize) messages will be sent.
- * @sec: where the result (in seconds) should be stored.
- * @bw: observed Bandwidth (in Mb/s)
- *
- * Conduct a bandwidth test from the local process to the given peer.
- * This call is blocking until the end of the experiment.
- */
-xbt_error_t grasbw_test(const char*to_name,unsigned int to_port,
- unsigned int bufSize,unsigned int expSize,unsigned int msgSize,
- /*OUT*/ double *sec, double*bw);
-
-/**
- * grasbw_request:
- * @from_name: Name of the host we are asking to do a experiment with (to_name:to_port)
- * @from_port: port on which the process we are asking for an experiment is listening for message
- * @to_name: Name of the host with which we should conduct the experiment
- * @to_port: port on which the peer process is listening (for message, do not
- * give a raw socket here. The needed raw socket will be negociated between
- * the peers)
- * @bufSize: Size of the socket buffer
- * @expSize: Total size of data sent across the network
- * @msgSize: Size of each message sent. Ie, (@expSize % @msgSize) messages will be sent.
- * @sec: where the result (in seconds) should be stored.
- * @bw: observed Bandwidth (in Mb/s)
- *
- * Conduct a bandwidth test from the process from_host:from_port to to_host:to_port.
- * This call is blocking until the end of the experiment.
- */
-xbt_error_t grasbw_request(const char* from_name,unsigned int from_port,
- const char* to_name,unsigned int to_port,
- unsigned int bufSize,unsigned int expSize,unsigned int msgSize,
- /*OUT*/ double *sec, double*bw);
-
-
-/* ***************************************************************************
- * Link saturation
- * ***************************************************************************/
-
-/**
- * grasbw_saturate_start:
- * @from_name: Name of the host we are asking to do a experiment with (to_name:to_port)
- * @from_port: port on which the process we are asking for an experiment is listening
- * (for message, do not give a raw socket here. The needed raw socket will be negociated
- * between the peers)
- * @to_name: Name of the host with which we should conduct the experiment
- * @to_port: port on which the peer process is listening for message
- * @msgSize: Size of each message sent.
- * @timeout: How long in maximum should be the saturation.
- *
- * Ask the process 'from_name:from_port' to start to saturate the link between itself
- * and to_name:to_name.
- */
-xbt_error_t grasbw_saturate_start(const char* from_name,unsigned int from_port,
- const char* to_name,unsigned int to_port,
- unsigned int msgSize, unsigned int timeout);
-
-/**
- * grasbw_saturate_stop:
- * @from_name: Name of the host we are asking to do a experiment with (to_name:to_port)
- * @from_port: port on which the process we are asking for an experiment is listening
- * (for message, do not give a raw socket here. The needed raw socket will be negociated
- * between the peers)
- * @to_name: Name of the host with which we should conduct the experiment
- * @to_port: port on which the peer process is listening for message
- *
- * Ask the process 'from_name:from_port' to stop saturating the link between itself
- * and to_name:to_name.
- */
-xbt_error_t grasbw_saturate_stop(const char* from_name,unsigned int from_port,
- const char* to_name,unsigned int to_port);
-
-
-
-#endif /* GRAS_BANDWIDTH_H */
+++ /dev/null
-/* $Id$ */
-
-/* gras_addons - several addons to do specific stuff not in GRAS itself */
-
-/* Copyright (c) 2003, 2004 Martin Quinson. All rights reserved. */
-
-/* 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. */
-
-#ifndef GRAS_ADDONS_H
-#define GRAS_ADDONS_H
-
-#include <gras.h>
-
-#define HOSTNAME_LEN 256
-#define ERRMSG_LEN 50
-
-/* ****************************************************************************
- * The common types used as payload in the messages and their definitions
- * ****************************************************************************/
-
-/**
- * msgHost_t:
- *
- * Description of an host
- */
-
-typedef struct {
- char host[HOSTNAME_LEN];
- unsigned int port;
-} msgHost_t;
-
-static const DataDescriptor msgHostDesc[] =
- { SIMPLE_MEMBER(CHAR_TYPE,HOSTNAME_LEN,offsetof(msgHost_t,host)),
- SIMPLE_MEMBER(UNSIGNED_INT_TYPE,1, offsetof(msgHost_t,port))};
-#define msgHostLen 2
-
-/**
- * msgError_t:
- *
- * how to indicate an eventual error
- */
-
-typedef struct {
- char errmsg[ERRMSG_LEN];
- unsigned int errcode;
-} msgError_t;
-
-static const DataDescriptor msgErrorDesc[] =
- { SIMPLE_MEMBER(CHAR_TYPE, ERRMSG_LEN,offsetof(msgError_t,errmsg)),
- SIMPLE_MEMBER(UNSIGNED_INT_TYPE, 1, offsetof(msgError_t,errcode))};
-#define msgErrorLen 2
-
-/**
- * msgResult_t:
- *
- * how to report the result of an experiment
- */
-
-typedef struct {
- unsigned int timestamp;
- double value;
-} msgResult_t;
-
-static const DataDescriptor msgResultDesc[] =
- { SIMPLE_MEMBER(UNSIGNED_INT_TYPE, 1, offsetof(msgResult_t,timestamp)),
- SIMPLE_MEMBER(DOUBLE_TYPE, 1, offsetof(msgResult_t,value))};
-#define msgResultLen 2
-
-/**
- * grasRepportError:
- *
- * Repports an error to the process listening on socket sock.
- *
- * The information will be embeeded in a message of type id, which must take a msgError_t as first
- * sequence (and SeqCount sequences in total). Other sequences beside the error one will be of
- * length 0.
- *
- * The message will be builded as sprintf would, using the given format and extra args.
- *
- * If the message cannot be builded and sent to recipient, the string severeError will be printed
- * on localhost's stderr.
- */
-void
-grasRepportError (gras_socket_t *sock, int id, int SeqCount,
- const char *severeError,
- xbt_error_t errcode, const char* format,...);
-
-#endif /* GRAS_ADDONS_H */
#ifndef GRAS_TRANSPORT_H
#define GRAS_TRANSPORT_H
-#include "xbt/error.h"
-
/** \addtogroup GRAS_sock
* \brief Socket handling (Communication facility).
*/
#include <xbt/misc.h>
#include <xbt/sysdep.h>
-#include <xbt/error.h>
#include <xbt/asserts.h>
#include <xbt/log.h>
#include "xbt/misc.h" /* BEGIN_DECL */
#include "xbt/dynar.h" /* void_f_pvoid_t */
-#include "xbt/error.h"
BEGIN_DECL()
#ifndef XBT_ERROR_H
#define XBT_ERROR_H
-//#error do not use this crap anymore
+#error do not use this crap anymore
#include "xbt/misc.h" /* BEGIN_DECL */
#include "xbt/log.h"
xbt_modinter.h gras_modinter.h \
\
xbt/sysdep.c \
- xbt/log.c xbt/log_default_appender.c xbt/error.c \
+ xbt/asserts.c \
+ xbt/log.c xbt/log_default_appender.c \
xbt/dynar.c \
xbt/dict.c xbt/dict_elm.c xbt/dict_cursor.c \
xbt/dict_multi.c \
*
* Results are reported in last args, and sizes are in kb.
*/
-xbt_error_t amok_bw_test(gras_socket_t peer,
- unsigned long int buf_size,
- unsigned long int exp_size,
- unsigned long int msg_size,
- /*OUT*/ double *sec, double *bw) {
+void amok_bw_test(gras_socket_t peer,
+ unsigned long int buf_size,
+ unsigned long int exp_size,
+ unsigned long int msg_size,
+ /*OUT*/ double *sec, double *bw) {
/* Measurement sockets for the experiments */
gras_socket_t measMasterIn=NULL,measIn,measOut;
int port;
- xbt_error_t errcode;
bw_request_t request,request_ack;
xbt_ex_t e;
DEBUG1("Got ACK; conduct the experiment (msg_size=%ld)",request->msg_size);
*sec=gras_os_time();
- gras_socket_meas_send(measOut,120,request->exp_size,request->msg_size);
- gras_socket_meas_recv(measIn,120,1,1);
-
- /*catch
- ERROR1("Error %s encountered while sending the BW experiment.",
- xbt_error_name(errcode));
+ TRY {
+ gras_socket_meas_send(measOut,120,request->exp_size,request->msg_size);
+ gras_socket_meas_recv(measIn,120,1,1);
+ } CATCH(e) {
gras_socket_close(measOut);
gras_socket_close(measMasterIn);
gras_socket_close(measIn);
- */
+ RETHROW0("Unable to conduct the experiment: %s");
+ }
*sec = gras_os_time() - *sec;
*bw = ((double)exp_size) / *sec;
gras_socket_close(measIn);
gras_socket_close(measMasterIn);
gras_socket_close(measOut);
- return errcode;
}
*
* Results are reported in last args, and sizes are in kb.
*/
-xbt_error_t amok_bw_request(const char* from_name,unsigned int from_port,
- const char* to_name,unsigned int to_port,
- unsigned long int buf_size,
- unsigned long int exp_size,
- unsigned long int msg_size,
- /*OUT*/ double *sec, double*bw) {
+void amok_bw_request(const char* from_name,unsigned int from_port,
+ const char* to_name,unsigned int to_port,
+ unsigned long int buf_size,
+ unsigned long int exp_size,
+ unsigned long int msg_size,
+ /*OUT*/ double *sec, double*bw) {
gras_socket_t sock;
/* The request */
gras_socket_close(sock);
free(result);
- return no_error;
}
int amok_bw_cb_bw_request(gras_socket_t expeditor,
free(result);
return 1;
-
-#if 0
- char* to_name=gras_msg_ctn(msg,0,0,msgHost_t).host;
- unsigned int to_port=gras_msg_ctn(msg,0,0,msgHost_t).port;
-
- unsigned int bufSize=gras_msg_ctn(msg,1,0,BwExp_t).bufSize;
- unsigned int expSize=gras_msg_ctn(msg,1,0,BwExp_t).expSize;
- unsigned int msgSize=gras_msg_ctn(msg,1,0,BwExp_t).msgSize;
- /* our answer */
- msgError_t *error;
- msgResult_t *res;
-
- if ((error->errcode=grasbw_test(to_name,to_port,bufSize,expSize,msgSize,
- &(res[0].value),&(res[1].value) ))) {
- fprintf(stderr,
- "%s:%d:grasbw_cbRequest: Error %s encountered while doing the test\n",
- __FILE__,__LINE__,xbt_error_name(error->errcode));
- strncpy(error->errmsg,"Error within grasbw_test",ERRMSG_LEN);
- gras_msg_new_and_send(msg->sock,GRASMSG_BW_RESULT,2,
- error,1,
- res,2);
- return 1;
- }
- res[0].timestamp = (unsigned int) gras_time();
- res[1].timestamp = (unsigned int) gras_time();
- gras_msg_new_and_send(msg->sock,GRASMSG_BW_RESULT,2,
- error,1,
- res,2);
- gras_msg_free(msg);
- return 1;
-#endif
}
int amok_bw_cb_sat_start(gras_socket_t expeditor,
CRITICAL0("amok_bw_cb_sat_begin: not implemented");
return 1;
}
-#if 0
-/* ***************************************************************************
- * Link saturation
- * ***************************************************************************/
-
-xbt_error_t grasbw_saturate_start(const char* from_name,unsigned int from_port,
- const char* to_name,unsigned int to_port,
- unsigned int msgSize, unsigned int timeout) {
- gras_sock_t *sock;
- xbt_error_t errcode;
- /* The request */
- SatExp_t *request;
- msgHost_t *target;
- /* answer */
- gras_msg_t *answer;
-
- if((errcode=gras_sock_client_open(from_name,from_port,&sock))) {
- fprintf(stderr,"%s:%d:saturate_start(): Error %s encountered while contacting peer\n",
- __FILE__,__LINE__,xbt_error_name(errcode));
- return errcode;
- }
- if (!(request=(SatExp_t *)malloc(sizeof(SatExp_t))) ||
- !(target=(msgHost_t*)malloc(sizeof(msgHost_t)))) {
- fprintf(stderr,"%s:%d:saturate_start(): Malloc error\n",__FILE__,__LINE__);
- gras_sock_close(sock);
- return malloc_error;
- }
-
- request->timeout=timeout;
- request->msgSize=msgSize;
-
- strcpy(target->host,to_name);
- target->port=to_port;
-
- if ((errcode=gras_msg_new_and_send(sock,GRASMSG_SAT_START, 2,
- target,1,
- request,1))) {
- fprintf(stderr,"%s:%d:saturate_start(): Error %s encountered while sending the request.\n",
- __FILE__,__LINE__,xbt_error_name(errcode));
- gras_sock_close(sock);
- return errcode;
- }
- if ((errcode=gras_msg_wait(120,GRASMSG_SAT_STARTED,&answer))) {
- fprintf(stderr,"%s:%d:saturate_start(): Error %s encountered while waiting for the ACK.\n",
- __FILE__,__LINE__,xbt_error_name(errcode));
- gras_sock_close(sock);
- return errcode;
- }
-
- if((errcode=gras_msg_ctn(answer,0,0,msgError_t).errcode)) {
- fprintf(stderr,"%s:%d:saturate_start(): Peer reported error %s (%s).\n",
- __FILE__,__LINE__,xbt_error_name(errcode),gras_msg_ctn(answer,0,0,msgError_t).errmsg);
- gras_msg_free(answer);
- gras_sock_close(sock);
- return errcode;
- }
-
- gras_msg_free(answer);
- gras_sock_close(sock);
- return no_error;
-}
-
-int grasbw_cbSatStart(gras_msg_t *msg) {
- gras_rawsock_t *raw;
- gras_sock_t *sock;
- xbt_error_t errcode;
- double start; /* time to timeout */
-
- /* specification of the test to run */
- char* to_name=gras_msg_ctn(msg,0,0,msgHost_t).host;
- unsigned int to_port=gras_msg_ctn(msg,0,0,msgHost_t).port;
-
- unsigned int msgSize=gras_msg_ctn(msg,1,0,SatExp_t).msgSize;
- unsigned int timeout=gras_msg_ctn(msg,1,0,SatExp_t).timeout;
- unsigned int raw_port;
-
- /* The request */
- SatExp_t *request;
- /* answer */
- gras_msg_t *answer;
-
- /*
- fprintf(stderr,"grasbw_cbSatStart(sd=%p)\n",msg->sock);
- fprintf(stderr,"(server=%d,raw=%d,fromPID=%d,toPID=%d,toHost=%p,toPort=%d,toChan=%d)\n",
- msg->sock->server_sock,msg->sock->raw_sock,msg->sock->from_PID,
- msg->sock->to_PID,msg->sock->to_host,msg->sock->to_port,msg->sock->to_chan);
- */
-
- /* Negociate the saturation with the peer */
- if((errcode=gras_sock_client_open(to_name,to_port,&sock))) {
- fprintf(stderr,"cbSatStart(): Error %s encountered while contacting peer\n",
- xbt_error_name(errcode));
- grasRepportError(msg->sock,GRASMSG_SAT_STARTED,1,
- "cbSatStart: Severe error: Cannot send error status to requester!!\n",
- errcode,"Cannot contact peer.\n");
- return 1;
- }
- if (!(request=(SatExp_t *)malloc(sizeof(SatExp_t)))) {
- fprintf(stderr,"cbSatStart(): Malloc error\n");
- gras_sock_close(sock);
- grasRepportError(msg->sock,GRASMSG_SAT_STARTED,1,
- "cbSatStart: Severe error: Cannot send error status to requester!!\n",
- malloc_error,"Cannot build request.\n");
- return 1;
- }
-
- request->timeout=gras_msg_ctn(msg,1,0,SatExp_t).timeout;
- request->msgSize=gras_msg_ctn(msg,1,0,SatExp_t).msgSize;
-
- if ((errcode=gras_msg_new_and_send(sock,GRASMSG_SAT_BEGIN, 1,
- request,1))) {
- fprintf(stderr,"cbSatStart(): Error %s encountered while sending the request.\n",
- xbt_error_name(errcode));
- grasRepportError(msg->sock,GRASMSG_SAT_STARTED,1,
- "cbSatStart: Severe error: Cannot send error status to requester!!\n",
- errcode,"Cannot send request.\n");
- gras_sock_close(sock);
- return 1;
- }
-
- if ((errcode=gras_msg_wait(120,GRASMSG_SAT_BEGUN,&answer))) {
- fprintf(stderr,"cbSatStart(): Error %s encountered while waiting for the ACK.\n",
- xbt_error_name(errcode));
- gras_sock_close(sock);
-
- grasRepportError(msg->sock,GRASMSG_SAT_STARTED,1,
- "cbSatStart: Severe error: Cannot send error status to requester!!\n",
- errcode,
- "Cannot receive the ACK.\n");
- return 1;
- }
-
- if((errcode=gras_msg_ctn(answer,0,0,msgError_t).errcode)) {
- fprintf(stderr,"cbSatStart(): Peer reported error %s (%s).\n",
- xbt_error_name(errcode),gras_msg_ctn(answer,0,0,msgError_t).errmsg);
-
- grasRepportError(msg->sock,GRASMSG_SAT_STARTED,1,
- "cbSatStart: Severe error: Cannot send error status to requester!!\n",
- errcode,
- "Peer repported '%s'.\n",gras_msg_ctn(answer,0,0,msgError_t).errmsg);
- gras_msg_free(answer);
- gras_sock_close(sock);
- return 1;
- }
-
- raw_port=gras_msg_ctn(answer,1,0,SatExp_t).port;
-
- if ((errcode=gras_rawsock_client_open(to_name,raw_port,msgSize,&raw))) {
- fprintf(stderr,"cbSatStart(): Error %s while opening raw socket to %s:%d.\n",
- xbt_error_name(errcode),to_name,gras_msg_ctn(answer,1,0,SatExp_t).port);
-
- grasRepportError(msg->sock,GRASMSG_SAT_STARTED,1,
- "cbSatStart: Severe error: Cannot send error status to requester!!\n",
- errcode,"Cannot open raw socket.\n");
- gras_sock_close(sock);
- return 1;
- }
-
- /* send a train of data before repporting that XP is started */
- if ((errcode=gras_rawsock_send(raw,msgSize,msgSize))) {
- fprintf(stderr,"cbSatStart: Failure %s during raw send\n",xbt_error_name(errcode));
- grasRepportError(msg->sock,GRASMSG_SAT_STARTED,1,
- "cbSatStart: Severe error: Cannot send error status to requester!!\n",
- errcode,"Cannot raw send.\n");
- gras_sock_close(sock);
- gras_rawsock_close(raw);
- return 1;
- }
-
- grasRepportError(msg->sock,GRASMSG_SAT_STARTED,1,
- "cbSatStart: Severe error: Cannot send error status to requester!!\n",
- no_error,"Saturation started");
- gras_msg_free(answer);
- gras_msg_free(msg);
-
- /* Do the saturation until we get a SAT_STOP message or until we timeout the whole XP*/
- start=gras_time();
- while (gras_msg_wait(0,GRASMSG_SAT_STOP,&msg)==timeout_error &&
- gras_time()-start < timeout) {
- if ((errcode=gras_rawsock_send(raw,msgSize,msgSize))) {
- fprintf(stderr,"cbSatStart: Failure %s during raw send\n",xbt_error_name(errcode));
- /* our error message do not interess anyone. SAT_STOP will do nothing. */
- gras_sock_close(sock);
- gras_rawsock_close(raw);
- return 1;
- }
- }
- if (gras_time()-start > timeout) {
- fprintf(stderr,"The saturation experiment did timeout. Stop it NOW\n");
- gras_sock_close(sock);
- gras_rawsock_close(raw);
- return 1;
- }
-
- /* Handle the SAT_STOP which broke the previous while */
-
- if ((errcode=gras_msg_new_and_send(sock, GRASMSG_SAT_END,0))) {
- fprintf(stderr,"cbSatStart(): Cannot tell peer to stop saturation\n");
-
- grasRepportError(msg->sock,GRASMSG_SAT_STOPPED,1,
- "cbSatStart: Severe error: Cannot send error status to requester!!\n",
- errcode,"Sending SAT_END to peer failed.\n");
- gras_sock_close(sock);
- gras_rawsock_close(raw);
- return 1;
- }
-
- if ((errcode=gras_msg_wait(60,GRASMSG_SAT_ENDED,&answer))) {
- fprintf(stderr,"cbSatStart(): Peer didn't ACK the end\n");
-
- grasRepportError(msg->sock,GRASMSG_SAT_STOPPED,1,
- "cbSatStart: Severe error: Cannot send error status to requester!!\n",
- errcode,"Receiving SAT_ENDED from peer failed.\n");
- gras_sock_close(sock);
- gras_rawsock_close(raw);
- return 1;
- }
- grasRepportError(msg->sock,GRASMSG_SAT_STOPPED,1,
- "cbSatStart: Severe error: Cannot send error status to requester!!\n",
- no_error,"");
-
- gras_sock_close(sock);
- gras_rawsock_close(raw);
- gras_msg_free(answer);
- gras_msg_free(msg);
-
- return 1;
-}
-
-int grasbw_cbSatBegin(gras_msg_t *msg) {
- gras_rawsock_t *raw;
- xbt_error_t errcode;
- double start; /* timer */
- /* request */
- unsigned int msgSize=gras_msg_ctn(msg,0,0,SatExp_t).msgSize;
- unsigned int timeout=gras_msg_ctn(msg,0,0,SatExp_t).timeout;
- /* answer */
- SatExp_t *request;
- msgError_t *error;
-
- if (!(request=(SatExp_t*)malloc(sizeof(SatExp_t))) ||
- !(error=(msgError_t *)malloc(sizeof(msgError_t)))) {
- fprintf(stderr,"cbSatBegin(): Malloc error\n");
- grasRepportError(msg->sock,GRASMSG_SAT_BEGUN,2,
- "cbSatBegin: Severe error: Cannot send error status to requester!!\n",
- malloc_error,"Malloc error");
- return 1;
- }
-
- if ((errcode=gras_rawsock_server_open(6666,8000,msgSize,&raw))) {
- fprintf(stderr,"cbSatBegin(): Error %s encountered while opening a raw socket\n",
- xbt_error_name(errcode));
- grasRepportError(msg->sock,GRASMSG_SAT_BEGUN,2,
- "cbSatBegin: Severe error: Cannot send error status to requester!!\n",
- errcode,"Cannot open raw socket");
- return 1;
- }
- request->port=gras_rawsock_get_peer_port(raw);
- request->msgSize=msgSize;
- error->errcode=no_error;
- error->errmsg[0]='\0';
- if ((errcode=gras_msg_new_and_send(msg->sock,GRASMSG_SAT_BEGUN,2,
- error,1,
- request,1))) {
- fprintf(stderr,"cbSatBegin(): Error %s encountered while send ACK to peer\n",
- xbt_error_name(errcode));
- return 1;
- }
- gras_msg_free(msg);
-
- start=gras_time();
- while (gras_msg_wait(0,GRASMSG_SAT_END,&msg)==timeout_error &&
- gras_time() - start < timeout) {
- errcode=gras_rawsock_recv(raw,msgSize,msgSize,1);
- if (errcode != timeout_error && errcode != no_error) {
- fprintf(stderr,"cbSatBegin: Failure %s during raw receive\n",xbt_error_name(errcode));
- /* our error message do not interess anyone. SAT_END will do nothing. */
- /* (if timeout'ed, it may be because the sender stopped emission. so survive it) */
- return 1;
- }
- }
- if (gras_time()-start > timeout) {
- fprintf(stderr,"The saturation experiment did timeout. Stop it NOW.\n");
- gras_rawsock_close(raw);
- return 1;
- }
-
- grasRepportError(msg->sock,GRASMSG_SAT_ENDED,1,
- "cbSatBegin: Cannot send SAT_ENDED.\n",
- no_error,"");
- gras_rawsock_close(raw);
- gras_msg_free(msg);
- return 1;
-}
-
-xbt_error_t grasbw_saturate_stop(const char* from_name,unsigned int from_port,
- const char* to_name,unsigned int to_port) {
- xbt_error_t errcode;
- gras_sock_t *sock;
- gras_msg_t *answer;
-
- if((errcode=gras_sock_client_open(from_name,from_port,&sock))) {
- fprintf(stderr,"saturate_stop(): Error %s encountered while contacting peer\n",
- xbt_error_name(errcode));
- return errcode;
- }
-
- if ((errcode=gras_msg_new_and_send(sock,GRASMSG_SAT_STOP,0))) {
- fprintf(stderr,"saturate_stop(): Error %s encountered while sending request\n",
- xbt_error_name(errcode));
- gras_sock_close(sock);
- return errcode;
- }
-
- if ((errcode=gras_msg_wait(120,GRASMSG_SAT_STOPPED,&answer))) {
- fprintf(stderr,"saturate_stop(): Error %s encountered while receiving ACK\n",
- xbt_error_name(errcode));
- gras_sock_close(sock);
- return errcode;
- }
-
- if((errcode=gras_msg_ctn(answer,0,0,msgError_t).errcode)) {
- fprintf(stderr,"saturate_stop(): Peer reported error %s (%s).\n",
- xbt_error_name(errcode),gras_msg_ctn(answer,0,0,msgError_t).errmsg);
- gras_msg_free(answer);
- gras_sock_close(sock);
- return errcode;
- }
-
- gras_msg_free(answer);
- gras_sock_close(sock);
-
- return no_error;
-}
-#endif
* if err.msg != NULL, it wasn't sucessful. Check err.msg and err.code to see why.
*/
typedef struct {
- s_amok_remoterr_t err;
unsigned int timestamp;
double sec;
double bw;
XBT_LOG_NEW_SUBCATEGORY(amok,XBT_LOG_ROOT_CAT,"All AMOK categories");
-amok_remoterr_t amok_remoterr_new(xbt_error_t param_errcode,
- const char* format,...) {
-
- amok_remoterr_t res;
-
- va_list ap;
- va_start(ap,format);
- res = amok_remoterr_new_va(param_errcode,format,ap);
- va_end(ap);
- return res;
-}
-
-amok_remoterr_t amok_remoterr_new_va(xbt_error_t param_errcode,
- const char* format,va_list ap) {
- amok_remoterr_t res=xbt_new(s_amok_remoterr_t,1);
- res->code=param_errcode;
- if (format) {
- res->msg=(char*)xbt_malloc(1024);
- vsnprintf(res->msg,1024,format,ap);
- } else {
- res->msg = NULL;
- }
-
- return res;
-}
-
-void amok_remoterr_free(amok_remoterr_t *err) {
- if (err && *err) {
- if ((*err)->msg) free((*err)->msg);
- free(*err);
- err=NULL;
- }
-}
-
-
-void
-amok_repport_error (gras_socket_t sock, gras_msgtype_t msgtype,
- xbt_error_t param_errcode, const char* format,...) {
- amok_remoterr_t error;
- va_list ap;
-
- error=xbt_new(s_amok_remoterr_t,1);
- error->code=param_errcode;
- error->msg=(char*)xbt_malloc(1024); /* FIXME */
- va_start(ap,format);
- vsnprintf(error->msg,1024,format,ap);
- va_end(ap);
-
- gras_msg_send(sock,msgtype,error);
- /* FIXME: error handling while error reporting :-/
- if (errcode != no_error) {
- CRITICAL4("Error '%s' while reporting error '%s' to %s:%d",
- xbt_error_name(errcode),error->msg,
- gras_socket_peer_name(sock),gras_socket_peer_port(sock) );
- }
- */
-}
-
void amok_base_init(void) {
gras_datadesc_type_t host_desc, remoterr_desc;
/* Access function */
int gras_datadesc_size(gras_datadesc_type_t type);
/* Described data exchanges: direct use */
-xbt_error_t gras_datadesc_cpy(gras_datadesc_type_t type, void *src, void **dst);
+void gras_datadesc_cpy(gras_datadesc_type_t type, void *src, void **dst);
void gras_datadesc_send(gras_socket_t sock, gras_datadesc_type_t type, void *src);
void gras_datadesc_recv(gras_socket_t sock, gras_datadesc_type_t type,
int r_arch, void *dst);
-/* Described data exchanges: IDL compilation */
-xbt_error_t gras_datadesc_gen_cpy(gras_datadesc_type_t type, void *src, void **dst);
-xbt_error_t gras_datadesc_gen_send(gras_socket_t sock, gras_datadesc_type_t type, void *src);
-xbt_error_t gras_datadesc_gen_recv(gras_socket_t sock, gras_datadesc_type_t type,
+/* Described data exchanges: IDL compilation FIXME: not implemented*/
+void gras_datadesc_gen_cpy(gras_datadesc_type_t type, void *src, void **dst);
+void gras_datadesc_gen_send(gras_socket_t sock, gras_datadesc_type_t type, void *src);
+void gras_datadesc_gen_recv(gras_socket_t sock, gras_datadesc_type_t type,
int r_arch, void *dst);
#include "xbt/sysdep.h"
#include "xbt/log.h"
-#include "xbt/error.h"
#include "xbt/dynar.h"
#include "xbt/dict.h"
#include "xbt/set.h"
/***************
* Convertions *
***************/
-xbt_error_t
+void
gras_dd_convert_elm(gras_datadesc_type_t type, int count,
int r_arch,
void *src, void *dst);
* The data to be converted is stored in @src, and is to be stored in @dst.
* Both pointers may be the same location if no resizing is needed.
*/
-xbt_error_t
+void
gras_dd_convert_elm(gras_datadesc_type_t type, int count,
int r_arch,
void *src, void *dst) {
}
}
- return no_error;
}
static void
static _XBT_INLINE void gras_dd_send_int(gras_socket_t sock, int i);
static _XBT_INLINE void gras_dd_recv_int(gras_socket_t sock, int r_arch, int *i);
-static _XBT_INLINE xbt_error_t
+static _XBT_INLINE void
gras_dd_alloc_ref(xbt_dict_t refs, long int size,
char **r_ref, long int r_len,
char **l_ref, int detect_cycle);
return 1;
}
-static _XBT_INLINE xbt_error_t
+static _XBT_INLINE void
gras_dd_alloc_ref(xbt_dict_t refs,
long int size,
char **r_ref,
if (detect_cycle)
xbt_dict_set_ext(refs,(const char *) r_ref, r_len, ptr, free);
}
- return no_error;
}
/**
* to a new location, and store a pointer to it in dst.
*
*/
-xbt_error_t gras_datadesc_cpy(gras_datadesc_type_t type,
- void *src,
- void **dst) {
+void gras_datadesc_cpy(gras_datadesc_type_t type,
+ void *src,
+ void **dst) {
THROW_UNIMPLEMENTED;
}
}
}
-#if 0
-/***
- *** IDL compiling functions
- ***/
-
-#define gras_datadesc_send_rec foo /* Just to make sure the copypast was ok */
-#define gras_datadesc_send foo /* Just to make sure the copypast was ok */
-#define gras_datadesc_recv_rec foo /* Just to make sure the copypast was ok */
-#define gras_datadesc_recv foo /* Just to make sure the copypast was ok */
-
-static xbt_error_t
-gras_datadesc_gen_send_rec(gras_socket_t sock,
- gras_cbps_t state,
- xbt_dict_t refs,
- gras_datadesc_type_t type,
- char *data,
- int detect_cycle) {
-
- xbt_error_t errcode;
- int cpt;
- gras_datadesc_type_t sub_type; /* type on which we recurse */
-
- printf(" VERB2(\"Send a %s (%s)\");\n",
- type->name, gras_datadesc_cat_names[type->category_code]);
-
- xbt_assert0(!type->send, "Callbacks not implemented in IDL compiler");
-
- switch (type->category_code) {
- case e_gras_datadesc_type_cat_scalar:
- printf(" TRYOLD(gras_trp_chunk_send(sock, data, %lu));\n",type->size[GRAS_THISARCH]);
- break;
-
- case e_gras_datadesc_type_cat_struct: {
- gras_dd_cat_struct_t struct_data;
- gras_dd_cat_field_t field;
- char *field_data;
-
- struct_data = type->category.struct_data;
- xbt_assert1(struct_data.closed,
- "Please call gras_datadesc_declare_struct_close on %s before sending it",
- type->name);
- printf(" VERB1(\">> Send all fields of the structure %s\");\n",type->name);
- xbt_dynar_foreach(struct_data.fields, cpt, field) {
- field_data = data;
- field_data += field->offset[GRAS_THISARCH];
-
- sub_type = field->type;
-
- xbt_assert0(!field->send, "Callbacks not implemented in IDL compiler");
-
- printf(" VERB1(\"Send field %s\");\n",field->name);
- printf(" data += %lu;\n",field->offset[GRAS_THISARCH]);
- TRYOLD(gras_datadesc_gen_send_rec(sock,state,refs,sub_type, field_data,
- detect_cycle || sub_type->cycle));
- printf(" data -= %lu;\n",field->offset[GRAS_THISARCH]);
-
- xbt_assert0(!field->recv, "Callbacks not implemented in IDL compiler");
- }
- printf(" VERB1(\"<< Sent all fields of the structure %s\"", type->name);
-
- break;
- }
-
- case e_gras_datadesc_type_cat_union: {
- gras_dd_cat_union_t union_data;
- gras_dd_cat_field_t field=NULL;
- int field_num;
-
- union_data = type->category.union_data;
-
- xbt_assert1(union_data.closed,
- "Please call gras_datadesc_declare_union_close on %s before sending it",
- type->name);
- /* retrieve the field number */
- printf(" field_num = union_data.selector(state, data);\n");
-
- printf(" xbt_assert0(field_num > 0,\n");
- printf(" \"union field selector of %s gave a negative value\");\n",type->name);
-
- printf(" xbt_assert3(field_num < xbt_dynar_length(union_data.fields),\n");
- printf(" \"union field selector of %s returned %%d but there is only %lu fields\",field_num);\n",
- type->name, xbt_dynar_length(union_data.fields));
-
- /* Send the field number */
- printf("TRYOLD(gras_dd_send_int(sock, field_num));\n");
-
- /* Send the content */
- field = xbt_dynar_get_as(union_data.fields, field_num, gras_dd_cat_field_t);
- sub_type = field->type;
-
- if (field->send)
- field->send(state,data);
-
- TRYOLD(gras_datadesc_gen_send_rec(sock,state,refs, sub_type, data,
- detect_cycle || sub_type->cycle));
-
- break;
- }
-
- case e_gras_datadesc_type_cat_ref: {
- gras_dd_cat_ref_t ref_data;
-
- void **ref=(void**)data;
- void *dummy;
-
- ref_data = type->category.ref_data;
-
- /* Detect the referenced type and send it to peer if needed */
- sub_type = ref_data.type;
- if (sub_type == NULL) {
- sub_type = (*ref_data.selector)(state,data);
- TRYOLD(gras_dd_send_int(sock, sub_type->code));
- }
-
- /* Send the actual value of the pointer for cycle handling */
- if (!pointer_type) {
- pointer_type = gras_datadesc_by_name("data pointer");
- xbt_assert(pointer_type);
- }
-
- TRYOLD(gras_trp_chunk_send(sock, (char*)data,
- pointer_type->size[GRAS_THISARCH]));
-
- /* Send the pointed data only if not already sent */
- if (*(void**)data == NULL) {
- VERB0("Not sending NULL referenced data");
- break;
- }
- errcode = detect_cycle
- ? xbt_dict_get_ext(refs,(char*)ref, sizeof(void*), &dummy)
- : mismatch_error;
- if (errcode == mismatch_error) {
- VERB1("Sending data referenced at %p", (void*)*ref);
- if (detect_cycle)
- xbt_dict_set_ext(refs, (char*)ref, sizeof(void*), ref, NULL);
- TRYOLD(gras_datadesc_gen_send_rec(sock,state,refs, sub_type, *ref,
- detect_cycle || sub_type->cycle));
-
- } else if (errcode == no_error) {
- VERB1("Not sending data referenced at %p (already done)", (void*)*ref);
- } else {
- return errcode;
- }
-
- break;
- }
-
- case e_gras_datadesc_type_cat_array: {
- gras_dd_cat_array_t array_data;
- long int count;
- char *ptr=data;
- long int elm_size;
-
- array_data = type->category.array_data;
-
- /* determine and send the element count */
- count = array_data.fixed_size;
- if (count == 0) {
- count = array_data.dynamic_size(state,data);
- xbt_assert1(count >=0,
- "Invalid (negative) array size for type %s",type->name);
- TRYOLD(gras_dd_send_int(sock, count));
- }
-
- /* send the content */
- sub_type = array_data.type;
- elm_size = sub_type->aligned_size[GRAS_THISARCH];
- if (sub_type->category_code == e_gras_datadesc_type_cat_scalar) {
- VERB1("Array of %ld scalars, send it in one shot",count);
- TRYOLD(gras_trp_chunk_send(sock, data,
- sub_type->aligned_size[GRAS_THISARCH] * count));
- } else if (sub_type->category_code == e_gras_datadesc_type_cat_array &&
- sub_type->category.array_data.fixed_size > 0 &&
- sub_type->category.array_data.type->category_code == e_gras_datadesc_type_cat_scalar) {
-
- VERB1("Array of %ld fixed array of scalars, send it in one shot",count);
- TRYOLD(gras_trp_chunk_send(sock, data,
- sub_type->category.array_data.type->aligned_size[GRAS_THISARCH]
- * count * sub_type->category.array_data.fixed_size));
-
- } else {
- for (cpt=0; cpt<count; cpt++) {
- TRYOLD(gras_datadesc_gen_send_rec(sock,state,refs, sub_type, ptr,
- detect_cycle || sub_type->cycle));
- ptr += elm_size;
- }
- }
- break;
- }
-
- default:
- xbt_assert0(0, "Invalid type");
- }
-
- return no_error;
-}
-
-/**
- * gras_datadesc_gen_send:
- *
- * Copy the data pointed by src and described by type to the socket
- *
- */
-xbt_error_t gras_datadesc_gen_send(gras_socket_t sock,
- gras_datadesc_type_t type,
- void *src) {
-
- xbt_error_t errcode;
- gras_cbps_t state;
- xbt_dict_t refs; /* all references already sent */
-
- refs = xbt_dict_new();
- state = gras_cbps_new();
-
- printf("xbt_error_t gras_%s_send(gras_socket_t sock,void *dst){\n",
- type->name);
- errcode = gras_datadesc_gen_send_rec(sock,state,refs,type,(char*)src,
- detect_cycle || sub_type->cycle);
- printf("}\n");
-
- xbt_dict_free(&refs);
- gras_cbps_free(&state);
-
- return errcode;
-}
-
-/**
- * gras_datadesc_gen_recv_rec:
- *
- * Do the data reception job recursively.
- *
- * subsize used only to deal with vicious case of reference to dynamic array.
- * This size is needed at the reference reception level (to allocate enough
- * space) and at the array reception level (to fill enough room).
- *
- * Having this size passed as an argument of the recursive function is a crude
- * hack, but I was told that working code is sometimes better than neat one ;)
- */
-static xbt_error_t
-gras_datadesc_gen_recv_rec(gras_socket_t sock,
- gras_cbps_t state,
- xbt_dict_t refs,
- gras_datadesc_type_t type,
- int r_arch,
- char **r_data,
- long int r_lgr,
- char *l_data,
- int subsize,
- int detect_cycle) {
-
- xbt_error_t errcode;
- int cpt;
- gras_datadesc_type_t sub_type;
-
- VERB2("Recv a %s @%p", type->name, (void*)l_data);
- xbt_assert(l_data);
-
- switch (type->category_code) {
- case e_gras_datadesc_type_cat_scalar:
- if (type->size[GRAS_THISARCH] == type->size[r_arch]) {
- TRYOLD(gras_trp_chunk_recv(sock, (char*)l_data, type->size[r_arch]));
- if (r_arch != GRAS_THISARCH)
- TRYOLD(gras_dd_convert_elm(type,1,r_arch, l_data,l_data));
- } else {
- void *ptr = xbt_malloc(type->size[r_arch]);
-
- TRYOLD(gras_trp_chunk_recv(sock, (char*)ptr, type->size[r_arch]));
- if (r_arch != GRAS_THISARCH)
- TRYOLD(gras_dd_convert_elm(type,1,r_arch, ptr,l_data));
- free(ptr);
- }
- break;
-
- case e_gras_datadesc_type_cat_struct: {
- gras_dd_cat_struct_t struct_data;
- gras_dd_cat_field_t field;
-
- struct_data = type->category.struct_data;
-
- xbt_assert1(struct_data.closed,
- "Please call gras_datadesc_declare_struct_close on %s before receiving it",
- type->name);
- VERB1(">> Receive all fields of the structure %s",type->name);
- xbt_dynar_foreach(struct_data.fields, cpt, field) {
- char *field_data = l_data + field->offset[GRAS_THISARCH];
-
- sub_type = field->type;
-
- TRYOLD(gras_datadesc_gen_recv_rec(sock,state,refs, sub_type,
- r_arch,NULL,0,
- field_data,-1,
- detect_cycle || sub_type->cycle));
- if (field->recv)
- field->recv(type,state,data);
-
- }
- VERB1("<< Received all fields of the structure %s", type->name);
-
- break;
- }
-
- case e_gras_datadesc_type_cat_union: {
- gras_dd_cat_union_t union_data;
- gras_dd_cat_field_t field=NULL;
- int field_num;
-
- union_data = type->category.union_data;
-
- xbt_assert1(union_data.closed,
- "Please call gras_datadesc_declare_union_close on %s before receiving it",
- type->name);
- /* retrieve the field number */
- TRYOLD(gras_dd_recv_int(sock, r_arch, &field_num));
- if (field_num < 0)
- RAISE1(mismatch_error,
- "Received union field for %s is negative", type->name);
- if (field_num < xbt_dynar_length(union_data.fields))
- RAISE3(mismatch_error,
- "Received union field for %s is %d but there is only %lu fields",
- type->name, field_num, xbt_dynar_length(union_data.fields));
-
- /* Recv the content */
- field = xbt_dynar_get_as(union_data.fields, field_num, gras_dd_cat_field_t);
- sub_type = field->type;
-
- TRYOLD(gras_datadesc_gen_recv_rec(sock,state,refs, sub_type,
- r_arch,NULL,0,
- l_data,-1,
- detect_cycle || sub_type->cycle));
- if (field->recv)
- field->recv(type,state,data);
-
- break;
- }
-
- case e_gras_datadesc_type_cat_ref: {
- char **r_ref = NULL;
- char **l_ref = NULL;
- gras_dd_cat_ref_t ref_data;
-
- ref_data = type->category.ref_data;
-
- /* Get the referenced type locally or from peer */
- sub_type = ref_data.type;
- if (sub_type == NULL) {
- int ref_code;
- TRYOLD(gras_dd_recv_int(sock, r_arch, &ref_code));
- TRYOLD(gras_datadesc_by_id(ref_code, &sub_type));
- }
-
- /* Get the actual value of the pointer for cycle handling */
- if (!pointer_type) {
- pointer_type = gras_datadesc_by_name("data pointer");
- xbt_assert(pointer_type);
- }
-
- r_ref = xbt_malloc(pointer_type->size[r_arch]);
-
- TRYOLD(gras_trp_chunk_recv(sock, (char*)r_ref,
- pointer_type->size[r_arch]));
-
- /* Receive the pointed data only if not already sent */
- if (gras_dd_is_r_null(r_ref, pointer_type->size[r_arch])) {
- VERB1("Not receiving data remotely referenced @%p since it's NULL",
- *(void **)r_ref);
- *(void**)l_data = NULL;
- free(r_ref);
- break;
- }
-
- errcode = detect_cycle
- ? xbt_dict_get_ext(refs,
- (char*)r_ref, pointer_type->size[r_arch],
- (void**)&l_ref)
- : mismatch_error;
-
- if (errcode == mismatch_error) {
- int subsubcount = 0;
- void *l_referenced=NULL;
-
- VERB2("Receiving a ref to '%s', remotely @%p",
- sub_type->name, *(void**)r_ref);
- if (sub_type->category_code == e_gras_datadesc_type_cat_array) {
- /* Damn. Reference to a dynamic array. Allocating the size for it
- is more complicated */
- gras_dd_cat_array_t array_data = sub_type->category.array_data;
- gras_datadesc_type_t subsub_type;
-
- subsubcount = array_data.fixed_size;
- if (subsubcount == 0)
- TRYOLD(gras_dd_recv_int(sock, r_arch, &subsubcount));
-
- subsub_type = array_data.type;
-
-
- TRYOLD(gras_dd_alloc_ref(refs,
- subsub_type->size[GRAS_THISARCH] * subsubcount,
- r_ref,pointer_type->size[r_arch],
- (char**)&l_referenced,
- detect_cycle));
- } else {
- TRYOLD(gras_dd_alloc_ref(refs,sub_type->size[GRAS_THISARCH],
- r_ref,pointer_type->size[r_arch],
- (char**)&l_referenced,
- detect_cycle));
- }
-
- TRYOLD(gras_datadesc_gen_recv_rec(sock,state,refs, sub_type,
- r_arch,r_ref,pointer_type->size[r_arch],
- (char*)l_referenced, subsubcount,
- detect_cycle || sub_type->cycle));
-
- *(void**)l_data=l_referenced;
- VERB3("'%s' remotely referenced at %p locally at %p",
- sub_type->name, *(void**)r_ref, l_referenced);
-
- } else if (errcode == no_error) {
- VERB2("NOT receiving data remotely referenced @%p (already done, @%p here)",
- *(void**)r_ref, *(void**)l_ref);
-
- *(void**)l_data=*l_ref;
-
- } else {
- return errcode;
- }
- free(r_ref);
- break;
- }
-
- case e_gras_datadesc_type_cat_array: {
- gras_dd_cat_array_t array_data;
- int count;
- char *ptr;
- long int elm_size;
-
- array_data = type->category.array_data;
- /* determine element count locally, or from caller, or from peer */
- count = array_data.fixed_size;
- if (count == 0)
- count = subsize;
- if (count == 0)
- TRYOLD(gras_dd_recv_int(sock, r_arch, &count));
- if (count == 0)
- RAISE1(mismatch_error,
- "Invalid (=0) array size for type %s",type->name);
-
- /* receive the content */
- sub_type = array_data.type;
- if (sub_type->category_code == e_gras_datadesc_type_cat_scalar) {
- VERB1("Array of %d scalars, get it in one shoot", count);
- if (sub_type->aligned_size[GRAS_THISARCH] >=
- sub_type->aligned_size[r_arch]) {
- TRYOLD(gras_trp_chunk_recv(sock, (char*)l_data,
- sub_type->aligned_size[r_arch] * count));
- if (r_arch != GRAS_THISARCH)
- TRYOLD(gras_dd_convert_elm(sub_type,count,r_arch, l_data,l_data));
- } else {
- ptr = xbt_malloc(sub_type->aligned_size[r_arch] * count);
-
- TRYOLD(gras_trp_chunk_recv(sock, (char*)ptr,
- sub_type->size[r_arch] * count));
- if (r_arch != GRAS_THISARCH)
- TRYOLD(gras_dd_convert_elm(sub_type,count,r_arch, ptr,l_data));
- free(ptr);
- }
- } else if (sub_type->category_code == e_gras_datadesc_type_cat_array &&
- sub_type->category.array_data.fixed_size > 0 &&
- sub_type->category.array_data.type->category_code == e_gras_datadesc_type_cat_scalar) {
- gras_datadesc_type_t subsub_type;
- array_data = sub_type->category.array_data;
- subsub_type = array_data.type;
-
- VERB1("Array of %d fixed array of scalars, get it in one shot",count);
- if (subsub_type->aligned_size[GRAS_THISARCH] >=
- subsub_type->aligned_size[r_arch]) {
- TRYOLD(gras_trp_chunk_recv(sock, (char*)l_data,
- subsub_type->aligned_size[r_arch] * count *
- array_data.fixed_size));
- if (r_arch != GRAS_THISARCH)
- TRYOLD(gras_dd_convert_elm(subsub_type,count*array_data.fixed_size,r_arch, l_data,l_data));
- } else {
- ptr = xbt_malloc(subsub_type->aligned_size[r_arch] * count*array_data.fixed_size);
-
- TRYOLD(gras_trp_chunk_recv(sock, (char*)ptr,
- subsub_type->size[r_arch] * count*array_data.fixed_size));
- if (r_arch != GRAS_THISARCH)
- TRYOLD(gras_dd_convert_elm(subsub_type,count*array_data.fixed_size,r_arch, ptr,l_data));
- free(ptr);
- }
-
-
- } else {
- /* not scalar content, get it recursively (may contain pointers) */
- elm_size = sub_type->aligned_size[GRAS_THISARCH];
- VERB2("Receive a %d-long array of %s",count, sub_type->name);
-
- ptr = l_data;
- for (cpt=0; cpt<count; cpt++) {
- TRYOLD(gras_datadesc_gen_recv_rec(sock,state,refs, sub_type,
- r_arch, NULL, 0, ptr,-1,
- detect_cycle || sub_type->cycle));
-
- ptr += elm_size;
- }
- }
- break;
- }
-
- default:
- xbt_assert0(0, "Invalid type");
- }
-
- if (type->recv)
- type->recv(type,state,l_data);
-
- return no_error;
-}
-
-/**
- * gras_datadesc_gen_recv:
- *
- * Get an instance of the datatype described by @type from the @socket,
- * and store a pointer to it in @dst
- *
- */
-xbt_error_t
-gras_datadesc_gen_recv(gras_socket_t sock,
- gras_datadesc_type_t type,
- int r_arch,
- void *dst) {
-
- xbt_error_t errcode;
- gras_cbps_t state; /* callback persistent state */
- xbt_dict_t refs; /* all references already sent */
-
- refs = xbt_dict_new();
- state = gras_cbps_new();
-
- printf("xbt_error_t gras_%s_recv(gras_socket_t sock,void *dst){\n",
- type->name);
-
- errcode = gras_datadesc_gen_recv_rec(sock, state, refs, type,
- r_arch, NULL, 0,
- (char *) dst,-1,
- sub_type->cycle);
-
- printf("}\n");
- xbt_dict_free(&refs);
- gras_cbps_free(&state);
-
- return errcode;
-}
-#endif
} s_gras_msg_procdata_t,*gras_msg_procdata_t;
-xbt_error_t gras_msg_send_namev(gras_socket_t sock,
- const char *namev,
- void *payload);
+void gras_msg_send_namev(gras_socket_t sock,
+ const char *namev,
+ void *payload);
#define GRAS_PROTOCOL_VERSION '\0';
#include "xbt/sysdep.h"
#include "xbt/log.h"
-#include "xbt/error.h"
#include "xbt/dynar.h"
#include "xbt/set.h"
#include "gras/transport.h"
XBT_OUT;
}
-#if 0
-/* Data exchange over measurement sockets */
-xbt_error_t gras_socket_meas_exchange(gras_socket_t peer,
- int sender,
- unsigned int timeout,
- unsigned long int expSize,
- unsigned long int msgSize) {
- unsigned int bytesTotal;
- static unsigned int count=0;
- m_task_t task=NULL;
- char name[256];
- gras_trp_sg_sock_data_t *sock_data = (gras_trp_sg_sock_data_t *)peer->data;
-
- gras_trp_procdata_t pd=(gras_trp_procdata_t)gras_libdata_get("gras_trp");
- double startTime;
-
- startTime=gras_os_time(); /* used only in sender mode */
-
- for(bytesTotal = 0; bytesTotal < expSize; bytesTotal += msgSize) {
-
- if (sender) {
-
- sprintf(name,"meas data[%d]",count++);
-
- task=MSG_task_create(name,0,((double)msgSize)/(1024.0*1024.0),NULL);
-
- DEBUG5("%f:%s: gras_socket_meas_send(%f %s -> %s) BEGIN",
- gras_os_time(), MSG_process_get_name(MSG_process_self()),
- ((double)msgSize)/(1024.0*1024.0),
- MSG_host_get_name( MSG_host_self()), peer->peer_name);
-
- if (MSG_task_put(task, sock_data->to_host,sock_data->to_chan) != MSG_OK)
- RAISE0(system_error,"Problem during the MSG_task_put()");
-
- DEBUG5("%f:%s: gras_socket_meas_send(%f %s -> %s) END",
- gras_os_time(), MSG_process_get_name(MSG_process_self()),
- ((double)msgSize)/(1024.0*1024.0),
- MSG_host_get_name( MSG_host_self()), peer->peer_name);
-
- } else { /* we are receiver, simulate a select */
-
- task=NULL;
- DEBUG2("%f:%s: gras_socket_meas_recv() BEGIN\n",
- gras_os_time(), MSG_process_get_name(MSG_process_self()));
- do {
- if (MSG_task_Iprobe((m_channel_t) pd->measChan)) {
- if (MSG_task_get(&task, (m_channel_t) pd->measChan) != MSG_OK) {
- fprintf(stderr,"GRAS: Error in MSG_task_get()\n");
- return unknown_error;
- }
-
- if (MSG_task_destroy(task) != MSG_OK) {
- fprintf(stderr,"GRAS: Error in MSG_task_destroy()\n");
- return unknown_error;
- }
-
- DEBUG2("%f:%s: gras_socket_meas_recv() END\n",
- gras_os_time(), MSG_process_get_name(MSG_process_self()));
- break;
- } else {
- MSG_process_sleep(0.0001);
- }
-
- } while (gras_os_time() - startTime < timeout);
-
- if (gras_os_time() - startTime > timeout)
- return timeout_error;
- } /* receiver part */
- } /* foreach msg */
-
- return no_error;
-}
-#endif
#include "xbt/sysdep.h"
#include "xbt/log.h"
-#include "xbt/error.h"
#include "xbt/dynar.h"
#include "xbt/dict.h"
/* Data exchange over measurement sockets */ /* FIXME: KILLME */
-xbt_error_t gras_socket_meas_exchange(gras_socket_t peer,
+/*
+void gras_socket_meas_exchange(gras_socket_t peer,
int sender,
unsigned int timeout,
unsigned long int expSize,
unsigned long int msgSize);
-
+*/
xbt_dynar_t gras_socketset_get(void); /* FIXME:KILLME */
#endif /* GRAS_TRP_PRIVATE_H */
#include "xbt/ex.h"
#include "xbt/sysdep.h"
#include "xbt/log.h"
-#include "xbt/error.h"
#include "gras/transport.h"
#include "gras/datadesc.h"
#include "gras/messages.h"
#include "xbt/sysdep.h"
#include "xbt/log.h"
-#include "xbt/error.h"
#include "xbt/dynar.h"
#include "xbt/dict.h"
#include "gras/virtu.h"
/* 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. */
-#include"private.h"
-#include"xbt/sysdep.h"
-#include "xbt/error.h"
+#include "private.h"
+#include "xbt/sysdep.h"
+#include "xbt/log.h"
#include "surf/surf_parse.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(deployment, msg,
"Logging specific to MSG (environment)");
/* 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. */
-#include"private.h"
-#include"xbt/sysdep.h"
-#include "xbt/error.h"
+#include "private.h"
+#include "xbt/sysdep.h"
+#include "xbt/log.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(environment, msg,
"Logging specific to MSG (environment)");
/* 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. */
-#include"private.h"
-#include"xbt/sysdep.h"
-#include "xbt/error.h"
+#include "private.h"
+#include "xbt/sysdep.h"
+#include "xbt/log.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(global, msg,
"Logging specific to MSG (global)");
/* 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. */
-#include"private.h"
-#include"xbt/sysdep.h"
-#include "xbt/error.h"
+#include "private.h"
+#include "xbt/sysdep.h"
+#include "xbt/log.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(gos, msg,
"Logging specific to MSG (gos)");
/* 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. */
-#include"private.h"
-#include"xbt/sysdep.h"
-#include "xbt/error.h"
+#include "private.h"
+#include "xbt/sysdep.h"
+#include "xbt/log.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(host, msg,
"Logging specific to MSG (host)");
/* 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. */
-#include"private.h"
-#include"xbt/sysdep.h"
-#include "xbt/error.h"
+#include "private.h"
+#include "xbt/sysdep.h"
+#include "xbt/log.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(m_process, msg,
"Logging specific to MSG (process)");
#include "private.h"
#include "xbt/sysdep.h"
-#include "xbt/error.h"
+#include "xbt/log.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_cfg, msg,
"Configuration support in \ref MSG_API");
/* 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. */
-#include"private.h"
-#include"xbt/sysdep.h"
-#include "xbt/error.h"
+#include "private.h"
+#include "xbt/sysdep.h"
+#include "xbt/log.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(task, msg,
"Logging specific to MSG (task)");
#include "xbt/sysdep.h"
-#include "xbt/error.h"
+#include "xbt/log.h"
#include "maxmin_private.h"
#include <stdlib.h>
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(maxmin, surf,
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "xbt/misc.h"
-#include "xbt/error.h"
+#include "xbt/log.h"
#include "surf/surf_parse.h"
#include "surf/surf_private.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(parse, surf ,"Logging specific to the SURF module");
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "xbt/sysdep.h"
-#include "xbt/error.h"
+#include "xbt/log.h"
#include "xbt/dict.h"
#include "trace_mgr_private.h"
#include "surf_private.h"
#include "portable.h"
#include "context_private.h"
-#include "xbt/error.h"
+#include "xbt/log.h"
#include "xbt/dynar.h"
#include "gras_config.h"
* \param dict the dealer of data
* \param key the key to find data
* \param key_len the size of the \a key
- * \param data the data that we are looking for
- * \return xbt_error
+ * \returns the data that we are looking for
*
- * Search the given \a key. mismatch_error when not found.
+ * Search the given \a key. throws not_found_error when not found.
*/
void *
xbt_dict_get_ext(xbt_dict_t dict,
*
* \param dict the dealer of data
* \param key the key to find data
- * \param data the data that we are looking for
- * \return xbt_error
+ * \returns the data that we are looking for
*
* Search the given \a key. THROWs mismatch_error when not found.
* Check xbt_dict_get_or_null() for a version returning NULL without exception when
* \param dict the trash can
* \param key the key of the data to be removed
* \param key_len the size of the \a key
- * \return xbt_error_t
+ *
*
- * Remove the entry associated with the given \a key
+ * Remove the entry associated with the given \a key (throws not_found)
*/
void
xbt_dict_remove_ext(xbt_dict_t dict,
/**
* @brief Get current key
* @param cursor: the cursor
- * @param key where to put the key
+ * @returns the current key
*/
char *
xbt_dict_cursor_get_key(xbt_dict_cursor_t cursor) {
/**
* @brief Get current data
* @param cursor the cursor
- * @param data where to put the data
+ * @returns the current data
*/
void *
xbt_dict_cursor_get_data(xbt_dict_cursor_t cursor) {
#include "xbt/sysdep.h"
#include "xbt/log.h"
-#include "xbt/error.h"
#include "xbt/ex.h"
#include "xbt/dynar.h"
#include "xbt/dict.h"
#include "xbt/misc.h"
#include "xbt/sysdep.h"
#include "xbt/log.h"
-#include "xbt/error.h"
#include "xbt/dynar.h"
#include <sys/types.h>
}
static _XBT_INLINE
-xbt_error_t
+void
_xbt_dynar_expand(xbt_dynar_t const dynar,
const int nb) {
- xbt_error_t errcode = no_error;
const unsigned long old_size = dynar->size;
if (nb > old_size) {
dynar->size = new_size;
dynar->data = new_data;
}
-
- return errcode;
}
static _XBT_INLINE
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "xbt/sysdep.h"
-#include "xbt/error.h"
#include "fifo_private.h"
/*XBT_LOG_NEW_DEFAULT_SUBCATEGORY(fifo,xbt,"FIFO"); UNUSED SO FAR */
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "xbt/sysdep.h"
-#include "xbt/error.h"
+#include "xbt/log.h"
#include "heap_private.h"
#include "xbt/sysdep.h"
#include "xbt/log.h"
-#include "xbt/error.h"
#include <stdio.h>
#include "gras/virtu.h"
#include "xbt/sysdep.h"
#include "xbt/log.h"
-#include "xbt/error.h"
#include "xbt/dynar.h"
#include "xbt/config.h"
*
* \param set
* \param name Name of the searched cell
- * \param dst where to put the found data into
+ * \returns the data you're looking for
*/
xbt_set_elm_t xbt_set_get_by_name (xbt_set_t set,
const char *name) {
* \param set
* \param name Name of the searched cell
* \param name_len length of the name, when strlen cannot be trusted
- * \param dst where to put the found data into
+ * \returns the data you're looking for
*
* This is useful when strlen cannot be trusted because you don't use a char*
* as name, you weirdo.
*
* \param set
* \param id what you're looking for
- * \param dst where to put the found data into
+ * \returns the data you're looking for
*
* @warning, if the ID does not exists, you're getting into trouble
*/
/* This type should be added to a type that is to be used in such a swag */
#include "xbt/sysdep.h"
-#include "xbt/error.h"
+#include "xbt/log.h"
#include "xbt/swag.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(swag,xbt,"Swag : O(1) set library");
print "#define READ 0\n#define WRITE 1\n#define RW 2\n\n";
-print "xbt_error_t write_read(gras_datadesc_type_t type,void *src, void *dst, gras_socket_t *sock, int direction);\n\n";
+print "void write_read(gras_datadesc_type_t type,void *src, void *dst, gras_socket_t *sock, int direction);\n\n";
my ($i,$j,$k,$l);
my $max=scalar @types;
XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Logging specific to this test");
-static xbt_error_t traverse(xbt_dict_t head) {
+static void traverse(xbt_dict_t head) {
xbt_dict_cursor_t cursor=NULL;
char *key;
char *data;
xbt_assert2 (!strcmp(key,data),
"Key(%s) != value(%s). Abording\n",key,data);
}
- return no_error;
}
-static xbt_error_t countelems(xbt_dict_t head,int*count) {
+static int countelems(xbt_dict_t head) {
xbt_dict_cursor_t cursor;
char *key;
void *data;
- *count=0;
+ int res = 0;
xbt_dict_foreach(head,cursor,key,data) {
- (*count)++;
+ res++;
}
- return no_error;
+ return res;
}
int main(int argc,char **argv) {
- xbt_error_t errcode;
xbt_dict_t head=NULL;
int i,j,k, nb;
char *key;
/* printf("[%d %s]\n",j,key); */
xbt_dict_set(head,key,key,&free);
}
- nb=0;
/* xbt_dict_dump(head,(void (*)(void*))&printf); */
- TRYFAIL(countelems(head,&nb));
+ nb = countelems(head);
if (nb != 1000) {
printf ("\nI found %d elements, and not 1000\n",nb);
abort();
}
- TRYFAIL(traverse(head));
+ traverse(head);
xbt_dict_free(&head);
xbt_dict_free(&head);
}
}
printf("\n Count the elements (retrieving the key and data for each): \n");
- TRYFAIL(countelems(head,&i));
+ i = countelems(head);
printf(" There is %d elements\n",i);
printf("\n Search my 20 000 elements 20 times. (a point is a test)\n");
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "xbt/sysdep.h"
+#include "xbt/log.h"
#include "surf/surf_parse.h"
#include "surf/surf.h"