gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r5179 - in GNUnet/src: applications/gap applications/pingpo


From: gnunet
Subject: [GNUnet-SVN] r5179 - in GNUnet/src: applications/gap applications/pingpong applications/session include
Date: Fri, 29 Jun 2007 03:02:09 -0600 (MDT)

Author: grothoff
Date: 2007-06-29 03:02:09 -0600 (Fri, 29 Jun 2007)
New Revision: 5179

Modified:
   GNUnet/src/applications/gap/gap.c
   GNUnet/src/applications/pingpong/pingpong.c
   GNUnet/src/applications/session/connect.c
   GNUnet/src/include/gnunet_util_error.h
Log:
more precise logging

Modified: GNUnet/src/applications/gap/gap.c
===================================================================
--- GNUnet/src/applications/gap/gap.c   2007-06-29 08:15:07 UTC (rev 5178)
+++ GNUnet/src/applications/gap/gap.c   2007-06-29 09:02:09 UTC (rev 5179)
@@ -1600,7 +1600,7 @@
 #endif
 
   if (ntohs(pmsg->size) < sizeof(P2P_gap_reply_MESSAGE)) {
-    GE_BREAK(ectx, 0);
+    GE_BREAK_OP(ectx, 0);
     return SYSERR; /* invalid! */
   }
   msg = (const P2P_gap_reply_MESSAGE *) pmsg;
@@ -1655,7 +1655,7 @@
           GE_ERROR | GE_BULK | GE_USER,
           _("GAP received invalid content from `%s'\n"),
           (host != NULL) ? (const char*)&enc : _("myself"));
-    GE_BREAK(ectx, 0);
+    GE_BREAK_OP(ectx, 0);
     FREE(value);
     return SYSERR; /* invalid */
   }
@@ -2000,7 +2000,7 @@
        (ntohs(msg->size) < sizeof(P2P_gap_query_MESSAGE)) ||
        (ntohs(msg->size) != sizeof(P2P_gap_query_MESSAGE) +
        (queries-1) * sizeof(HashCode512)) ) {
-    GE_BREAK(ectx, 0);
+    GE_BREAK_OP(ectx, 0);
     return SYSERR; /* malformed query */
   }
 
@@ -2013,7 +2013,7 @@
        (or B directly back to A; also should not happen)
        in this case, A must just drop; however, this
        should not happen (peers should check). */
-    GE_BREAK(ectx, 0);
+    GE_BREAK_OP(ectx, 0);
     FREE(qmsg);
     return OK;
   }

Modified: GNUnet/src/applications/pingpong/pingpong.c
===================================================================
--- GNUnet/src/applications/pingpong/pingpong.c 2007-06-29 08:15:07 UTC (rev 
5178)
+++ GNUnet/src/applications/pingpong/pingpong.c 2007-06-29 09:02:09 UTC (rev 
5179)
@@ -198,7 +198,7 @@
           GE_WARNING | GE_BULK | GE_USER | GE_DEVELOPER,
           _("Received malformed `%s' message. Dropping.\n"),
           "ping");
-    GE_BREAK(NULL, 0);
+    GE_BREAK_OP(NULL, 0);
     return SYSERR;
   }
   pmsg = (const P2P_pingpong_MESSAGE *) hmsg;
@@ -208,7 +208,7 @@
     GE_LOG(ectx,
           GE_INFO | GE_REQUEST | GE_ADMIN,
           _("Received PING not destined for us!\n"));
-    GE_BREAK(NULL, 0);
+    GE_BREAK_OP(NULL, 0);
     return SYSERR; /* not for us */
   }
 

