summaryrefslogtreecommitdiff
path: root/tools/ivythroughput.cpp
blob: 692c6395654d3381a45dc0d9ca1e48d732f64894 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
/*
 *	IvyThroughput
 *
 *	Copyright (C) 2008
 *	Centre d'Études de la Navigation Aérienne
 */
 

// g++ ivythroughput.cpp -o ivythroughput -L/usr/local/lib64/ -Wl,-rpath,/usr/local/lib64/ -livy -lpcrecpp

/* SCENARIO  
   
  ° 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)

    test memory leak
  ° fork d'un emetteur et d'un (ou plusieurs) recepteur : le recepteur s'abonne à toutes les regexps,
    se desabonne, se reabonne etc etc en boucle : on teste que l'empreinte mémoire
    de l'emetteur ne grossisse pas

    test throughput :
  ° fork d'un emetteur et d'un ou plusieurs recepteurs : les recepteurs s'abonnent à toutes les regexps
  ° 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
*/

#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>
#include "version.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <iostream>
#include <sstream>
#include <signal.h>

#include "ivysocket.h"
#include "ivy.h"
#include "timer.h"
#include "ivyloop.h"
#include <pcrecpp.h>

#include <string>
#include <list>
#include <map>

typedef std::list<std::string>  ListOfString;
typedef std::list<pid_t> ListOfPid;
typedef std::map<unsigned int, bool> MapUintToBool;
typedef std::list<MsgRcvPtr> ListOfMsgRcvPtr;

typedef struct {
  unsigned int currentBind;
  unsigned int totalBind;
} InfoBind;
typedef std::map<string, InfoBind> MapBindByClnt;

#define MILLISEC 1000.0

typedef enum  {memoryLeak1, memoryLeak2, throughput} KindOfTest ;


typedef struct {
  ListOfMsgRcvPtr	*bindIdList;
  const ListOfString    *regexps;
  unsigned int		inst;
} MlDataStruct;



extern char *optarg;
extern int   optind, opterr, optopt;

void recepteur_tp (const char* bus, KindOfTest kod, unsigned int inst, 
		   const ListOfString& regexps, unsigned int exitAfter);
void recepteur_ml (const char* bus, KindOfTest kod, unsigned int inst, 
		   const ListOfString& regexps);
void emetteur (const char* bus, KindOfTest kod, int testDuration, 
	       const ListOfString& messages, int regexpSize);

bool getMessages (const char*fileName, ListOfString &messages, unsigned int numMess);
bool getRegexps (const char*fileName, ListOfString &regexps, unsigned int numReg);

double currentTime();
void binCB( IvyClientPtr app, void *user_data, int id, const char* regexp,  IvyBindEvent event ) ;
void congestCB ( IvyClientPtr app, void *user_data, IvyApplicationEvent event ) ;
void stopCB (TimerId id, void *user_data, unsigned long delta);
void sendAllMessageCB (TimerId id, void *user_data, unsigned long delta);
void recepteurReadyCB (IvyClientPtr app, void *user_data, int argc, char *argv[]);
void recepteurCB (IvyClientPtr app, void *user_data, int argc, char *argv[]);
void startOfSeqCB (IvyClientPtr app, void *user_data, int argc, char *argv[]);
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);

unsigned int nbMess=0, nbReg=0, numClients =1, globalInst, numRegexps=1e6, numMessages=1e6;
MapUintToBool   recReady;
KindOfTest   kindOfTest = throughput;
bool	     regexpAreUniq = false;

