From 7d534bbf798a4036dd3cee1c36df05b2c34defe8 Mon Sep 17 00:00:00 2001 From: bustico Date: Mon, 24 Jan 2011 13:39:15 +0000 Subject: make ivy-c c++ compiler compliant use last version (1.9.3) of uthash header --- tools/ivythroughput.cpp | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'tools/ivythroughput.cpp') diff --git a/tools/ivythroughput.cpp b/tools/ivythroughput.cpp index 692c639..d99588e 100644 --- a/tools/ivythroughput.cpp +++ b/tools/ivythroughput.cpp @@ -12,7 +12,8 @@ ° traitement des options : -v (affi version) -b bus, -r regexp file, -m message file, -n : nombre de recepteurs - -t [type de test => ml (memory leak), tp (throughput) + -t [type de test => ml (memory leak), tp (throughput), dx (gestion des deconnexions + intenpestives) test memory leak ° fork d'un emetteur et d'un (ou plusieurs) recepteur : le recepteur s'abonne à toutes les regexps, @@ -24,6 +25,10 @@ ° l'emetteur envoie en boucle tous les messages du fichier de message ° l'emetteur note le temps d'envoi des messages ° l'emetteur envoie un die all et quitte + + UTILISATION TYPIQUES: + pour la deconnexion intenpestive : + ivythroughput -R 500 -t dx -d 40 -n 2 */ #include @@ -61,7 +66,7 @@ typedef std::map MapBindByClnt; #define MILLISEC 1000.0 -typedef enum {memoryLeak1, memoryLeak2, throughput} KindOfTest ; +typedef enum {memoryLeak1, memoryLeak2, throughput, disconnect} KindOfTest ; typedef struct { @@ -97,6 +102,7 @@ void endOfSeqCB (IvyClientPtr app, void *user_data, int argc, char *argv[]); void desabonneEtReabonneCB (TimerId id, void *user_data, unsigned long delta); void changeRegexpCB (TimerId id, void *user_data, unsigned long delta); void exitCB (TimerId id, void *user_data, unsigned long delta); +void doNothingAndSuicideCB (TimerId id, void *user_data, unsigned long delta); unsigned int nbMess=0, nbReg=0, numClients =1, globalInst, numRegexps=1e6, numMessages=1e6; MapUintToBool recReady; @@ -155,6 +161,8 @@ int main(int argc, char *argv[]) kindOfTest = memoryLeak2; } else if (strcasecmp (optarg, "tp") == 0) { kindOfTest = throughput; + } else if (strcasecmp (optarg, "dx") == 0) { + kindOfTest = disconnect; } else { printf("usage: %s %s",argv[0],helpmsg); exit(1); @@ -209,6 +217,9 @@ int main(int argc, char *argv[]) case memoryLeak2 : recepteur_tp (bus, kindOfTest, i, regexps, testDuration-5); break; + case disconnect : + recepteur_tp (bus, kindOfTest, i, regexps, testDuration); + break; } exit (0); } else { @@ -297,8 +308,10 @@ void recepteur_tp (const char* bus, KindOfTest kod, unsigned int inst, if (kod == memoryLeak2) { TimerRepeatAfter (1, exitAfter*1000, exitCB, NULL); + } else if (kod == disconnect) { + TimerRepeatAfter (1, exitAfter*1000/3, doNothingAndSuicideCB, (void *) exitAfter); } - + //usleep (inst * 50 * 1000); IvyStart (bus); IvyMainLoop (); @@ -646,3 +659,16 @@ void exitCB (TimerId id, void *user_data, unsigned long delta) printf ("DBG> client exit\n"); exit (0); } + +void doNothingAndSuicideCB (TimerId id, void *user_data, unsigned long delta) +{ + printf ("."); + long time = (long) user_data; + time = ((time-2)/2) * 1000; + printf ("DBG> client hanging for %d milliseconds\n", time); + usleep (time * 1000); + printf ("DBG> client suicide\n"); + _exit(42); + printf ("DBG> CECI NE DEVRAIT JAMAIS ETRE AFFICHE\n"); +} + -- cgit v1.1