gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r19706 - gnunet/src/util


From: gnunet
Subject: [GNUnet-SVN] r19706 - gnunet/src/util
Date: Mon, 6 Feb 2012 10:17:11 +0100

Author: grothoff
Date: 2012-02-06 10:17:11 +0100 (Mon, 06 Feb 2012)
New Revision: 19706

Modified:
   gnunet/src/util/server_mst.c
   gnunet/src/util/test_common_logging_dummy.c
   gnunet/src/util/test_common_logging_runtime_loglevels.c
Log:
-speed up logging test, fix logging testcase to always log at DEBUG level

Modified: gnunet/src/util/server_mst.c
===================================================================
--- gnunet/src/util/server_mst.c        2012-02-05 19:36:09 UTC (rev 19705)
+++ gnunet/src/util/server_mst.c        2012-02-06 09:17:11 UTC (rev 19706)
@@ -132,6 +132,8 @@
   unsigned long offset;
   int ret;
 
+  GNUNET_assert (mst->off <= mst->pos);
+  GNUNET_assert (mst->pos <= mst->curr_buf);
 #if DEBUG_SERVER_MST
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Server-mst receives %u bytes with %u bytes already in private 
buffer\n",
@@ -142,6 +144,7 @@
   while (mst->pos > 0)
   {
 do_align:
+    GNUNET_assert (mst->pos >= mst->off);
     if ((mst->curr_buf - mst->off < sizeof (struct GNUNET_MessageHeader)) ||
         (0 != (mst->off % ALIGN_FACTOR)))
     {
@@ -176,15 +179,18 @@
       GNUNET_break_op (0);
       return GNUNET_SYSERR;
     }
-    if (mst->curr_buf - mst->off < want)
+    if ( (mst->curr_buf - mst->off < want) &&
+        (mst->off > 0) )
     {
-      /* need more space */
+      /* can get more space by moving */
       mst->pos -= mst->off;
       memmove (ibuf, &ibuf[mst->off], mst->pos);
       mst->off = 0;
     }
-    if (want > mst->curr_buf)
+    if (mst->curr_buf < want)
     {
+      /* need to get more space by growing buffer */
+      GNUNET_assert (0 == mst->off);
       mst->hdr = GNUNET_realloc (mst->hdr, want);
       ibuf = (char *) mst->hdr;
       mst->curr_buf = want;
@@ -193,6 +199,7 @@
     if (mst->pos - mst->off < want)
     {
       delta = GNUNET_MIN (want - (mst->pos - mst->off), size);
+      GNUNET_assert (mst->pos + delta <= mst->curr_buf);
       memcpy (&ibuf[mst->pos], buf, delta);
       mst->pos += delta;
       buf += delta;
@@ -225,6 +232,7 @@
       mst->pos = 0;
     }
   }
+  GNUNET_assert (0 == mst->pos);
   while (size > 0)
   {
 #if DEBUG_SERVER_MST
@@ -235,7 +243,7 @@
     if (size < sizeof (struct GNUNET_MessageHeader))
       break;
     offset = (unsigned long) buf;
-    need_align = (0 != offset % ALIGN_FACTOR) ? GNUNET_YES : GNUNET_NO;
+    need_align = (0 != (offset % ALIGN_FACTOR)) ? GNUNET_YES : GNUNET_NO;
     if (GNUNET_NO == need_align)
     {
       /* can try to do zero-copy and process directly from original buffer */
@@ -248,7 +256,7 @@
         return GNUNET_SYSERR;
       }
       if (size < want)
-        break;                  /* or not, buffer incomplete, so copy to 
private buffer... */
+        break;                  /* or not: buffer incomplete, so copy to 
private buffer... */
       if (one_shot == GNUNET_SYSERR)
       {
         /* cannot call callback again, but return value saying that
@@ -278,12 +286,15 @@
       ibuf = (char *) mst->hdr;
       mst->curr_buf = size + mst->pos;
     }
-    GNUNET_assert (mst->pos + size <= mst->curr_buf);
+    GNUNET_assert (size + mst->pos <= mst->curr_buf);
     memcpy (&ibuf[mst->pos], buf, size);
     mst->pos += size;
   }
   if (purge)
+  {
     mst->off = 0;
+    mst->pos = 0;
+  }
 #if DEBUG_SERVER_MST
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Server-mst leaves %u bytes in private buffer\n",

Modified: gnunet/src/util/test_common_logging_dummy.c
===================================================================
--- gnunet/src/util/test_common_logging_dummy.c 2012-02-05 19:36:09 UTC (rev 
19705)
+++ gnunet/src/util/test_common_logging_dummy.c 2012-02-06 09:17:11 UTC (rev 
19706)
@@ -25,11 +25,17 @@
  * @author LRN
  */
 #include "platform.h"
+#undef GNUNET_EXTRA_LOGGING
+#define GNUNET_EXTRA_LOGGING GNUNET_YES
+
 #include "gnunet_common.h"
 #include "gnunet_time_lib.h"
 #include "gnunet_network_lib.h"
 
-#define MS200 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 200)
+/**
+ * Delay introduced between operations, useful for debugging.
+ */
+#define OUTPUT_DELAY GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_MILLISECONDS, 0)
 
 static void
 my_log (void *ctx, enum GNUNET_ErrorType kind, const char *component,
@@ -44,7 +50,7 @@
 static int
 expensive_func ()
 {
-  return GNUNET_NETWORK_socket_select (NULL, NULL, NULL, MS200);
+  return GNUNET_NETWORK_socket_select (NULL, NULL, NULL, OUTPUT_DELAY);
 }
 
 #define pr(kind,lvl) {\

Modified: gnunet/src/util/test_common_logging_runtime_loglevels.c
===================================================================
--- gnunet/src/util/test_common_logging_runtime_loglevels.c     2012-02-05 
19:36:09 UTC (rev 19705)
+++ gnunet/src/util/test_common_logging_runtime_loglevels.c     2012-02-06 
09:17:11 UTC (rev 19706)
@@ -43,7 +43,7 @@
 static GNUNET_SCHEDULER_TaskIdentifier die_task;
 
 static void
-runone ();
+runone (void);
 
 static void
 end_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)




reply via email to

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