gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r326 - in GNUnet: . src/applications/fs/ecrs src/server


From: grothoff
Subject: [GNUnet-SVN] r326 - in GNUnet: . src/applications/fs/ecrs src/server
Date: Sat, 26 Feb 2005 15:08:35 -0800 (PST)

Author: grothoff
Date: 2005-02-26 15:08:34 -0800 (Sat, 26 Feb 2005)
New Revision: 326

Modified:
   GNUnet/src/applications/fs/ecrs/check.conf
   GNUnet/src/applications/fs/ecrs/download.c
   GNUnet/src/applications/fs/ecrs/ecrstest.c
   GNUnet/src/server/handler.c
   GNUnet/src/server/tcpserver.c
   GNUnet/todo
Log:
alignment

Modified: GNUnet/src/applications/fs/ecrs/check.conf
===================================================================
--- GNUnet/src/applications/fs/ecrs/check.conf  2005-02-26 23:05:10 UTC (rev 
325)
+++ GNUnet/src/applications/fs/ecrs/check.conf  2005-02-26 23:08:34 UTC (rev 
326)
@@ -6,7 +6,7 @@
 [GNUNETD]
 # VALGRIND        = 300
 HELOEXPIRES     = 60
-LOGLEVEL        = NOTHING
+LOGLEVEL        = DEBUG
 LOGFILE         = $GNUNETD_HOME/logs
 KEEPLOG         = 0
 PIDFILE         = $GNUNETD_HOME/gnunetd.pid

Modified: GNUnet/src/applications/fs/ecrs/download.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/download.c  2005-02-26 23:05:10 UTC (rev 
325)
+++ GNUnet/src/applications/fs/ecrs/download.c  2005-02-26 23:08:34 UTC (rev 
326)
@@ -566,6 +566,10 @@
   cron_t TTL_DECREMENT; 
 } CommonCtx;
 
+/**
+ * Compute how many bytes of data are stored in
+ * this node.
+ */
 static unsigned int getNodeSize(const NodeClosure * node) {  
   unsigned int i;
   unsigned int ret;
@@ -573,6 +577,7 @@
   unsigned long long spos;
   unsigned long long epos;
   
+  GNUNET_ASSERT(node->offset < node->ctx->total);
   if (node->level == 0) {
     ret = DBLOCK_SIZE;
     if (node->offset + (unsigned long long) ret
@@ -587,8 +592,8 @@
   epos = spos + rsize;
   if (epos > node->ctx->total)
     epos = node->ctx->total;
-  ret = (epos - spos) / (rsize / CHK_PER_INODE);
-  if (ret * (rsize / CHK_PER_INODE) < epos - spos)
+  ret = (epos - spos) / rsize;
+  if (ret * rsize < epos - spos)
     ret++; /* need to round up! */
   return ret * sizeof(CHK);
 }
@@ -835,6 +840,9 @@
   size = ntohl(reply->size) - sizeof(Datastore_Value);
   if ( (size <= sizeof(DBlock)) ||
        (size - sizeof(DBlock) != getNodeSize(node)) ) {
+    printf("Received %u bytes, expected %u\n",
+          size,
+          getNodeSize(node));
     BREAK();
     return SYSERR; /* invalid size! */
   }

Modified: GNUnet/src/applications/fs/ecrs/ecrstest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/ecrstest.c  2005-02-26 23:05:10 UTC (rev 
325)
+++ GNUnet/src/applications/fs/ecrs/ecrstest.c  2005-02-26 23:08:34 UTC (rev 
326)
@@ -22,7 +22,7 @@
                                     NULL));
   FREENONNULL(setConfigurationString("GNUNET",
                                     "LOGLEVEL",
-                                    "NOTHING"));
+                                    "DEBUG"));
   return OK;
 }
 
@@ -217,11 +217,11 @@
 
 int main(int argc, char * argv[]){
   static unsigned int filesizes[] = {
-    1,
+/*    1,
     2,
     4,
     16,
-    32, 
+    32, */ 
     1024,
     DBLOCK_SIZE - 1,
     DBLOCK_SIZE,

Modified: GNUnet/src/server/handler.c
===================================================================
--- GNUnet/src/server/handler.c 2005-02-26 23:05:10 UTC (rev 325)
+++ GNUnet/src/server/handler.c 2005-02-26 23:08:34 UTC (rev 326)
@@ -1,5 +1,6 @@
 /*
      This file is part of GNUnet
+     (C) 2001, 2002, 2003, 2004, 2005 Christian Grothoff (and other 
contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -188,8 +189,6 @@
   return SYSERR; 
 }
 
-
-
 /**
  * Register a method as a handler for specific message types.  Note
  * that it IS possible to register multiple handlers for the same
@@ -297,30 +296,50 @@
                   int wasEncrypted,
                   TSession * session) {
   unsigned int pos;
-  p2p_HEADER * part;
+  const p2p_HEADER * part;
+  p2p_HEADER cpart;
+  p2p_HEADER * copy;
   EncName enc;
   int last;
 
   pos = 0;
+  copy = NULL;
   while (pos < size) {
     unsigned short plen;
     unsigned short ptyp;
 
-    part = (p2p_HEADER *) &msg[pos];
-    plen = htons(part->size);
+    memcpy(&cpart,
+          &msg[pos],
+          sizeof(p2p_HEADER));
+    plen = htons(cpart->size);
     if (pos + plen > size) {
       IFLOG(LOG_WARNING,
            hash2enc(&sender->hashPubKey,
                     &enc));      
       LOG(LOG_WARNING, 
          _("Received corrupt message from peer '%s'in %s:%d.\n"),
-         &enc, __FILE__, __LINE__);
+         &enc, 
+         __FILE__, __LINE__);
       return;
     }
+    if ( (pos % sizeof(int)) != 0) {
+      /* correct misalignment; we allow messages to _not_ be a
+        multiple of 4 bytes (if absolutely necessary; it should be
+        avoided where the cost for doing so is not prohibitive);
+        however we also (need to) guaranteed word-alignment for the
+        handlers; so we must re-align the message if it is
+        misaligned. */
+      copy = MALLOC(plen);
+      memcpy(copy,
+            &msg[pos],
+            plen);
+      part = copy;
+    } else {
+      part = (const p2p_HEADER*) &msg[pos];
+    }
     pos += plen;
 
     ptyp = htons(part->type);
-
     if (YES == wasEncrypted) {
       MessagePartHandler callback;
       
@@ -365,6 +384,8 @@
        last++;
       }
     } /* if plaintext */
