diff options
author | Julius Bünger <buenger@mytum.de> | 2015-02-15 17:19:27 +0000 |
---|---|---|
committer | Julius Bünger <buenger@mytum.de> | 2015-02-15 17:19:27 +0000 |
commit | c36764e318a6cbf1adceb2a56ff756b3d0fecaf7 (patch) | |
tree | 3c78255f707eed3b8d73c3ad9f1340e6edf0c528 /src | |
parent | 4242db96e6e4dc394cc2d325aff0ec24b8750b50 (diff) | |
download | gnunet-c36764e318a6cbf1adceb2a56ff756b3d0fecaf7.tar.gz gnunet-c36764e318a6cbf1adceb2a56ff756b3d0fecaf7.zip |
- macro for getting/setting peer flags
Diffstat (limited to 'src')
-rw-r--r-- | src/rps/gnunet-service-rps.c | 54 |
1 files changed, 45 insertions, 9 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c index b5ced6f33..88fe5521a 100644 --- a/src/rps/gnunet-service-rps.c +++ b/src/rps/gnunet-service-rps.c | |||
@@ -185,6 +185,10 @@ struct PeerContext | |||
185 | * /Housekeeping with peers | 185 | * /Housekeeping with peers |
186 | ***********************************************************************/ | 186 | ***********************************************************************/ |
187 | 187 | ||
188 | |||
189 | |||
190 | |||
191 | |||
188 | /*********************************************************************** | 192 | /*********************************************************************** |
189 | * Globals | 193 | * Globals |
190 | ***********************************************************************/ | 194 | ***********************************************************************/ |
@@ -357,11 +361,32 @@ uint32_t num_hist_update_tasks; | |||
357 | ***********************************************************************/ | 361 | ***********************************************************************/ |
358 | 362 | ||
359 | 363 | ||
364 | |||
365 | |||
366 | |||
367 | |||
360 | /*********************************************************************** | 368 | /*********************************************************************** |
361 | * Util functions | 369 | * Util functions |
362 | ***********************************************************************/ | 370 | ***********************************************************************/ |
363 | 371 | ||
364 | /** | 372 | /** |
373 | * Set a peer flag of given peer context. | ||
374 | */ | ||
375 | #define set_peer_flag(peer_ctx, mask) (peer_ctx->peer_flags |= mask) | ||
376 | |||
377 | /** | ||
378 | * Get peer flag of given peer context. | ||
379 | */ | ||
380 | #define get_peer_flag(peer_ctx, mask) (peer_ctx->peer_flags & mask ? GNUNET_YES : GNUNET_NO) | ||
381 | |||
382 | /** | ||
383 | * Unset flag of given peer context. | ||
384 | */ | ||
385 | #define unset_peer_flag(peer_ctx, mask) (peer_ctx->peer_flags &= (~mask)) | ||
386 | |||
387 | |||
388 | |||
389 | /** | ||
365 | * Check if peer is already in peer array. | 390 | * Check if peer is already in peer array. |
366 | */ | 391 | */ |
367 | int | 392 | int |
@@ -435,7 +460,9 @@ get_rand_peer_ignore_list (const struct GNUNET_PeerIdentity *peer_list, | |||
435 | tmp_size = 0; | 460 | tmp_size = 0; |
436 | tmp_peer_list = NULL; | 461 | tmp_peer_list = NULL; |
437 | GNUNET_array_grow (tmp_peer_list, tmp_size, list_size); | 462 | GNUNET_array_grow (tmp_peer_list, tmp_size, list_size); |
438 | memcpy (tmp_peer_list, peer_list, list_size * sizeof (struct GNUNET_PeerIdentity)); | 463 | memcpy (tmp_peer_list, |
464 | peer_list, | ||
465 | list_size * sizeof (struct GNUNET_PeerIdentity)); | ||
439 | peer = GNUNET_new (struct GNUNET_PeerIdentity); | 466 | peer = GNUNET_new (struct GNUNET_PeerIdentity); |
440 | 467 | ||
441 | /**; | 468 | /**; |
@@ -1127,7 +1154,7 @@ handle_peer_pull_reply (void *cls, | |||
1127 | // FIXME wait for cadet to change this function | 1154 | // FIXME wait for cadet to change this function |
1128 | sender_ctx = get_peer_ctx (peer_map, sender); | 1155 | sender_ctx = get_peer_ctx (peer_map, sender); |
1129 | 1156 | ||
1130 | if (0 == (sender_ctx->peer_flags || PULL_REPLY_PENDING)) | 1157 | if (0 == get_peer_flag (sender_ctx, PULL_REPLY_PENDING)) |
1131 | { | 1158 | { |
1132 | GNUNET_break_op (0); | 1159 | GNUNET_break_op (0); |
1133 | return GNUNET_OK; | 1160 | return GNUNET_OK; |
@@ -1147,12 +1174,14 @@ handle_peer_pull_reply (void *cls, | |||
1147 | { | 1174 | { |
1148 | out_op.op = insert_in_pull_list; | 1175 | out_op.op = insert_in_pull_list; |
1149 | out_op.op_cls = NULL; | 1176 | out_op.op_cls = NULL; |
1150 | GNUNET_array_append (peer_ctx->outstanding_ops, peer_ctx->num_outstanding_ops, out_op); | 1177 | GNUNET_array_append (peer_ctx->outstanding_ops, |
1178 | peer_ctx->num_outstanding_ops, | ||
1179 | out_op); | ||
1151 | } | 1180 | } |
1152 | } | 1181 | } |
1153 | 1182 | ||
1154 | sender_ctx->peer_flags &= (~PULL_REPLY_PENDING); | 1183 | unset_peer_flag (sender_ctx, PULL_REPLY_PENDING); |
1155 | rem_from_list (pending_pull_reply_list, &pending_pull_reply_list_size, sender); | 1184 | rem_from_list (&pending_pull_reply_list, &pending_pull_reply_list_size, sender); |
1156 | 1185 | ||
1157 | return GNUNET_OK; | 1186 | return GNUNET_OK; |
1158 | } | 1187 | } |
@@ -1355,7 +1384,8 @@ insertCB (void *cls, struct RPS_Sampler *sampler, | |||
1355 | 1384 | ||
1356 | 1385 | ||
1357 | /** | 1386 | /** |
1358 | * Close the connection to given peer and delete channel and mq. | 1387 | * Close the connection to given peer and delete channel and mq |
1388 | * if the peer is not anymore in the sampler. | ||
1359 | */ | 1389 | */ |
1360 | void | 1390 | void |
1361 | removeCB (void *cls, struct RPS_Sampler *sampler, | 1391 | removeCB (void *cls, struct RPS_Sampler *sampler, |
@@ -1415,20 +1445,26 @@ init_peer_cb (void *cls, | |||
1415 | 1445 | ||
1416 | // maybe create a function for that | 1446 | // maybe create a function for that |
1417 | peer_ctx = get_peer_ctx (peer_map, peer); | 1447 | peer_ctx = get_peer_ctx (peer_map, peer); |
1448 | // FIXME this peer might already be marked as LIVE | ||
1418 | if (GNUNET_NO == insert_in_sampler_scheduled (peer_ctx)) | 1449 | if (GNUNET_NO == insert_in_sampler_scheduled (peer_ctx)) |
1419 | { | 1450 | { |
1420 | out_op.op = insert_in_sampler; | 1451 | out_op.op = insert_in_sampler; |
1421 | GNUNET_array_append (peer_ctx->outstanding_ops, peer_ctx->num_outstanding_ops, out_op); | 1452 | out_op.op_cls = NULL; |
1453 | GNUNET_array_append (peer_ctx->outstanding_ops, | ||
1454 | peer_ctx->num_outstanding_ops, | ||
1455 | out_op); | ||
1422 | } | 1456 | } |
1423 | 1457 | ||
1424 | if (GNUNET_NO == insert_in_gossip_list_scheduled (peer_ctx)) | 1458 | if (GNUNET_NO == insert_in_gossip_list_scheduled (peer_ctx)) |
1425 | { | 1459 | { |
1426 | out_op.op = insert_in_gossip_list; | 1460 | out_op.op = insert_in_gossip_list; |
1427 | out_op.op_cls = NULL; | 1461 | out_op.op_cls = NULL; |
1428 | GNUNET_array_append (peer_ctx->outstanding_ops, peer_ctx->num_outstanding_ops, out_op); | 1462 | GNUNET_array_append (peer_ctx->outstanding_ops, |
1463 | peer_ctx->num_outstanding_ops, | ||
1464 | out_op); | ||
1429 | } | 1465 | } |
1430 | 1466 | ||
1431 | /* Issue livelyness test on peer */ | 1467 | /* Trigger livelyness test on peer */ |
1432 | (void) get_channel (peer_map, peer); | 1468 | (void) get_channel (peer_map, peer); |
1433 | 1469 | ||
1434 | // send push/pull to each of those peers? | 1470 | // send push/pull to each of those peers? |