int main(int argc, char *argv[])
{
  int c;
  int testDuration = 10;
  char *bus ;
  char  regexpFile[1024] = "testivy/regexp.txt";
  char  messageFile[1024] = "testivy/messages.ivy";
  ListOfString messages, regexps;
  pid_t        pid;
  ListOfPid    recPid;
  
  const char* helpmsg =
    "[options] \n"
    "\t -b bus\tdefines the Ivy bus to which to connect to, defaults to 127:2010\n"
    "\t -v \t prints the ivy relase number\n\n"
    "\t -t \t type of test :  ml or ml2 (memory leak) or tp (throughput)\n"
    "\t -r \t regexfile\tread list of regexp's from file (default to testivy/regexp.txt)\n"
    "\t -R \t restrict to R firsts regexps instead of all the regexp in the regexp file \n"
    "\t -p \t each client will postpend regexp with uniq string to "
             "simulate N clients with differents regexps\n"
    "\t -m \t messageFile\tread list of messages from file (default to testivy/messages.ivy)\n"
    "\t -M \t restrict to M firsts messages instead of all the message in the message file \n"
    "\t -n \t number of clients\n" 
    "\t -d \t duration of the test in seconds\n" ;


  if (getenv("IVYBUS") != NULL) {
    bus = strdup (getenv("IVYBUS"));
  } else {
    bus = strdup ("127.0.0.1:2000") ;
  }

  while ((c = getopt(argc, argv, "vpb:r:m:R:M:n:t:d:")) != EOF)
    switch (c) {
    case 'b':
      strcpy (bus, optarg);
      break;
    case 'v':
      printf("ivy c library version %d.%d\n",IVYMAJOR_VERSION, IVYMINOR_VERSION);
      break; 
    case 'p':
      regexpAreUniq = true;
      break; 
    case 't':
      if (strcasecmp (optarg, "ml") == 0) {
	kindOfTest = memoryLeak1;
      } else if (strcasecmp (optarg, "ml1") == 0) {
	kindOfTest = memoryLeak1;
      } else if (strcasecmp (optarg, "ml2") == 0) {
	kindOfTest = memoryLeak2;
      } else if (strcasecmp (optarg, "tp") == 0) {
	kindOfTest = throughput;
      } else {
	printf("usage: %s %s",argv[0],helpmsg);
	exit(1);
      }
      break;
    case 'r':
      strcpy (regexpFile, optarg);
      break;
    case 'm':
      strcpy (messageFile, optarg);
      break;
    case 'R':
       numRegexps = atoi (optarg);
      break;
    case 'M':
       numMessages = atoi (optarg);
      break;
    case 'n':
      numClients = atoi (optarg);
      break;
    case 'd':
      testDuration = atoi (optarg);
      break;
    default:
      printf("usage: %s %s",argv[0],helpmsg);
      exit(1);
    }

  if (!getRegexps (regexpFile, regexps, numRegexps)) 
    {return (1);};

  if (kindOfTest != memoryLeak1) {
    if (!getMessages (messageFile, messages, numMessages)) 
      {return (1);};
  }



  for (unsigned int i=0; i< numClients; i++) {
    if ((pid = fork ()) == 0) {
      // fils
#ifdef __APPLE__
      usleep (200 * 1000);
#endif
      switch  (kindOfTest) {
      case throughput :
	recepteur_tp (bus, kindOfTest, i, regexps, 0);
	break;
      case memoryLeak1 :
	recepteur_ml (bus, kindOfTest, i, regexps);
	break;
      case memoryLeak2 :
	recepteur_tp (bus, kindOfTest, i, regexps, testDuration-5);
	break;
      }
      exit (0);
    } else {
      recPid.push_back (pid);
      recReady[i]=false;
    }
  }
  
  emetteur  (bus, kindOfTest, testDuration, messages, regexps.size());

  ListOfPid::iterator  iter;  
  for (iter=recPid.begin(); iter != recPid.end(); iter++) {
    kill (*iter, SIGTERM);
  }

  for (iter=recPid.begin(); iter != recPid.end(); iter++) {
    waitpid (*iter, NULL, 0);
  }
  
  return (0);
}




/*
#                                           _      _
#                                          | |    | |
#                  ___   _ __ ___     ___  | |_   | |_     ___   _   _   _ __
#                 / _ \ | '_ ` _ \   / _ \ | __|  | __|   / _ \ | | | | | '__|
#                |  __/ | | | | | | |  __/ \ |_   \ |_   |  __/ | |_| | | |
#                 \___| |_| |_| |_|  \___|  \__|   \__|   \___|  \__,_| |_|
*/
void emetteur (const char* bus, KindOfTest kod, int testDuration, 
	       const ListOfString& messages, int regexpSize)
{
  printf ("DBG> emetteur start, pid=%d\n", getpid());
  IvyInit ("IvyThroughputEmit", "IvyThroughputEmit Ready", congestCB, NULL,NULL,NULL);
  //  double origin = currentTime();


  IvySetBindCallback (binCB, (void *) (regexpSize+2));
  IvyBindMsg (recepteurReadyCB, (void *) &messages, 
	      "^IvyThroughputReceive_(\\d+)\\s+Ready");

  TimerRepeatAfter (1, testDuration *1000, stopCB, NULL);

  IvyStart (bus);
  IvyMainLoop ();
}



