aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2018-01-07 22:32:24 +0100
committerJulius Bünger <buenger@mytum.de>2018-01-07 22:33:09 +0100
commit5f9face21a6ca311247c4f11a1f015691673cc9a (patch)
tree66308fea98f33076e70c0276a7b7cec787042303
parent5511ea2d4ce4e62120528272881b477ca6f6877c (diff)
downloadgnunet-5f9face21a6ca311247c4f11a1f015691673cc9a.tar.gz
gnunet-5f9face21a6ca311247c4f11a1f015691673cc9a.zip
rps tests: cosmetics
-rw-r--r--src/rps/test_rps.c40
1 files changed, 26 insertions, 14 deletions
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c
index 9f3044dcc..2cc1ac62e 100644
--- a/src/rps/test_rps.c
+++ b/src/rps/test_rps.c
@@ -62,6 +62,19 @@ static unsigned int mal_type = 0;
62 */ 62 */
63static struct GNUNET_TESTBED_Peer **testbed_peers; 63static struct GNUNET_TESTBED_Peer **testbed_peers;
64 64
65/**
66 * @brief Indicates whether peer should go off- or online
67 */
68enum PEER_ONLINE_DELTA {
69 /**
70 * @brief Indicates peer going online
71 */
72 PEER_GO_ONLINE = 1,
73 /**
74 * @brief Indicates peer going offline
75 */
76 PEER_GO_OFFLINE = -1,
77};
65 78
66/** 79/**
67 * Operation map entry 80 * Operation map entry
@@ -84,10 +97,10 @@ struct OpListEntry
84 struct GNUNET_TESTBED_Operation *op; 97 struct GNUNET_TESTBED_Operation *op;
85 98
86 /** 99 /**
87 * Depending on whether we start or stop RPS service at the peer set this to 1 (start) 100 * Depending on whether we start or stop RPS service at the peer, set this to
88 * or -1 (stop) 101 * #PEER_GO_ONLINE (1) or #PEER_GO_OFFLINE (-1)
89 */ 102 */
90 int delta; 103 enum PEER_ONLINE_DELTA delta;
91 104
92 /** 105 /**
93 * Index of the regarding peer 106 * Index of the regarding peer
@@ -1181,7 +1194,7 @@ churn_cb (void *cls,
1181 1194
1182 num_peers_online += entry->delta; 1195 num_peers_online += entry->delta;
1183 1196
1184 if (-1 == entry->delta) 1197 if (PEER_GO_OFFLINE == entry->delta)
1185 { /* Peer hopefully just went offline */ 1198 { /* Peer hopefully just went offline */
1186 if (GNUNET_YES != rps_peers[entry->index].online) 1199 if (GNUNET_YES != rps_peers[entry->index].online)
1187 { 1200 {
@@ -1199,7 +1212,7 @@ churn_cb (void *cls,
1199 rps_peers[entry->index].online = GNUNET_NO; 1212 rps_peers[entry->index].online = GNUNET_NO;
1200 } 1213 }
1201 1214
1202 else if (0 < entry->delta) 1215 else if (PEER_GO_ONLINE < entry->delta)
1203 { /* Peer hopefully just went online */ 1216 { /* Peer hopefully just went online */
1204 if (GNUNET_NO != rps_peers[entry->index].online) 1217 if (GNUNET_NO != rps_peers[entry->index].online)
1205 { 1218 {
@@ -1239,16 +1252,15 @@ churn_cb (void *cls,
1239/** 1252/**
1240 * @brief Set the rps-service up or down for a specific peer 1253 * @brief Set the rps-service up or down for a specific peer
1241 * 1254 *
1242 * TODO use enum instead of 1/-1 for delta
1243 *
1244 * @param i index of action 1255 * @param i index of action
1245 * @param j index of peer 1256 * @param j index of peer
1246 * @param delta down (-1) or up (1) 1257 * @param delta (#PEER_ONLINE_DELTA) down (-1) or up (1)
1247 * @param prob_go_on_off the probability of the action 1258 * @param prob_go_on_off the probability of the action
1248 */ 1259 */
1249static void 1260static void
1250manage_service_wrapper (unsigned int i, unsigned int j, int delta, 1261manage_service_wrapper (unsigned int i, unsigned int j,
1251 double prob_go_on_off) 1262 enum PEER_ONLINE_DELTA delta,
1263 double prob_go_on_off)
1252{ 1264{
1253 struct OpListEntry *entry; 1265 struct OpListEntry *entry;
1254 uint32_t prob; 1266 uint32_t prob;
@@ -1268,19 +1280,19 @@ manage_service_wrapper (unsigned int i, unsigned int j, int delta,
1268 i, 1280 i,
1269 j, 1281 j,
1270 GNUNET_i2s (rps_peers[j].peer_id), 1282 GNUNET_i2s (rps_peers[j].peer_id),
1271 (0 > delta) ? "online" : "offline"); 1283 (PEER_GO_ONLINE == delta) ? "online" : "offline");
1272 if (prob < prob_go_on_off * UINT32_MAX) 1284 if (prob < prob_go_on_off * UINT32_MAX)
1273 { 1285 {
1274 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1286 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1275 "%s goes %s\n", 1287 "%s goes %s\n",
1276 GNUNET_i2s (rps_peers[j].peer_id), 1288 GNUNET_i2s (rps_peers[j].peer_id),
1277 (0 > delta) ? "offline" : "online"); 1289 (PEER_GO_OFFLINE == delta) ? "offline" : "online");
1278 1290
1279 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1291 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1280 "testbed_peers points to %p, peer 0 to %p\n", 1292 "testbed_peers points to %p, peer 0 to %p\n",
1281 testbed_peers, testbed_peers[0]); 1293 testbed_peers, testbed_peers[0]);
1282 1294
1283 if (0 > delta) 1295 if (PEER_GO_OFFLINE == delta)
1284 cancel_pending_req_rep (&rps_peers[j]); 1296 cancel_pending_req_rep (&rps_peers[j]);
1285 entry = make_oplist_entry (); 1297 entry = make_oplist_entry ();
1286 entry->delta = delta; 1298 entry->delta = delta;
@@ -1290,7 +1302,7 @@ manage_service_wrapper (unsigned int i, unsigned int j, int delta,
1290 "rps", 1302 "rps",
1291 &churn_cb, 1303 &churn_cb,
1292 entry, 1304 entry,
1293 (0 > delta) ? 0 : 1); 1305 (PEER_GO_OFFLINE == delta) ? 0 : 1);
1294 } 1306 }
1295 rps_peers[j].entry_op_manage = entry; 1307 rps_peers[j].entry_op_manage = entry;
1296} 1308}