aboutsummaryrefslogtreecommitdiff
path: root/src/rps
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2016-05-12 08:58:14 +0000
committerJulius Bünger <buenger@mytum.de>2016-05-12 08:58:14 +0000
commitc5ba5d0496597c4e2f3ae1fc393ebdf0971790d8 (patch)
tree69cb5eeeca85f4dd689b8bfeb47bb70dcc247fed /src/rps
parent44548b148c4198e9460b6503296ed8a62b61d19a (diff)
downloadgnunet-c5ba5d0496597c4e2f3ae1fc393ebdf0971790d8.tar.gz
gnunet-c5ba5d0496597c4e2f3ae1fc393ebdf0971790d8.zip
-rps: proper setting of "online" flag
Diffstat (limited to 'src/rps')
-rw-r--r--src/rps/gnunet-service-rps_peers.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/rps/gnunet-service-rps_peers.c b/src/rps/gnunet-service-rps_peers.c
index cbea0dac8..7a073c63f 100644
--- a/src/rps/gnunet-service-rps_peers.c
+++ b/src/rps/gnunet-service-rps_peers.c
@@ -284,6 +284,40 @@ create_or_get_peer_ctx (const struct GNUNET_PeerIdentity *peer)
284} 284}
285 285
286/** 286/**
287 * @brief Check whether we have a connection to this @a peer
288 *
289 * Also sets the #Peers_ONLINE flag accordingly
290 *
291 * @param peer the peer in question
292 *
293 * @return #GNUNET_YES if we are connected
294 * #GNUNET_NO otherwise
295 */
296int
297Peers_check_connected (const struct GNUNET_PeerIdentity *peer)
298{
299 const struct PeerContext *peer_ctx;
300
301 /* If we don't know about this peer we don't know whether it's online */
302 if (GNUNET_NO == Peers_check_peer_known (peer))
303 {
304 return GNUNET_NO;
305 }
306 /* Get the context */
307 peer_ctx = get_peer_ctx (peer);
308 /* If we have no channel to this peer we don't know whether it's online */
309 if ( (NULL == peer_ctx->send_channel) &&
310 (NULL == peer_ctx->recv_channel) )
311 {
312 Peers_unset_peer_flag (peer, Peers_ONLINE);
313 return GNUNET_NO;
314 }
315 /* Otherwise (if we have a channel, we know that it's online */
316 Peers_set_peer_flag (peer, Peers_ONLINE);
317 return GNUNET_YES;
318}
319
320/**
287 * @brief Set the peer flag to living and 321 * @brief Set the peer flag to living and
288 * call the pending operations on this peer. 322 * call the pending operations on this peer.
289 * 323 *
@@ -702,6 +736,7 @@ Peers_remove_peer (const struct GNUNET_PeerIdentity *peer)
702 LOG (GNUNET_ERROR_TYPE_DEBUG, 736 LOG (GNUNET_ERROR_TYPE_DEBUG,
703 "Going to remove peer %s\n", 737 "Going to remove peer %s\n",
704 GNUNET_i2s (&peer_ctx->peer_id)); 738 GNUNET_i2s (&peer_ctx->peer_id));
739 Peers_unset_peer_flag (peer, Peers_ONLINE);
705 740
706 GNUNET_array_grow (peer_ctx->pending_ops, peer_ctx->num_pending_ops, 0); 741 GNUNET_array_grow (peer_ctx->pending_ops, peer_ctx->num_pending_ops, 0);
707 // TODO delete struct GNUNET_TRANSPORT_TransmitHandle *transmit_handle 742 // TODO delete struct GNUNET_TRANSPORT_TransmitHandle *transmit_handle
@@ -1018,6 +1053,7 @@ Peers_destroy_sending_channel (const struct GNUNET_PeerIdentity *peer)
1018 set_channel_flag (peer_ctx->send_channel_flags, Peers_CHANNEL_CLEAN); 1053 set_channel_flag (peer_ctx->send_channel_flags, Peers_CHANNEL_CLEAN);
1019 GNUNET_CADET_channel_destroy (peer_ctx->send_channel); 1054 GNUNET_CADET_channel_destroy (peer_ctx->send_channel);
1020 peer_ctx->send_channel = NULL; 1055 peer_ctx->send_channel = NULL;
1056 (void) Peers_check_connected (peer);
1021 return GNUNET_YES; 1057 return GNUNET_YES;
1022 } 1058 }
1023 return GNUNET_NO; 1059 return GNUNET_NO;
@@ -1063,7 +1099,7 @@ Peers_cleanup_destroyed_channel (void *cls,
1063 peer_ctx->send_channel = NULL; 1099 peer_ctx->send_channel = NULL;
1064 else if (channel == peer_ctx->recv_channel) 1100 else if (channel == peer_ctx->recv_channel)
1065 peer_ctx->recv_channel = NULL; 1101 peer_ctx->recv_channel = NULL;
1066 1102 (void) Peers_check_connected (peer);
1067 return; 1103 return;
1068 } 1104 }
1069 1105
@@ -1090,6 +1126,7 @@ Peers_cleanup_destroyed_channel (void *cls,
1090 GNUNET_i2s (peer)); 1126 GNUNET_i2s (peer));
1091 } 1127 }
1092 } 1128 }
1129 (void) Peers_check_connected (peer);
1093} 1130}
1094 1131
1095/** 1132/**