/*
#                                             _ __    _
#                                            | '_ \  | |
#                 _ __    ___    ___    ___  | |_) | | |_     ___   _   _   _ __
#                | '__|  / _ \  / __|  / _ \ | .__/  | __|   / _ \ | | | | | '__|
#                | |    |  __/ | (__  |  __/ | |     \ |_   |  __/ | |_| | | |
#                |_|     \___|  \___|  \___| |_|      \__|   \___|  \__,_| |_|
*/
void recepteur_tp (const char* bus, KindOfTest kod, unsigned int inst, 
		const ListOfString& regexps,  unsigned int exitAfter)
{
  std::string agentName = "IvyThroughputReceive_";
  std::stringstream stream ;
  stream << inst;
  agentName +=  stream.str();
  std::string agentNameReady (agentName + " Ready");
  //double origin = currentTime();
  globalInst = inst;

  printf ("DBG> recepteur_%d start, pid=%d\n", inst, getpid());
  IvyInit (agentName.c_str(), agentNameReady.c_str(), congestCB, NULL,NULL,NULL);
  
  unsigned int debugInt = 0;
  ListOfString::const_iterator  iter;  
  for (iter=regexps.begin(); iter != regexps.end(); iter++) {
    debugInt++;
    string reg = *iter;
    if (regexpAreUniq) { ((reg += "(") += stream.str()) += ")?";}
    IvyBindMsg (recepteurCB, (void *) inst, reg.c_str());
  }
  IvyBindMsg (startOfSeqCB, NULL, "^start(OfSequence)");
  IvyBindMsg (endOfSeqCB, NULL, "^end(OfSequence)");

  if (kod == memoryLeak2) {
    TimerRepeatAfter (1, exitAfter*1000, exitCB, NULL);
  }

  //usleep (inst * 50 * 1000);
  IvyStart (bus);
  IvyMainLoop ();
}

void recepteur_ml (const char* bus, KindOfTest kod, unsigned int inst, 
		const ListOfString& regexps)
{
  std::string agentName = "IvyThroughputReceive_";
  std::stringstream stream ;
  stream << inst;
  agentName +=  stream.str();
  std::string agentNameReady (agentName + " Ready");
  //double origin = currentTime();
  globalInst = inst;
  static ListOfMsgRcvPtr bindIdList;
  static MlDataStruct mds;

  printf ("DBG> recepteur_%d start, pid=%d\n", inst, getpid());
  IvyInit (agentName.c_str(), agentNameReady.c_str(), congestCB, NULL,NULL,NULL);
  
  unsigned int debugInt = 0;
  ListOfString::const_iterator  iter;  
  for (iter=regexps.begin(); iter != regexps.end(); iter++) {
    debugInt++;
    string reg = *iter;
    if (regexpAreUniq) { (reg += " ") += stream.str();}
    bindIdList.push_back (IvyBindMsg (recepteurCB, (void *) inst, reg.c_str()));
  }
  IvyBindMsg (startOfSeqCB, NULL, "^start(OfSequence)");
  IvyBindMsg (endOfSeqCB, NULL, "^end(OfSequence)");

  mds.bindIdList = &bindIdList;
  mds.regexps = &regexps;
  mds.inst = inst;

  TimerRepeatAfter (1, 1000, desabonneEtReabonneCB, &mds);
  //TimerRepeatAfter (1, 1000, abonneEtDesabonneCB, &mds);

  IvyStart (bus);
  IvyMainLoop ();
}

// ===========================================================================



/*
#                  __ _          _      __  __                                 __ _
#                 / _` |        | |    |  \/  |                               / _` |
#                | (_| |   ___  | |_   | \  / |   ___   ___    ___     __ _  | (_| |   ___
#                 \__, |  / _ \ | __|  | |\/| |  / _ \ / __|  / __|   / _` |  \__, |  / _ \
#                  __/ | |  __/ \ |_   | |  | | |  __/ \__ \  \__ \  | (_| |   __/ | |  __/
#                 |___/   \___|  \__|  |_|  |_|  \___| |___/  |___/   \__,_|  |___/   \___|
*/

bool getMessages (const char*fileName, ListOfString &messages, unsigned int numMess)
{
  FILE *infile;
  char buffer [1024*64];
  pcrecpp::RE pcreg ("\"(.*)\"$");
  string  aMsg;

  infile = fopen(fileName, "r");
  if (!infile) {
    fprintf (stderr, "impossible d'ouvrir %s en lecture\n", fileName);
    return false;
  }
  
  while ((fgets (buffer, sizeof (buffer), infile) != NULL) && (nbMess < numMess)) {
    if (pcreg.PartialMatch (buffer, &aMsg)) {
      messages.push_back (aMsg);
      nbMess++;
    } 
  }
  fclose (infile);
  return (true);
}


