aboutsummaryrefslogtreecommitdiff
path: root/src/testbed
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2012-09-01 16:08:48 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2012-09-01 16:08:48 +0000
commit6b3658245ff0d56bda7ace4fe36b157c2bfda059 (patch)
tree528c3ce6ae095688b6fbf9788053defdadf34ab6 /src/testbed
parent84697c75b5d20d199282715c39ccd59ef4a0d1fa (diff)
downloadgnunet-6b3658245ff0d56bda7ace4fe36b157c2bfda059.tar.gz
gnunet-6b3658245ff0d56bda7ace4fe36b157c2bfda059.zip
repect event mask before calling event callback
Diffstat (limited to 'src/testbed')
-rw-r--r--src/testbed/test_testbed_api_testbed_run.c3
-rw-r--r--src/testbed/testbed_api_testbed.c51
2 files changed, 27 insertions, 27 deletions
diff --git a/src/testbed/test_testbed_api_testbed_run.c b/src/testbed/test_testbed_api_testbed_run.c
index 8aee8d6cc..b8bca508d 100644
--- a/src/testbed/test_testbed_api_testbed_run.c
+++ b/src/testbed/test_testbed_api_testbed_run.c
@@ -31,7 +31,7 @@
31/** 31/**
32 * Number of peers we want to start 32 * Number of peers we want to start
33 */ 33 */
34#define NUM_PEERS 50 34#define NUM_PEERS 13
35 35
36/** 36/**
37 * The array of peers; we fill this as the peers are given to us by the testbed 37 * The array of peers; we fill this as the peers are given to us by the testbed
@@ -155,7 +155,6 @@ run (void *cls, char *const *args, const char *cfgfile,
155 event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_STOP); 155 event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_STOP);
156 event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT); 156 event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT);
157 event_mask |= (1LL << GNUNET_TESTBED_ET_DISCONNECT); 157 event_mask |= (1LL << GNUNET_TESTBED_ET_DISCONNECT);
158 event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED);
159 GNUNET_TESTBED_run (NULL, config, NUM_PEERS, event_mask, &controller_event_cb, 158 GNUNET_TESTBED_run (NULL, config, NUM_PEERS, event_mask, &controller_event_cb,
160 NULL, &master_task, NULL); 159 NULL, &master_task, NULL);
161 abort_task = 160 abort_task =
diff --git a/src/testbed/testbed_api_testbed.c b/src/testbed/testbed_api_testbed.c
index 06cba2850..6fa5d6dd4 100644
--- a/src/testbed/testbed_api_testbed.c
+++ b/src/testbed/testbed_api_testbed.c
@@ -1,22 +1,22 @@
1/* 1/*
2 This file is part of GNUnet 2 This file is part of GNUnet
3 (C) 2008--2012 Christian Grothoff (and other contributing authors) 3 (C) 2008--2012 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your 7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version. 8 option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details. 13 General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the 16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19 */ 19*/
20 20
21/** 21/**
22 * @file testbed/testbed_api_testbed.c 22 * @file testbed/testbed_api_testbed.c
@@ -32,7 +32,7 @@
32/** 32/**
33 * Generic loggins shorthand 33 * Generic loggins shorthand
34 */ 34 */
35#define LOG(kind,...) \ 35#define LOG(kind,...) \
36 GNUNET_log_from (kind, "testbed-api-testbed", __VA_ARGS__) 36 GNUNET_log_from (kind, "testbed-api-testbed", __VA_ARGS__)
37 37
38/** 38/**
@@ -343,7 +343,7 @@ event_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
343 } 343 }
344 344
345call_cc: 345call_cc:
346 if (NULL != rc->cc) 346 if ((0 != (rc->event_mask && (1LL << event->type))) && (NULL != rc->cc))
347 rc->cc (rc->cc_cls, event); 347 rc->cc (rc->cc_cls, event);
348 if (GNUNET_TESTBED_ET_PEER_START != event->type) 348 if (GNUNET_TESTBED_ET_PEER_START != event->type)
349 return; 349 return;
@@ -382,6 +382,7 @@ controller_status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg,
382{ 382{
383 struct RunContext *rc = cls; 383 struct RunContext *rc = cls;
384 struct DLLOperation *dll_op; 384 struct DLLOperation *dll_op;
385 uint64_t event_mask;
385 unsigned int peer; 386 unsigned int peer;
386 387
387 if (status != GNUNET_OK) 388 if (status != GNUNET_OK)
@@ -389,9 +390,11 @@ controller_status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg,
389 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Testbed startup failed\n"); 390 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Testbed startup failed\n");
390 return; 391 return;
391 } 392 }
393 event_mask = rc->event_mask;
394 event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_STOP);
395 event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED);
392 rc->c = 396 rc->c =
393 GNUNET_TESTBED_controller_connect (cfg, rc->h, rc->event_mask, &event_cb, 397 GNUNET_TESTBED_controller_connect (cfg, rc->h, event_mask, &event_cb, rc);
394 rc);
395 rc->peers = 398 rc->peers =
396 GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Peer *) * rc->num_peers); 399 GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Peer *) * rc->num_peers);
397 GNUNET_assert (NULL != rc->c); 400 GNUNET_assert (NULL != rc->c);
@@ -480,9 +483,6 @@ GNUNET_TESTBED_run (const char *host_filename,
480{ 483{
481 struct RunContext *rc; 484 struct RunContext *rc;
482 485
483 event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_START);
484 event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_STOP);
485 event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED);
486 rc = GNUNET_malloc (sizeof (struct RunContext)); 486 rc = GNUNET_malloc (sizeof (struct RunContext));
487 GNUNET_break (NULL == host_filename); /* Currently we do not support host 487 GNUNET_break (NULL == host_filename); /* Currently we do not support host
488 * files */ 488 * files */
@@ -496,6 +496,7 @@ GNUNET_TESTBED_run (const char *host_filename,
496 GNUNET_assert (NULL != rc->cproc); 496 GNUNET_assert (NULL != rc->cproc);
497 rc->num_peers = num_peers; 497 rc->num_peers = num_peers;
498 rc->event_mask = event_mask; 498 rc->event_mask = event_mask;
499 rc->event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_START);
499 rc->cc = cc; 500 rc->cc = cc;
500 rc->cc_cls = cc_cls; 501 rc->cc_cls = cc_cls;
501 rc->master = master; 502 rc->master = master;