[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r26825 - gnunet/src/peerinfo
From: |
gnunet |
Subject: |
[GNUnet-SVN] r26825 - gnunet/src/peerinfo |
Date: |
Wed, 10 Apr 2013 11:20:38 +0200 |
Author: wachs
Date: 2013-04-10 11:20:38 +0200 (Wed, 10 Apr 2013)
New Revision: 26825
Modified:
gnunet/src/peerinfo/gnunet-service-peerinfo.c
gnunet/src/peerinfo/test_peerinfo_api_notify_friend_only.c
Log:
fix
Modified: gnunet/src/peerinfo/gnunet-service-peerinfo.c
===================================================================
--- gnunet/src/peerinfo/gnunet-service-peerinfo.c 2013-04-10 09:02:17 UTC
(rev 26824)
+++ gnunet/src/peerinfo/gnunet-service-peerinfo.c 2013-04-10 09:20:38 UTC
(rev 26825)
@@ -455,9 +455,10 @@
/**
- * 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 @@
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 @@
entry->friend_only_hello = r.friend_only_hello;
GNUNET_free (fn);
}
+ notify_all (entry);
}
return entry;
}
@@ -624,8 +627,6 @@
GNUNET_i2s (&id));
update_hello (&id, r.friend_only_hello);
}
-
- notify_all (entry);
dsc->matched++;
return GNUNET_OK;
}
Modified: gnunet/src/peerinfo/test_peerinfo_api_notify_friend_only.c
===================================================================
--- gnunet/src/peerinfo/test_peerinfo_api_notify_friend_only.c 2013-04-10
09:02:17 UTC (rev 26824)
+++ gnunet/src/peerinfo/test_peerinfo_api_notify_friend_only.c 2013-04-10
09:20:38 UTC (rev 26825)
@@ -57,6 +57,8 @@
*/
static int res_cb_wo_fo;
+struct GNUNET_PeerIdentity pid;
+
GNUNET_SCHEDULER_TaskIdentifier timeout_task;
@@ -142,6 +144,10 @@
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 @@
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 @@
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 @@
{
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 @@
add_peer ()
{
struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pkey;
- struct GNUNET_PeerIdentity pid;
struct GNUNET_HELLO_Message *h2;
size_t agc;
@@ -235,6 +249,8 @@
{
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 ();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r26825 - gnunet/src/peerinfo,
gnunet <=