/*
#                  __ _          _      _____            __ _                  _ __
#                 / _` |        | |    |  __ \          / _` |                | '_ \
#                | (_| |   ___  | |_   | |__) |   ___  | (_| |   ___  __  __  | |_) |  ___
#                 \__, |  / _ \ | __|  |  _  /   / _ \  \__, |  / _ \ \ \/ /  | .__/  / __|
#                  __/ | |  __/ \ |_   | | \ \  |  __/   __/ | |  __/  >  <   | |     \__ \
#                 |___/   \___|  \__|  |_|  \_\  \___|  |___/   \___| /_/\_\  |_|     |___/
*/
bool getRegexps (const char*fileName, ListOfString &regexps, unsigned int numReg)
{
  FILE *infile;
  char buffer [1024*64];
  pcrecpp::RE pcreg1 ("add regexp \\d+ : (.*)$");
  pcrecpp::RE pcreg2 ("(\\^.*)$");
  string  aMsg;

  infile = fopen(fileName, "r");
  if (!infile) {
    fprintf (stderr, "impossible d'ouvrir %s en lecture\n", fileName);
    return false;
  }
  
  while ((fgets (buffer, sizeof (buffer), infile) != NULL) && (nbReg < numReg)) {
    if (pcreg1.PartialMatch (buffer, &aMsg)) {
      regexps.push_back (aMsg);
      nbReg++;
    } else if (pcreg2.PartialMatch (buffer, &aMsg)) {
      regexps.push_back (aMsg);
      nbReg++;
    }
  }
  fclose (infile);

  return (true);
}



/*
#                                              _______   _
#                                             |__   __| (_)
#                  ___   _   _   _ __   _ __     | |     _    _ __ ___     ___
#                 / __| | | | | | '__| | '__|    | |    | |  | '_ ` _ \   / _ \
#                | (__  | |_| | | |    | |       | |    | |  | | | | | | |  __/
#                 \___|  \__,_| |_|    |_|       |_|    |_|  |_| |_| |_|  \___|
*/
double currentTime()
{
  double current;
  
  struct timeval stamp;
  gettimeofday( &stamp, NULL );
  current = (double)stamp.tv_sec * MILLISEC + (double)(stamp.tv_usec/MILLISEC);
  return  current;
}


/*
#                 _       _             _____   ____
#                | |     (_)           / ____| |  _ \
#                | |__    _    _ __   | |      | |_) |
#                | '_ \  | |  | '_ \  | |      |  _ <
#                | |_) | | |  | | | | | |____  | |_) |
#                |_.__/  |_|  |_| |_|  \_____| |____/
*/
void binCB( IvyClientPtr app, void *user_data, int id, const char* regexp,  IvyBindEvent event ) 
{
  string appName = IvyGetApplicationName( app );
  static MapBindByClnt bindByClnt;

  if (bindByClnt.find (appName) == bindByClnt.end()) {
    (bindByClnt[appName]).currentBind = 0;
    (bindByClnt[appName]).totalBind = (unsigned long) user_data;
  }

  switch ( event )
    {
    case IvyAddBind:
      (bindByClnt[appName]).currentBind ++;
      if ((bindByClnt[appName]).currentBind == (bindByClnt[appName]).totalBind) {
	printf("Application:%s ALL REGEXPS BINDED\n", appName.c_str());
      } else {
	//	printf("Application:%s bind [%d/%d]\n", appName.c_str(), 
	//     (bindByClnt[appName]).currentBind, (bindByClnt[appName]).totalBind);
      }
      break;
    case IvyRemoveBind:
      if ((id % 10000) == 0) {
	printf("Application:%s bind '%d' REMOVED\n", appName.c_str(), id );
      }
      break;
    case IvyFilterBind:
      printf("Application:%s bind '%s' FILTRED\n", appName.c_str(), regexp );
      break;
    case IvyChangeBind:
      printf("Application:%s bind '%s' CHANGED\n", appName.c_str(), regexp );
      break;
    }
}



void congestCB ( IvyClientPtr app, void *user_data, IvyApplicationEvent event ) 
{
  string appName = IvyGetApplicationName( app );

  switch ( event ) {
#if IVYMINOR_VERSION >= 11
  case IvyApplicationCongestion:
    printf("Application:%s : Congestion\n", appName.c_str());
    break;
  case IvyApplicationDecongestion:
    printf("Application:%s : DEcongestion\n", appName.c_str());
    break;
  case IvyApplicationFifoFull:
    printf("Application:%s : FIFO PLEINE, MESSAGES PERDUS !!!\n", appName.c_str());
    break;
#endif
  case IvyApplicationConnected:
#ifdef __APPLE__
    printf("Application:%s : Connected\n", appName.c_str());
#endif
  case IvyApplicationDisconnected:
#ifdef __APPLE__
    printf("Application:%s : Disconnected\n", appName.c_str());
#endif
    break;
  }
}




