aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2018-10-01 20:06:53 +0200
committerJulius Bünger <buenger@mytum.de>2018-10-01 23:15:32 +0200
commit4ac7b35eb3126485ac69c6d930c18a78b7b9a860 (patch)
tree3ec01bad9d2b059be038da99e8f5c44a929f53a0 /src
parent3823c7a71aa1b16df6c34ef3def45875289a6b3d (diff)
downloadgnunet-4ac7b35eb3126485ac69c6d930c18a78b7b9a860.tar.gz
gnunet-4ac7b35eb3126485ac69c6d930c18a78b7b9a860.zip
Change terminology: "live" -> "online"
Diffstat (limited to 'src')
-rw-r--r--src/rps/gnunet-service-rps.c113
1 files changed, 57 insertions, 56 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index 5abbc692f..07b88ddcd 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -144,7 +144,7 @@ struct ChannelCtx;
144 * This is stored in a multipeermap. 144 * This is stored in a multipeermap.
145 * It contains information such as cadet channels, a message queue for sending, 145 * It contains information such as cadet channels, a message queue for sending,
146 * status about the channels, the pending operations on this peer and some flags 146 * status about the channels, the pending operations on this peer and some flags
147 * about the status of the peer itself. (live, valid, ...) 147 * about the status of the peer itself. (online, valid, ...)
148 */ 148 */
149struct PeerContext 149struct PeerContext
150{ 150{
@@ -173,7 +173,7 @@ struct PeerContext
173 * 173 *
174 * To be canceled on shutdown. 174 * To be canceled on shutdown.
175 */ 175 */
176 struct PendingMessage *liveliness_check_pending; 176 struct PendingMessage *online_check_pending;
177 177
178 /** 178 /**
179 * Number of pending operations. 179 * Number of pending operations.
@@ -774,29 +774,29 @@ remove_pending_message (struct PendingMessage *pending_msg, int cancel);
774 * 774 *
775 * Also adds peer to #valid_peers. 775 * Also adds peer to #valid_peers.
776 * 776 *
777 * @param peer_ctx the #PeerContext of the peer to set live 777 * @param peer_ctx the #PeerContext of the peer to set online
778 */ 778 */
779static void 779static void
780set_peer_live (struct PeerContext *peer_ctx) 780set_peer_online (struct PeerContext *peer_ctx)
781{ 781{
782 struct GNUNET_PeerIdentity *peer; 782 struct GNUNET_PeerIdentity *peer;
783 unsigned int i; 783 unsigned int i;
784 784
785 peer = &peer_ctx->peer_id; 785 peer = &peer_ctx->peer_id;
786 LOG (GNUNET_ERROR_TYPE_DEBUG, 786 LOG (GNUNET_ERROR_TYPE_DEBUG,
787 "Peer %s is live and valid, calling %i pending operations on it\n", 787 "Peer %s is online and valid, calling %i pending operations on it\n",
788 GNUNET_i2s (peer), 788 GNUNET_i2s (peer),
789 peer_ctx->num_pending_ops); 789 peer_ctx->num_pending_ops);
790 790
791 if (NULL != peer_ctx->liveliness_check_pending) 791 if (NULL != peer_ctx->online_check_pending)
792 { 792 {
793 LOG (GNUNET_ERROR_TYPE_DEBUG, 793 LOG (GNUNET_ERROR_TYPE_DEBUG,
794 "Removing pending liveliness check for peer %s\n", 794 "Removing pending online check for peer %s\n",
795 GNUNET_i2s (&peer_ctx->peer_id)); 795 GNUNET_i2s (&peer_ctx->peer_id));
796 // TODO wait until cadet sets mq->cancel_impl 796 // TODO wait until cadet sets mq->cancel_impl
797 //GNUNET_MQ_send_cancel (peer_ctx->liveliness_check_pending->ev); 797 //GNUNET_MQ_send_cancel (peer_ctx->online_check_pending->ev);
798 remove_pending_message (peer_ctx->liveliness_check_pending, GNUNET_YES); 798 remove_pending_message (peer_ctx->online_check_pending, GNUNET_YES);
799 peer_ctx->liveliness_check_pending = NULL; 799 peer_ctx->online_check_pending = NULL;
800 } 800 }
801 801
802 (void) add_valid_peer (peer); 802 (void) add_valid_peer (peer);
@@ -1022,51 +1022,51 @@ remove_pending_message (struct PendingMessage *pending_msg, int cancel)
1022 1022
1023/** 1023/**
1024 * @brief This is called in response to the first message we sent as a 1024 * @brief This is called in response to the first message we sent as a
1025 * liveliness check. 1025 * online check.
1026 * 1026 *
1027 * @param cls #PeerContext of peer with pending liveliness check 1027 * @param cls #PeerContext of peer with pending online check
1028 */ 1028 */
1029static void 1029static void
1030mq_liveliness_check_successful (void *cls) 1030mq_online_check_successful (void *cls)
1031{ 1031{
1032 struct PeerContext *peer_ctx = cls; 1032 struct PeerContext *peer_ctx = cls;
1033 1033
1034 if (NULL != peer_ctx->liveliness_check_pending) 1034 if (NULL != peer_ctx->online_check_pending)
1035 { 1035 {
1036 LOG (GNUNET_ERROR_TYPE_DEBUG, 1036 LOG (GNUNET_ERROR_TYPE_DEBUG,
1037 "Liveliness check for peer %s was successfull\n", 1037 "Online check for peer %s was successfull\n",
1038 GNUNET_i2s (&peer_ctx->peer_id)); 1038 GNUNET_i2s (&peer_ctx->peer_id));
1039 remove_pending_message (peer_ctx->liveliness_check_pending, GNUNET_YES); 1039 remove_pending_message (peer_ctx->online_check_pending, GNUNET_YES);
1040 peer_ctx->liveliness_check_pending = NULL; 1040 peer_ctx->online_check_pending = NULL;
1041 set_peer_live (peer_ctx); 1041 set_peer_online (peer_ctx);
1042 } 1042 }
1043} 1043}
1044 1044
1045/** 1045/**
1046 * Issue a check whether peer is live 1046 * Issue a check whether peer is online
1047 * 1047 *
1048 * @param peer_ctx the context of the peer 1048 * @param peer_ctx the context of the peer
1049 */ 1049 */
1050static void 1050static void
1051check_peer_live (struct PeerContext *peer_ctx) 1051check_peer_online (struct PeerContext *peer_ctx)
1052{ 1052{
1053 LOG (GNUNET_ERROR_TYPE_DEBUG, 1053 LOG (GNUNET_ERROR_TYPE_DEBUG,
1054 "Get informed about peer %s getting live\n", 1054 "Get informed about peer %s getting online\n",
1055 GNUNET_i2s (&peer_ctx->peer_id)); 1055 GNUNET_i2s (&peer_ctx->peer_id));
1056 1056
1057 struct GNUNET_MQ_Handle *mq; 1057 struct GNUNET_MQ_Handle *mq;
1058 struct GNUNET_MQ_Envelope *ev; 1058 struct GNUNET_MQ_Envelope *ev;
1059 1059
1060 ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_RPS_PP_CHECK_LIVE); 1060 ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_RPS_PP_CHECK_LIVE);
1061 peer_ctx->liveliness_check_pending = 1061 peer_ctx->online_check_pending =
1062 insert_pending_message (&peer_ctx->peer_id, ev, "Check liveliness"); 1062 insert_pending_message (&peer_ctx->peer_id, ev, "Check online");
1063 mq = get_mq (&peer_ctx->peer_id); 1063 mq = get_mq (&peer_ctx->peer_id);
1064 GNUNET_MQ_notify_sent (ev, 1064 GNUNET_MQ_notify_sent (ev,
1065 mq_liveliness_check_successful, 1065 mq_online_check_successful,
1066 peer_ctx); 1066 peer_ctx);
1067 GNUNET_MQ_send (mq, ev); 1067 GNUNET_MQ_send (mq, ev);
1068 GNUNET_STATISTICS_update (stats, 1068 GNUNET_STATISTICS_update (stats,
1069 "# pending liveliness checks", 1069 "# pending online checks",
1070 1, 1070 1,
1071 GNUNET_NO); 1071 GNUNET_NO);
1072} 1072}
@@ -1199,14 +1199,14 @@ destroy_peer (struct PeerContext *peer_ctx)
1199 "Removing unsent %s\n", 1199 "Removing unsent %s\n",
1200 peer_ctx->pending_messages_head->type); 1200 peer_ctx->pending_messages_head->type);
1201 /* Cancle pending message, too */ 1201 /* Cancle pending message, too */
1202 if ( (NULL != peer_ctx->liveliness_check_pending) && 1202 if ( (NULL != peer_ctx->online_check_pending) &&
1203 (0 == memcmp (peer_ctx->pending_messages_head, 1203 (0 == memcmp (peer_ctx->pending_messages_head,
1204 peer_ctx->liveliness_check_pending, 1204 peer_ctx->online_check_pending,
1205 sizeof (struct PendingMessage))) ) 1205 sizeof (struct PendingMessage))) )
1206 { 1206 {
1207 peer_ctx->liveliness_check_pending = NULL; 1207 peer_ctx->online_check_pending = NULL;
1208 GNUNET_STATISTICS_update (stats, 1208 GNUNET_STATISTICS_update (stats,
1209 "# pending liveliness checks", 1209 "# pending online checks",
1210 -1, 1210 -1,
1211 GNUNET_NO); 1211 GNUNET_NO);
1212 } 1212 }
@@ -1214,18 +1214,18 @@ destroy_peer (struct PeerContext *peer_ctx)
1214 GNUNET_YES); 1214 GNUNET_YES);
1215 } 1215 }
1216 1216
1217 /* If we are still waiting for notification whether this peer is live 1217 /* If we are still waiting for notification whether this peer is online
1218 * cancel the according task */ 1218 * cancel the according task */
1219 if (NULL != peer_ctx->liveliness_check_pending) 1219 if (NULL != peer_ctx->online_check_pending)
1220 { 1220 {
1221 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1221 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1222 "Removing pending liveliness check for peer %s\n", 1222 "Removing pending online check for peer %s\n",
1223 GNUNET_i2s (&peer_ctx->peer_id)); 1223 GNUNET_i2s (&peer_ctx->peer_id));
1224 // TODO wait until cadet sets mq->cancel_impl 1224 // TODO wait until cadet sets mq->cancel_impl
1225 //GNUNET_MQ_send_cancel (peer_ctx->liveliness_check_pending->ev); 1225 //GNUNET_MQ_send_cancel (peer_ctx->online_check_pending->ev);
1226 remove_pending_message (peer_ctx->liveliness_check_pending, 1226 remove_pending_message (peer_ctx->online_check_pending,
1227 GNUNET_YES); 1227 GNUNET_YES);
1228 peer_ctx->liveliness_check_pending = NULL; 1228 peer_ctx->online_check_pending = NULL;
1229 } 1229 }
1230 1230
1231 if (NULL != peer_ctx->send_channel_ctx) 1231 if (NULL != peer_ctx->send_channel_ctx)
@@ -1639,21 +1639,21 @@ check_peer_flag (const struct GNUNET_PeerIdentity *peer,
1639 * 1639 *
1640 * If not known yet, insert into known peers 1640 * If not known yet, insert into known peers
1641 * 1641 *
1642 * @param peer the peer whose liveliness is to be checked 1642 * @param peer the peer whose online is to be checked
1643 * @return #GNUNET_YES if the check was issued 1643 * @return #GNUNET_YES if the check was issued
1644 * #GNUNET_NO otherwise 1644 * #GNUNET_NO otherwise
1645 */ 1645 */
1646static int 1646static int
1647issue_peer_liveliness_check (const struct GNUNET_PeerIdentity *peer) 1647issue_peer_online_check (const struct GNUNET_PeerIdentity *peer)
1648{ 1648{
1649 struct PeerContext *peer_ctx; 1649 struct PeerContext *peer_ctx;
1650 1650
1651 (void) insert_peer (peer); 1651 (void) insert_peer (peer);
1652 peer_ctx = get_peer_ctx (peer); 1652 peer_ctx = get_peer_ctx (peer);
1653 if ( (GNUNET_NO == check_peer_flag (peer, Peers_ONLINE)) && 1653 if ( (GNUNET_NO == check_peer_flag (peer, Peers_ONLINE)) &&
1654 (NULL == peer_ctx->liveliness_check_pending) ) 1654 (NULL == peer_ctx->online_check_pending) )
1655 { 1655 {
1656 check_peer_live (peer_ctx); 1656 check_peer_online (peer_ctx);
1657 return GNUNET_YES; 1657 return GNUNET_YES;
1658 } 1658 }
1659 return GNUNET_NO; 1659 return GNUNET_NO;
@@ -1775,7 +1775,7 @@ handle_inbound_channel (void *cls,
1775 GNUNET_assert (NULL != channel); /* according to cadet API */ 1775 GNUNET_assert (NULL != channel); /* according to cadet API */
1776 /* Make sure we 'know' about this peer */ 1776 /* Make sure we 'know' about this peer */
1777 peer_ctx = create_or_get_peer_ctx (initiator); 1777 peer_ctx = create_or_get_peer_ctx (initiator);
1778 set_peer_live (peer_ctx); 1778 set_peer_online (peer_ctx);
1779 ctx_peer = GNUNET_new (struct GNUNET_PeerIdentity); 1779 ctx_peer = GNUNET_new (struct GNUNET_PeerIdentity);
1780 *ctx_peer = *initiator; 1780 *ctx_peer = *initiator;
1781 channel_ctx = add_channel_ctx (peer_ctx); 1781 channel_ctx = add_channel_ctx (peer_ctx);
@@ -1884,7 +1884,8 @@ send_message (const struct GNUNET_PeerIdentity *peer,
1884 * 1884 *
1885 * Avoids scheduling an operation twice. 1885 * Avoids scheduling an operation twice.
1886 * 1886 *
1887 * @param peer the peer we want to schedule the operation for once it gets live 1887 * @param peer the peer we want to schedule the operation for once it gets
1888 * online
1888 * 1889 *
1889 * @return #GNUNET_YES if the operation was scheduled 1890 * @return #GNUNET_YES if the operation was scheduled
1890 * #GNUNET_NO otherwise 1891 * #GNUNET_NO otherwise
@@ -1898,7 +1899,7 @@ schedule_operation (const struct GNUNET_PeerIdentity *peer,
1898 1899
1899 GNUNET_assert (GNUNET_YES == check_peer_known (peer)); 1900 GNUNET_assert (GNUNET_YES == check_peer_known (peer));
1900 1901
1901 //TODO if LIVE/ONLINE execute immediately 1902 //TODO if ONLINE execute immediately
1902 1903
1903 if (GNUNET_NO == check_operation_scheduled (peer, peer_op)) 1904 if (GNUNET_NO == check_operation_scheduled (peer, peer_op))
1904 { 1905 {
@@ -2063,7 +2064,7 @@ rem_from_list (struct GNUNET_PeerIdentity **peer_list,
2063/** 2064/**
2064 * Insert PeerID in #view 2065 * Insert PeerID in #view
2065 * 2066 *
2066 * Called once we know a peer is live. 2067 * Called once we know a peer is online.
2067 * Implements #PeerOp 2068 * Implements #PeerOp
2068 * 2069 *
2069 * @return GNUNET_OK if peer was actually inserted 2070 * @return GNUNET_OK if peer was actually inserted
@@ -2076,7 +2077,7 @@ insert_in_view_op (void *cls,
2076/** 2077/**
2077 * Insert PeerID in #view 2078 * Insert PeerID in #view
2078 * 2079 *
2079 * Called once we know a peer is live. 2080 * Called once we know a peer is online.
2080 * 2081 *
2081 * @return GNUNET_OK if peer was actually inserted 2082 * @return GNUNET_OK if peer was actually inserted
2082 * GNUNET_NO if peer was not inserted 2083 * GNUNET_NO if peer was not inserted
@@ -2091,7 +2092,7 @@ insert_in_view (const struct GNUNET_PeerIdentity *peer)
2091 if ( (GNUNET_NO == online) || 2092 if ( (GNUNET_NO == online) ||
2092 (GNUNET_SYSERR == online) ) /* peer is not even known */ 2093 (GNUNET_SYSERR == online) ) /* peer is not even known */
2093 { 2094 {
2094 (void) issue_peer_liveliness_check (peer); 2095 (void) issue_peer_online_check (peer);
2095 (void) schedule_operation (peer, insert_in_view_op); 2096 (void) schedule_operation (peer, insert_in_view_op);
2096 return GNUNET_NO; 2097 return GNUNET_NO;
2097 } 2098 }
@@ -2378,7 +2379,7 @@ send_pull_reply (const struct GNUNET_PeerIdentity *peer_id,
2378/** 2379/**
2379 * Insert PeerID in #pull_map 2380 * Insert PeerID in #pull_map
2380 * 2381 *
2381 * Called once we know a peer is live. 2382 * Called once we know a peer is online.
2382 */ 2383 */
2383static void 2384static void
2384insert_in_pull_map (void *cls, 2385insert_in_pull_map (void *cls,
@@ -2392,7 +2393,7 @@ insert_in_pull_map (void *cls,
2392/** 2393/**
2393 * Insert PeerID in #view 2394 * Insert PeerID in #view
2394 * 2395 *
2395 * Called once we know a peer is live. 2396 * Called once we know a peer is online.
2396 * Implements #PeerOp 2397 * Implements #PeerOp
2397 */ 2398 */
2398static void 2399static void
@@ -2426,7 +2427,7 @@ insert_in_sampler (void *cls,
2426 if (0 < RPS_sampler_count_id (mss->sampler, peer)) 2427 if (0 < RPS_sampler_count_id (mss->sampler, peer))
2427 { 2428 {
2428 /* Make sure we 'know' about this peer */ 2429 /* Make sure we 'know' about this peer */
2429 (void) issue_peer_liveliness_check (peer); 2430 (void) issue_peer_online_check (peer);
2430 /* Establish a channel towards that peer to indicate we are going to send 2431 /* Establish a channel towards that peer to indicate we are going to send
2431 * messages to it */ 2432 * messages to it */
2432 //indicate_sending_intention (peer); 2433 //indicate_sending_intention (peer);
@@ -2450,7 +2451,7 @@ insert_in_sampler (void *cls,
2450 2451
2451/** 2452/**
2452 * @brief This is called on peers from external sources (cadet, peerinfo, ...) 2453 * @brief This is called on peers from external sources (cadet, peerinfo, ...)
2453 * If the peer is not known, liveliness check is issued and it is 2454 * If the peer is not known, online check is issued and it is
2454 * scheduled to be inserted in sampler and view. 2455 * scheduled to be inserted in sampler and view.
2455 * 2456 *
2456 * "External sources" refer to every source except the gossip. 2457 * "External sources" refer to every source except the gossip.
@@ -2461,7 +2462,7 @@ static void
2461got_peer (const struct GNUNET_PeerIdentity *peer) 2462got_peer (const struct GNUNET_PeerIdentity *peer)
2462{ 2463{
2463 /* If we did not know this peer already, insert it into sampler and view */ 2464 /* If we did not know this peer already, insert it into sampler and view */
2464 if (GNUNET_YES == issue_peer_liveliness_check (peer)) 2465 if (GNUNET_YES == issue_peer_online_check (peer))
2465 { 2466 {
2466 schedule_operation (peer, insert_in_sampler); 2467 schedule_operation (peer, insert_in_sampler);
2467 schedule_operation (peer, insert_in_view_op); 2468 schedule_operation (peer, insert_in_view_op);
@@ -2939,7 +2940,7 @@ handle_peer_check (void *cls,
2939 LOG (GNUNET_ERROR_TYPE_DEBUG, 2940 LOG (GNUNET_ERROR_TYPE_DEBUG,
2940 "Received CHECK_LIVE (%s)\n", GNUNET_i2s (peer)); 2941 "Received CHECK_LIVE (%s)\n", GNUNET_i2s (peer));
2941 GNUNET_STATISTICS_update (stats, 2942 GNUNET_STATISTICS_update (stats,
2942 "# pending liveliness checks", 2943 "# pending online checks",
2943 -1, 2944 -1,
2944 GNUNET_NO); 2945 GNUNET_NO);
2945 2946
@@ -3173,7 +3174,7 @@ handle_peer_pull_reply (void *cls,
3173 else 3174 else
3174 { 3175 {
3175 schedule_operation (&peers[i], insert_in_pull_map); 3176 schedule_operation (&peers[i], insert_in_pull_map);
3176 (void) issue_peer_liveliness_check (&peers[i]); 3177 (void) issue_peer_online_check (&peers[i]);
3177 } 3178 }
3178 } 3179 }
3179 3180
@@ -3399,7 +3400,7 @@ handle_client_act_malicious (void *cls,
3399 /* Set the flag of the attacked peer to valid to avoid problems */ 3400 /* Set the flag of the attacked peer to valid to avoid problems */
3400 if (GNUNET_NO == check_peer_known (&attacked_peer)) 3401 if (GNUNET_NO == check_peer_known (&attacked_peer))
3401 { 3402 {
3402 (void) issue_peer_liveliness_check (&attacked_peer); 3403 (void) issue_peer_online_check (&attacked_peer);
3403 } 3404 }
3404 3405
3405 LOG (GNUNET_ERROR_TYPE_DEBUG, 3406 LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -3490,7 +3491,7 @@ do_mal_round (void *cls)
3490 * Send as many pushes to the attacked peer as possible 3491 * Send as many pushes to the attacked peer as possible
3491 * That is one push per round as it will ignore more. 3492 * That is one push per round as it will ignore more.
3492 */ 3493 */
3493 (void) issue_peer_liveliness_check (&attacked_peer); 3494 (void) issue_peer_online_check (&attacked_peer);
3494 if (GNUNET_YES == check_peer_flag (&attacked_peer, Peers_ONLINE)) 3495 if (GNUNET_YES == check_peer_flag (&attacked_peer, Peers_ONLINE))
3495 send_push (&attacked_peer); 3496 send_push (&attacked_peer);
3496 } 3497 }
@@ -3502,7 +3503,7 @@ do_mal_round (void *cls)
3502 /* Send PUSH to attacked peers */ 3503 /* Send PUSH to attacked peers */
3503 if (GNUNET_YES == check_peer_known (&attacked_peer)) 3504 if (GNUNET_YES == check_peer_known (&attacked_peer))
3504 { 3505 {
3505 (void) issue_peer_liveliness_check (&attacked_peer); 3506 (void) issue_peer_online_check (&attacked_peer);
3506 if (GNUNET_YES == check_peer_flag (&attacked_peer, Peers_ONLINE)) 3507 if (GNUNET_YES == check_peer_flag (&attacked_peer, Peers_ONLINE))
3507 { 3508 {
3508 LOG (GNUNET_ERROR_TYPE_DEBUG, 3509 LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -3511,7 +3512,7 @@ do_mal_round (void *cls)
3511 send_push (&attacked_peer); 3512 send_push (&attacked_peer);
3512 } 3513 }
3513 } 3514 }
3514 (void) issue_peer_liveliness_check (&attacked_peer); 3515 (void) issue_peer_online_check (&attacked_peer);
3515 3516
3516 /* The maximum of pushes we're going to send this round */ 3517 /* The maximum of pushes we're going to send this round */
3517 num_pushes = GNUNET_MIN (GNUNET_MIN (push_limit - 1, 3518 num_pushes = GNUNET_MIN (GNUNET_MIN (push_limit - 1,