[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r14103 - in gnunet/src: core dv hostlist include peerinfo p
From: |
gnunet |
Subject: |
[GNUnet-SVN] r14103 - in gnunet/src: core dv hostlist include peerinfo peerinfo-tool topology transport |
Date: |
Mon, 3 Jan 2011 15:21:25 +0100 |
Author: wachs
Date: 2011-01-03 15:21:25 +0100 (Mon, 03 Jan 2011)
New Revision: 14103
Modified:
gnunet/src/core/gnunet-service-core.c
gnunet/src/dv/gnunet-service-dv.c
gnunet/src/hostlist/hostlist-server.c
gnunet/src/include/gnunet_peerinfo_service.h
gnunet/src/peerinfo-tool/gnunet-peerinfo.c
gnunet/src/peerinfo/peerinfo_api.c
gnunet/src/peerinfo/peerinfo_api_notify.c
gnunet/src/peerinfo/perf_peerinfo_api.c
gnunet/src/peerinfo/test_peerinfo_api.c
gnunet/src/topology/gnunet-daemon-topology.c
gnunet/src/transport/gnunet-service-transport.c
Log:
Changed peerinfo api to distinguish between last element and timeout
Modified: gnunet/src/core/gnunet-service-core.c
===================================================================
--- gnunet/src/core/gnunet-service-core.c 2011-01-03 10:33:55 UTC (rev
14102)
+++ gnunet/src/core/gnunet-service-core.c 2011-01-03 14:21:25 UTC (rev
14103)
@@ -3006,10 +3006,18 @@
static void
process_hello_retry_send_key (void *cls,
const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Message *hello)
+ const struct GNUNET_HELLO_Message *hello,
+ const char *err_msg)
{
struct Neighbour *n = cls;
+ if (err_msg != NULL)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Error in communication with PEERINFO service\n"));
+ /* return; */
+ }
+
if (peer == NULL)
{
#if DEBUG_CORE
@@ -3318,11 +3326,19 @@
static void
process_hello_retry_handle_set_key (void *cls,
const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Message *hello)
+ const struct GNUNET_HELLO_Message *hello,
+ const char *err_msg)
{
struct Neighbour *n = cls;
struct SetKeyMessage *sm = n->skm;
+ if (err_msg != NULL)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Error in communication with PEERINFO service\n"));
+ /* return; */
+ }
+
if (peer == NULL)
{
n->skm = NULL;
Modified: gnunet/src/dv/gnunet-service-dv.c
===================================================================
--- gnunet/src/dv/gnunet-service-dv.c 2011-01-03 10:33:55 UTC (rev 14102)
+++ gnunet/src/dv/gnunet-service-dv.c 2011-01-03 14:21:25 UTC (rev 14103)
@@ -2806,11 +2806,13 @@
* @param cls closure
* @param peer id of the peer, NULL for last call
* @param hello hello message for the peer (can be NULL)
+ * @param err_msg NULL if successful, otherwise contains error message
*/
static void
process_peerinfo (void *cls,
const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Message *hello)
+ const struct GNUNET_HELLO_Message *hello,
+ const char *err_msg)
{
struct PeerIteratorContext *peerinfo_iterator = cls;
struct DirectNeighbor *neighbor = peerinfo_iterator->neighbor;
@@ -2819,7 +2821,12 @@
char *neighbor_pid;
#endif
int sent;
-
+ if (err_msg != NULL)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Error in communication with PEERINFO service\n"));
+ /* return; */
+ }
if (peer == NULL)
{
if (distant->pkey == NULL)
Modified: gnunet/src/hostlist/hostlist-server.c
===================================================================
--- gnunet/src/hostlist/hostlist-server.c 2011-01-03 10:33:55 UTC (rev
14102)
+++ gnunet/src/hostlist/hostlist-server.c 2011-01-03 14:21:25 UTC (rev
14103)
@@ -178,13 +178,21 @@
static void
host_processor (void *cls,
const struct GNUNET_PeerIdentity * peer,
- const struct GNUNET_HELLO_Message *hello)
+ const struct GNUNET_HELLO_Message *hello,
+ const char *err_msg)
{
struct HostSet *results = cls;
size_t old;
size_t s;
int has_addr;
+ if (err_msg != NULL)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Error in communication with PEERINFO service:\n
`%s'"), err_msg);
+ return;
+ }
+
if (peer == NULL)
{
pitr = NULL;
@@ -439,17 +447,25 @@
* @param cls closure (not used)
* @param peer potential peer to connect to
* @param hello HELLO for this peer (or NULL)
+ * @param err_msg NULL if successful, otherwise contains error message
*/
static void
process_notify (void *cls,
const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Message *hello)
+ const struct GNUNET_HELLO_Message *hello,
+ const char *err_msg)
{
struct HostSet *results;
#if DEBUG_HOSTLIST_SERVER
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peerinfo is notifying us to rebuild our hostlist\n");
#endif
+ if (err_msg != NULL)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Error in communication with PEERINFO service\n"));
+ /* return; */
+ }
results = GNUNET_malloc(sizeof(struct HostSet));
GNUNET_assert (peerinfo != NULL);
pitr = GNUNET_PEERINFO_iterate (peerinfo,
Modified: gnunet/src/include/gnunet_peerinfo_service.h
===================================================================
--- gnunet/src/include/gnunet_peerinfo_service.h 2011-01-03 10:33:55 UTC
(rev 14102)
+++ gnunet/src/include/gnunet_peerinfo_service.h 2011-01-03 14:21:25 UTC
(rev 14103)
@@ -95,11 +95,13 @@
* @param cls closure
* @param peer id of the peer, NULL for last call
* @param hello hello message for the peer (can be NULL)
+ * @param error message
*/
typedef void
(*GNUNET_PEERINFO_Processor) (void *cls,
const struct GNUNET_PeerIdentity * peer,
- const struct GNUNET_HELLO_Message * hello);
+ const struct GNUNET_HELLO_Message * hello,
+ const char * err_msg);
/**
Modified: gnunet/src/peerinfo/peerinfo_api.c
===================================================================
--- gnunet/src/peerinfo/peerinfo_api.c 2011-01-03 10:33:55 UTC (rev 14102)
+++ gnunet/src/peerinfo/peerinfo_api.c 2011-01-03 14:21:25 UTC (rev 14103)
@@ -385,15 +385,16 @@
ic->h->in_receive = GNUNET_NO;
if (msg == NULL)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- _("Failed to receive response from `%s' service.\n"),
- "PEERINFO");
+ char * err_msg;
+ GNUNET_asprintf(&err_msg,_("Failed to receive response from `%s'
service.\n"),"PEERINFO");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,err_msg);
reconnect (ic->h);
trigger_transmit (ic->h);
if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel (ic->timeout_task);
if (ic->callback != NULL)
- ic->callback (ic->callback_cls, NULL, NULL);
+ ic->callback (ic->callback_cls, NULL, NULL, err_msg);
+ GNUNET_free (err_msg);
GNUNET_free (ic);
return;
}
@@ -408,7 +409,7 @@
if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel (ic->timeout_task);
if (ic->callback != NULL)
- ic->callback (ic->callback_cls, NULL, NULL);
+ ic->callback (ic->callback_cls, NULL, NULL, NULL);
GNUNET_free (ic);
return;
}
@@ -416,13 +417,17 @@
if ((ms < sizeof (struct InfoMessage)) ||
(ntohs (msg->type) != GNUNET_MESSAGE_TYPE_PEERINFO_INFO))
{
+ char * err_msg;
+ GNUNET_asprintf(&err_msg,_("Received invalid message from `%s'
service.\n"),"PEERINFO");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,err_msg);
GNUNET_break (0);
reconnect (ic->h);
trigger_transmit (ic->h);
if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel (ic->timeout_task);
if (ic->callback != NULL)
- ic->callback (ic->callback_cls, NULL, NULL);
+ ic->callback (ic->callback_cls, NULL, NULL, err_msg);
+ GNUNET_free (err_msg);
GNUNET_free (ic);
return;
}
@@ -434,14 +439,17 @@
hello = (const struct GNUNET_HELLO_Message *) &im[1];
if (ms != sizeof (struct InfoMessage) + GNUNET_HELLO_size (hello))
{
- GNUNET_break (0);
+ char * err_msg;
+ GNUNET_asprintf(&err_msg,_("Received invalid message from `%s'
service.\n"),"PEERINFO");
+ GNUNET_break (0);
reconnect (ic->h);
trigger_transmit (ic->h);
if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel (ic->timeout_task);
if (ic->callback != NULL)
- ic->callback (ic->callback_cls, NULL, NULL);
+ ic->callback (ic->callback_cls, NULL, NULL, err_msg);
GNUNET_free (ic);
+ GNUNET_free (err_msg);
return;
}
}
@@ -455,7 +463,7 @@
#endif
ic->h->in_receive = GNUNET_YES;
if (ic->callback != NULL)
- ic->callback (ic->callback_cls, &im->peer, hello);
+ ic->callback (ic->callback_cls, &im->peer, hello, NULL);
GNUNET_CLIENT_receive (ic->h->client,
&peerinfo_handler,
ic,
@@ -478,10 +486,9 @@
if (GNUNET_OK != transmit_success)
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _("Failed to transmit iteration request to `%s' service
(%d).\n"),
- "PEERINFO",
- transmit_success);
+ char * err_msg;
+ GNUNET_asprintf(&err_msg,_("Failed to transmit iteration request to `%s'
service (%d).\n"),"PEERINFO",transmit_success);
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,err_msg);
if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK)
{
GNUNET_SCHEDULER_cancel (ic->timeout_task);
@@ -490,7 +497,8 @@
reconnect (ic->h);
trigger_transmit (ic->h);
if (ic->callback != NULL)
- ic->callback (ic->callback_cls, NULL, NULL);
+ ic->callback (ic->callback_cls, NULL, NULL, err_msg);
+ GNUNET_free (err_msg);
GNUNET_free (ic);
return;
}
@@ -520,19 +528,21 @@
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct GNUNET_PEERINFO_IteratorContext *ic = cls;
+ char * err_msg;
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,
- _("Timeout transmitting iteration request to `%s' service.\n"),
+ GNUNET_asprintf(&err_msg,_("Timeout transmitting iteration request to `%s'
service.\n"),
"PEERINFO");
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,err_msg);
ic->timeout_task = GNUNET_SCHEDULER_NO_TASK;
if (! ic->in_receive)
GNUNET_CONTAINER_DLL_remove (ic->h->tq_head,
ic->h->tq_tail,
ic->tqe);
reconnect (ic->h);
- ic->callback (ic->callback_cls, NULL, NULL);
+ ic->callback (ic->callback_cls, NULL, NULL,err_msg);
ic->callback = NULL;
GNUNET_free_non_null (ic->tqe);
+ GNUNET_free (err_msg);
GNUNET_free (ic);
}
Modified: gnunet/src/peerinfo/peerinfo_api_notify.c
===================================================================
--- gnunet/src/peerinfo/peerinfo_api_notify.c 2011-01-03 10:33:55 UTC (rev
14102)
+++ gnunet/src/peerinfo/peerinfo_api_notify.c 2011-01-03 14:21:25 UTC (rev
14103)
@@ -138,7 +138,7 @@
"Received information about peer `%s' from peerinfo database\n",
GNUNET_i2s (&im->peer));
#endif
- nc->callback (nc->callback_cls, &im->peer, hello);
+ nc->callback (nc->callback_cls, &im->peer, hello, NULL);
receive_notifications (nc);
}
Modified: gnunet/src/peerinfo/perf_peerinfo_api.c
===================================================================
--- gnunet/src/peerinfo/perf_peerinfo_api.c 2011-01-03 10:33:55 UTC (rev
14102)
+++ gnunet/src/peerinfo/perf_peerinfo_api.c 2011-01-03 14:21:25 UTC (rev
14103)
@@ -107,7 +107,8 @@
static void
process (void *cls,
const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Message *hello)
+ const struct GNUNET_HELLO_Message *hello,
+ const char * err_msg)
{
if (peer == NULL)
{
Modified: gnunet/src/peerinfo/test_peerinfo_api.c
===================================================================
--- gnunet/src/peerinfo/test_peerinfo_api.c 2011-01-03 10:33:55 UTC (rev
14102)
+++ gnunet/src/peerinfo/test_peerinfo_api.c 2011-01-03 14:21:25 UTC (rev
14103)
@@ -100,11 +100,18 @@
static void
process (void *cls,
const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Message *hello)
+ const struct GNUNET_HELLO_Message *hello,
+ const char * err_msg)
{
int *ok = cls;
unsigned int agc;
+ if (err_msg != NULL)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Error in communication with PEERINFO service\n"));
+ }
+
if (peer == NULL)
{
ic = NULL;
Modified: gnunet/src/peerinfo-tool/gnunet-peerinfo.c
===================================================================
--- gnunet/src/peerinfo-tool/gnunet-peerinfo.c 2011-01-03 10:33:55 UTC (rev
14102)
+++ gnunet/src/peerinfo-tool/gnunet-peerinfo.c 2011-01-03 14:21:25 UTC (rev
14103)
@@ -157,14 +157,15 @@
static void
print_peer_info (void *cls,
const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Message *hello)
+ const struct GNUNET_HELLO_Message *hello,
+ const char * err_msg)
{
struct GNUNET_CRYPTO_HashAsciiEncoded enc;
struct PrintContext *pc;
if (peer == NULL)
{
- fprintf (stderr,_("Error in communication with PEERINFO service\n"));
+ if (err_msg != NULL) fprintf (stderr,_("Error in communication with
PEERINFO service\n"));
GNUNET_PEERINFO_disconnect (peerinfo);
return;
}
Modified: gnunet/src/topology/gnunet-daemon-topology.c
===================================================================
--- gnunet/src/topology/gnunet-daemon-topology.c 2011-01-03 10:33:55 UTC
(rev 14102)
+++ gnunet/src/topology/gnunet-daemon-topology.c 2011-01-03 14:21:25 UTC
(rev 14103)
@@ -924,14 +924,23 @@
* @param cls closure (not used)
* @param peer potential peer to connect to
* @param hello HELLO for this peer (or NULL)
+ * @param err_msg NULL if successful, otherwise contains error message
*/
static void
process_peer (void *cls,
const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Message *hello)
+ const struct GNUNET_HELLO_Message *hello,
+ const char *err_msg)
{
struct Peer *pos;
+ if (err_msg != NULL)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Error in communication with PEERINFO service\n"));
+ /* return; */
+ }
+
GNUNET_assert (peer != NULL);
if (0 == memcmp (&my_identity,
peer, sizeof (struct GNUNET_PeerIdentity)))
Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c 2011-01-03 10:33:55 UTC
(rev 14102)
+++ gnunet/src/transport/gnunet-service-transport.c 2011-01-03 14:21:25 UTC
(rev 14103)
@@ -2710,15 +2710,23 @@
* @param cls closure ('struct NeighbourList*')
* @param peer id of the peer, NULL for last call
* @param h hello message for the peer (can be NULL)
+ * @param err_msg NULL if successful, otherwise contains error message
*/
static void
add_hello_for_peer (void *cls,
const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Message *h)
+ const struct GNUNET_HELLO_Message *h,
+ const char *err_msg)
{
struct NeighbourList *n = cls;
- if (peer == NULL)
+ if (err_msg != NULL)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Error in communication with PEERINFO service\n"));
+ /* return; */
+ }
+ if ((peer == NULL))
{
GNUNET_STATISTICS_update (stats,
gettext_noop ("# outstanding peerinfo iterate
requests"),
@@ -4029,11 +4037,13 @@
* @param cls closure
* @param peer id of the peer, NULL for last call
* @param h hello message for the peer (can be NULL)
+ * @param err_msg NULL if successful, otherwise contains error message
*/
static void
check_hello_validated (void *cls,
const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Message *h)
+ const struct GNUNET_HELLO_Message *h,
+ const char *err_msg)
{
struct CheckHelloValidatedContext *chvc = cls;
struct GNUNET_HELLO_Message *plain_hello;
@@ -4041,6 +4051,13 @@
struct GNUNET_PeerIdentity target;
struct NeighbourList *n;
+ if (err_msg != NULL)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Error in communication with PEERINFO service\n"));
+ /* return; */
+ }
+
if (peer == NULL)
{
GNUNET_STATISTICS_update (stats,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r14103 - in gnunet/src: core dv hostlist include peerinfo peerinfo-tool topology transport,
gnunet <=