Modified: GNUnet/src/applications/session/connect.c
===================================================================
--- GNUnet/src/applications/session/connect.c   2007-06-29 08:15:07 UTC (rev 
5178)
+++ GNUnet/src/applications/session/connect.c   2007-06-29 09:02:09 UTC (rev 
5179)
@@ -251,7 +251,7 @@
   if (rsize < sizeof(P2P_setkey_MESSAGE)) {
     EncName enc;
 
-    GE_BREAK(ectx, 0);
+    GE_BREAK_OP(ectx, 0);
     IF_GELOG(ectx,
             GE_INFO | GE_USER | GE_REQUEST,
             hash2enc(&hostId->hashPubKey,
@@ -330,15 +330,15 @@
        (0 != memcmp(&hc,
                    &foreignHello->senderIdentity,
                    sizeof(PeerIdentity))) ) {
-    GE_BREAK(NULL,
-            0 == memcmp(&hc,
-                        &foreignHello->senderIdentity,
-                        sizeof(PeerIdentity)));
-    GE_BREAK(NULL,
-            0 == memcmp(&hc,
-                        hostId,
-                        sizeof(PeerIdentity)));
-    GE_BREAK(NULL, 0);
+    GE_BREAK_OP(NULL,
+               0 == memcmp(&hc,
+                           &foreignHello->senderIdentity,
+                           sizeof(PeerIdentity)));
+    GE_BREAK_OP(NULL,
+               0 == memcmp(&hc,
+                           hostId,
+                           sizeof(PeerIdentity)));
+    GE_BREAK_OP(NULL, 0);
     FREE(foreignHello);
     return NULL;
   }
@@ -355,7 +355,7 @@
                                  sizeof(SESSIONKEY),
                                  &foreignHello->publicKey,
                                  &msg->key)) {
-    GE_BREAK(ectx, 0);
+    GE_BREAK_OP(ectx, 0);
     FREE(foreignHello);
     FREE(msg);
     return NULL; /* encrypt failed */
@@ -686,7 +686,7 @@
           ntohl(key.crc32),
           crc32N(&key, SESSIONKEY_LEN));
 #endif
-    GE_BREAK(ectx, 0);
+    GE_BREAK_OP(ectx, 0);
     stats->change(stat_skeyRejected,
                  1);
     return SYSERR;
@@ -815,7 +815,7 @@
                  tsession,
                  ping); /* ping is now pong */
     } else {
-      GE_BREAK(ectx, 0);
+      GE_BREAK_OP(ectx, 0);
       /* PING not included in SKEY - bug (in other peer!?) */
     }
   }

Modified: GNUnet/src/include/gnunet_util_error.h
===================================================================
--- GNUnet/src/include/gnunet_util_error.h      2007-06-29 08:15:07 UTC (rev 
5178)
+++ GNUnet/src/include/gnunet_util_error.h      2007-06-29 09:02:09 UTC (rev 
5179)
@@ -212,12 +212,33 @@
  */
 #define IF_GELOG(ctx, kind, a) do { if (GE_isLogged(ctx, kind)) { a; } } 
while(0)
 
+/**
+ * Use this for fatal errors that cannot be handled
+ */
 #define GE_ASSERT(ctx, cond) do { if (! (cond)) { GE_LOG(ctx, GE_DEVELOPER | 
GE_USER | GE_FATAL | GE_IMMEDIATE, _("Internal error: assertion failed at %s:%d 
in %s.\n"), __FILE__, __LINE__, __FUNCTION__); GE_CONFIRM(ctx); abort(); } } 
while(0)
 
 #define GE_ASSERT_FLF(ctx, cond, file, line, function) do { if (! (cond)) { 
GE_LOG(ctx, GE_DEVELOPER | GE_USER | GE_FATAL | GE_IMMEDIATE, _("Internal 
error: assertion failed at %s:%d in %s.\n"), file, line, function); 
GE_CONFIRM(ctx); abort(); } } while(0)
 
+/**
+ * Use this for internal assertion violations that are
+ * not fatal (can be handled) but should not occur.
+ */
 #define GE_BREAK(ctx, cond)  do { if (! (cond)) { GE_LOG(ctx, GE_DEVELOPER | 
GE_USER | GE_FATAL | GE_IMMEDIATE, _("Internal error: assertion failed at %s:%d 
in %s.\n"), __FILE__, __LINE__, __FUNCTION__); } } while(0)
 
+/**
+ * Use this for assertion violations caused by other
+ * peers (i.e. protocol violations).  We do not want to
+ * confuse end-users (say, some other peer runs an 
+ * older, broken or incompatible GNUnet version), but
+ * we still want to see these problems during 
+ * development and testing.  "OP == other peer".
+ */
+#define GE_BREAK_OP(ctx, cond)  do { if (! (cond)) { GE_LOG(ctx, GE_DEVELOPER 
| GE_FATAL | GE_IMMEDIATE, _("Internal error: assertion failed at %s:%d in 
%s.\n"), __FILE__, __LINE__, __FUNCTION__); } } while(0)
+
+/**
+ * Just like GE_BREAK just with file/line/function 
+ * information given as part of the call.
+ */
 #define GE_BREAK_FLF(ctx, cond, file, line, function)  do { if (! (cond)) { 
GE_LOG(ctx, GE_DEVELOPER | GE_USER | GE_FATAL | GE_IMMEDIATE, _("Internal 
error: assertion failed at %s:%d in %s.\n"), file, line, function); } } while(0)
 
 /**





reply via email to

[Prev in Thread] Current Thread [Next in Thread]