void stopCB (TimerId id, void *user_data, unsigned long delta)
{
 IvyStop ();
}


void sendAllMessageCB (TimerId id, void *user_data, unsigned long delta)
{
  ListOfString  *messages = (ListOfString *) user_data;
  double startTime = currentTime();
  unsigned int envoyes=0;

  IvySendMsg ("startOfSequence");
  ListOfString::iterator  iter;  
  for (iter=messages->begin(); iter != messages->end(); iter++) {
    envoyes += IvySendMsg ((*iter).c_str());
  }
  IvySendMsg ("endOfSequence");

  printf ("[ivy %d.%d] envoyer [%d/%d] messages filtres par %d regexps a %d clients "
	  "prends %.1f secondes\n",
	  IVYMAJOR_VERSION, IVYMINOR_VERSION,
	  envoyes, nbMess, nbReg, numClients, 
	  (currentTime()-startTime) / 1000.0) ;
  TimerRepeatAfter (1, 1000, sendAllMessageCB ,user_data);
}

void recepteurCB (IvyClientPtr app, void *user_data, int argc, char *argv[])
{
  //  unsigned long recN = (long) user_data;
  //  printf (".");
  //  if (!((argc == 1) && (strcmp (argv[0], "OfSequence")) == 0))
  nbMess++;
}


void recepteurReadyCB (IvyClientPtr app, void *user_data, int argc, char *argv[])
{
  ListOfString  *messages = (ListOfString *) user_data;
  unsigned int instance = atoi( *argv++ );

  recReady[instance] = true;
  bool readyToStart = true;

  for (unsigned int i=0; i< numClients; i++) {
    if (recReady[i]==false) {
      printf ("Emetteur :Recepteur[%d] OK,  manque recepteur [%d/%d]\n", instance, i, numClients-1);
      readyToStart = false;
    }
  }
  
  if (readyToStart == true) {
    if (kindOfTest != memoryLeak1) {
      TimerRepeatAfter (1, 100, sendAllMessageCB , messages);
      printf ("Emetteur : tous recepteurs prets : on envoie la puree !!\n");
    }
  } else {
    printf ("\n");
  }
}



void startOfSeqCB (IvyClientPtr app, void *user_data, int argc, char *argv[])
{
  nbMess = 0;
}


void endOfSeqCB (IvyClientPtr app, void *user_data, int argc, char *argv[])
{
  //nbMess--;
  printf ("recepteur %d a recu %d messages\n", globalInst, nbMess);
}


void desabonneEtReabonneCB (TimerId id, void *user_data, unsigned long delta)
{
  MlDataStruct *mds = (MlDataStruct *) user_data;
  
  //  printf ("on entre dans desabonneEtReabonneCB\n");
  
  ListOfMsgRcvPtr::iterator  iter;  

  // DESABONNE
  for (iter=mds->bindIdList->begin(); iter != mds->bindIdList->end(); iter++) {
    IvyUnbindMsg (*iter);
  }
  mds->bindIdList->clear ();
  
  // REABONNE
  ListOfString::const_iterator  iter2;  
  for (iter2=mds->regexps->begin(); iter2 != mds->regexps->end(); iter2++) {
    string reg = *iter2;
    mds->bindIdList->push_back (IvyBindMsg (recepteurCB, (void *) mds->inst, reg.c_str()));
  }

  // CHANGE REGEXP
    for (iter=mds->bindIdList->begin(); iter != mds->bindIdList->end(); iter++) {
    IvyChangeMsg (*iter, "^Une regexp (BIDON)");
  }


  // DESABONNE
  for (iter=mds->bindIdList->begin(); iter != mds->bindIdList->end(); iter++) {
    IvyUnbindMsg (*iter);
  }
  mds->bindIdList->clear ();

  //TimerRepeatAfter (1, 1000, changeRegexpCB, mds);
}


void changeRegexpCB (TimerId id, void *user_data, unsigned long delta)
{
  MlDataStruct *mds = (MlDataStruct *) user_data;
  
  //  printf ("on entre dans abonneEtDesabonneCB\n");
  
  ListOfMsgRcvPtr::iterator  iter;  


  for (iter=mds->bindIdList->begin(); iter != mds->bindIdList->end(); iter++) {
    IvyChangeMsg (*iter, "^Une regexp (BIDON)");
  }

  TimerRepeatAfter (1, 1000, changeRegexpCB, mds);
}

void exitCB (TimerId id, void *user_data, unsigned long delta)
{
  printf ("DBG> client exit\n");
  exit (0);
}