summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-04-10 09:20:38 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-04-10 09:20:38 +0000
commit6c81d165a39ae62bb250bb37af31bb2ea858f65f (patch)
tree07939f69016ec1db3a6a851656d089cd08227f24 /src
parent60c01495b1f945b9755d72261f1c6f5ea8ea1fda (diff)
fix
Diffstat (limited to 'src')
-rw-r--r--src/peerinfo/gnunet-service-peerinfo.c7
-rw-r--r--src/peerinfo/test_peerinfo_api_notify_friend_only.c40
2 files changed, 32 insertions, 15 deletions
diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c
index d08f9920c..ce7a38a6d 100644
--- a/src/peerinfo/gnunet-service-peerinfo.c
+++ b/src/peerinfo/gnunet-service-peerinfo.c
@@ -455,9 +455,10 @@ read_host_file (const char *fn, int unlink_garbage, struct ReadHostFileContext *
/**
- * Add a host to the list.
+ * Add a host to the list and notify clients about this event
*
* @param identity the identity of the host
+ * @return the HostEntry
*/
static struct HostEntry *
add_host_to_known_hosts (const struct GNUNET_PeerIdentity *identity)
@@ -469,6 +470,7 @@ add_host_to_known_hosts (const struct GNUNET_PeerIdentity *identity)
entry = GNUNET_CONTAINER_multihashmap_get (hostmap, &identity->hashPubKey);
if (NULL == entry)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding new peer `%s'\n", GNUNET_i2s (identity));
GNUNET_STATISTICS_update (stats, gettext_noop ("# peers known"), 1,
GNUNET_NO);
entry = GNUNET_malloc (sizeof (struct HostEntry));
@@ -484,6 +486,7 @@ add_host_to_known_hosts (const struct GNUNET_PeerIdentity *identity)
entry->friend_only_hello = r.friend_only_hello;
GNUNET_free (fn);
}
+ notify_all (entry);
}
return entry;
}
@@ -624,8 +627,6 @@ hosts_directory_scan_callback (void *cls, const char *fullname)
GNUNET_i2s (&id));
update_hello (&id, r.friend_only_hello);
}
-
- notify_all (entry);
dsc->matched++;
return GNUNET_OK;
}
diff --git a/src/peerinfo/test_peerinfo_api_notify_friend_only.c b/src/peerinfo/test_peerinfo_api_notify_friend_only.c
index 3afd50e68..700bac755 100644
--- a/src/peerinfo/test_peerinfo_api_notify_friend_only.c
+++ b/src/peerinfo/test_peerinfo_api_notify_friend_only.c
@@ -57,6 +57,8 @@ static int res_cb_w_fo;
*/
static int res_cb_wo_fo;
+struct GNUNET_PeerIdentity pid;
+
GNUNET_SCHEDULER_TaskIdentifier timeout_task;
@@ -142,6 +144,10 @@ process_w_fo (void *cls, const struct GNUNET_PeerIdentity *peer,
if (NULL != peer)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Received callback for peer `%s' %s HELLO\n",
+ GNUNET_i2s (peer),
+ (NULL != hello) ? "with" : "without");
+
if (NULL == hello)
return;
@@ -151,10 +157,14 @@ process_w_fo (void *cls, const struct GNUNET_PeerIdentity *peer,
return;
}
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Received %s HELLO\n",
- (GNUNET_YES == GNUNET_HELLO_is_friend_only (hello)) ? "friend only" : "public");
- res_cb_w_fo = GNUNET_YES;
- GNUNET_SCHEDULER_add_now(&done, NULL);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Received %s HELLO for peer `%s'\n",
+ (GNUNET_YES == GNUNET_HELLO_is_friend_only (hello)) ? "friend only" : "public",
+ GNUNET_i2s (peer));
+ if (0 == memcmp (&pid, peer, sizeof (pid)))
+ {
+ res_cb_w_fo = GNUNET_YES;
+ GNUNET_SCHEDULER_add_now(&done, NULL);
+ }
return;
}
}
@@ -173,20 +183,27 @@ process_wo_fo (void *cls, const struct GNUNET_PeerIdentity *peer,
if (NULL != peer)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Received callback for peer `%s' %s HELLO\n",
+ GNUNET_i2s (peer),
+ (NULL != hello) ? "with" : "without");
+
if (NULL == hello)
return;
- GNUNET_break (0);
-
if (GNUNET_YES == GNUNET_HELLO_is_friend_only(hello))
{
GNUNET_break (0);
return;
}
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Received %s HELLO\n",
- (GNUNET_YES == GNUNET_HELLO_is_friend_only (hello)) ? "friend only" : "public");
- res_cb_wo_fo = GNUNET_YES;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Received %s HELLO for peer `%s'\n",
+ (GNUNET_YES == GNUNET_HELLO_is_friend_only (hello)) ? "friend only" : "public",
+ GNUNET_i2s (peer));
+ if (0 == memcmp (&pid, peer, sizeof (pid)))
+ {
+ GNUNET_break (0);
+ res_cb_wo_fo = GNUNET_YES;
+ }
}
}
@@ -195,8 +212,6 @@ add_peer_done (void *cls, const char *emsg)
{
if (NULL == emsg)
{
- pnc_w_fo = GNUNET_PEERINFO_notify (mycfg, GNUNET_YES, &process_w_fo, NULL);
- pnc_wo_fo = GNUNET_PEERINFO_notify (mycfg, GNUNET_NO, &process_wo_fo, NULL);
return;
}
else
@@ -213,7 +228,6 @@ static void
add_peer ()
{
struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pkey;
- struct GNUNET_PeerIdentity pid;
struct GNUNET_HELLO_Message *h2;
size_t agc;
@@ -235,6 +249,8 @@ run (void *cls,
{
timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
mycfg = cfg;
+ pnc_w_fo = GNUNET_PEERINFO_notify (mycfg, GNUNET_YES, &process_w_fo, NULL);
+ pnc_wo_fo = GNUNET_PEERINFO_notify (mycfg, GNUNET_NO, &process_wo_fo, NULL);
h = GNUNET_PEERINFO_connect (cfg);
GNUNET_assert (NULL != h);
add_peer ();