+    FREENONNULL(copy);
+    copy = NULL;
   } /* while loop */
 }
 

Modified: GNUnet/src/server/tcpserver.c
===================================================================
--- GNUnet/src/server/tcpserver.c       2005-02-26 23:05:10 UTC (rev 325)
+++ GNUnet/src/server/tcpserver.c       2005-02-26 23:08:34 UTC (rev 326)
@@ -337,34 +337,37 @@
     return SYSERR;
   }
   handle->readBufferPos += ret;
-  if (handle->readBufferPos < sizeof(CS_HEADER))
-    return OK;
-  len = ntohs(((CS_HEADER*)handle->readBuffer)->size);
+  ret = OK;
+  while (ret == OK) {
+    if (handle->readBufferPos < sizeof(CS_HEADER))
+      return OK;
+    len = ntohs(((CS_HEADER*)handle->readBuffer)->size);
 #if DEBUG_TCPHANDLER
-  LOG(LOG_DEBUG,
-      "Total size is %u bytes, have %u.\n",
-      len,
+    LOG(LOG_DEBUG,
+       "Total size is %u bytes, have %u.\n",
+       len,
       handle->readBufferPos);
 #endif
-  if (len > handle->readBufferSize) /* if MTU larger than expected, grow! */
-    GROW(handle->readBuffer,
-        handle->readBufferSize,
-        len);
-  if (handle->readBufferPos < len) 
-    return OK;  
-  /* avoid deadlock: give up the lock while
-     the client is processing; since only (!) the
-     select-thread can possibly free handle/readbuffer,
+    if (len > handle->readBufferSize) /* if MTU larger than expected, grow! */
+      GROW(handle->readBuffer,
+          handle->readBufferSize,
+          len);
+    if (handle->readBufferPos < len) 
+      return OK;  
+    /* avoid deadlock: give up the lock while
+       the client is processing; since only (!) the
+       select-thread can possibly free handle/readbuffer,
      releasing the lock here is safe. */
-  MUTEX_UNLOCK(&clientlock);
-  ret = processHelper((CS_HEADER*)handle->readBuffer,
+    MUTEX_UNLOCK(&clientlock);
+    ret = processHelper((CS_HEADER*)handle->readBuffer,
                      handle);
-  MUTEX_LOCK(&clientlock);
-  /* finally, shrink buffer adequately */
-  memmove(&handle->readBuffer[0],
+    MUTEX_LOCK(&clientlock);
+    /* finally, shrink buffer adequately */
+    memmove(&handle->readBuffer[0],
          &handle->readBuffer[len],
-         handle->readBufferPos - len);
-  handle->readBufferPos -= len;           
+           handle->readBufferPos - len);
+    handle->readBufferPos -= len;
+  }
   return ret;
 }
 

Modified: GNUnet/todo
===================================================================
--- GNUnet/todo 2005-02-26 23:05:10 UTC (rev 325)
+++ GNUnet/todo 2005-02-26 23:08:34 UTC (rev 326)
@@ -1,4 +1,7 @@
 0.6.6b [2?'05] (aka "bugfixes"):
+- 833!
+- 832?
+- 829!
 - 828?
 - 827??
 - 823?
@@ -8,9 +11,10 @@
 - 593???
 
 0.7.0pre0 [3'05] (aka "pre-preview"):
-- padding for insert/return requests: we're currently breaking
-  8-byte alignment!
+- Known bugs:
+  * strange ecrstest bug(s?)
 - Need testing:
+  * fslibtest: implement verify result
   * ECRS-directories (build, iterate)
   * gnunet-directory
   * gnunet-pseudonym
@@ -20,8 +24,10 @@
   * API changes (hostkey struct, other structs? HashCode160)
 
 0.7.0pre1 [4'05] (aka "preview"):
+- util:
+  * switch hash to SHA-512
+  * switch cipher to AES-256
 - testing:
-  * fslibtest: implement verify result
   * sqlite-tests: test update function, concurrency with iterators
 - topology:
   * do aggressive bootstrap on first start (Christian) [ easy ]
@@ -38,7 +44,7 @@
 
 0.7.0 [5'05] (aka "compatibility? what's that?"):
 - Missing Features:
-   - resolve "FIXME 0.7"
+  * resolve "FIXME 0.7"
   * configure.ac: flags for mysql, gmp, libgcrypt should ONLY be passed when
     linking the respective modules / libraries (gnunet_util, sqstore_mysql) [ 
tricky ]
   * fsui core (persistence) [ difficult ]





reply via email to

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