gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r10183 - in gnunet/src: fs include


From: gnunet
Subject: [GNUnet-SVN] r10183 - in gnunet/src: fs include
Date: Mon, 1 Feb 2010 14:55:29 +0100

Author: grothoff
Date: 2010-02-01 14:55:28 +0100 (Mon, 01 Feb 2010)
New Revision: 10183

Modified:
   gnunet/src/fs/fs.h
   gnunet/src/fs/fs_download.c
   gnunet/src/fs/fs_search.c
   gnunet/src/fs/gnunet-service-fs.c
   gnunet/src/fs/gnunet-service-fs_indexing.c
   gnunet/src/fs/test_fs_download.c
   gnunet/src/include/gnunet_protocols.h
Log:
fixes

Modified: gnunet/src/fs/fs.h
===================================================================
--- gnunet/src/fs/fs.h  2010-02-01 13:02:01 UTC (rev 10182)
+++ gnunet/src/fs/fs.h  2010-02-01 13:55:28 UTC (rev 10183)
@@ -1300,35 +1300,6 @@
 
 
 /**
- * Response from FS service with a result for a previous FS search.
- * Note that queries for DBLOCKS and IBLOCKS that have received a
- * single response are considered done.
- */
-struct ContentMessage
-{
-
-  /**
-   * Message type will be 
-   * GNUNET_MESSAGE_TYPE_FS_CONTENT.
-   */
-  struct GNUNET_MessageHeader header;
-
-  /**
-   * Type of the content that was found,
-   * should never be 0.
-   */
-  uint32_t type GNUNET_PACKED;
-
-  /**
-   * When will this result expire?
-   */
-  struct GNUNET_TIME_AbsoluteNBO expiration;
-
-  /* followed by the actual block of data */
-
-};
-
-/**
  * Only the (mandatory) query is included.
  */
 #define GET_MESSAGE_BIT_QUERY_ONLY 0
@@ -1417,7 +1388,10 @@
 
 
 /**
- * Message sent between peers providing FS-content.
+ * Response from FS service with a result for a previous FS search.
+ * Note that queries for DBLOCKS and IBLOCKS that have received a
+ * single response are considered done.  This message is transmitted
+ * between peers as well as between the service and a client.
  */
 struct PutMessage
 {
@@ -1428,14 +1402,14 @@
   struct GNUNET_MessageHeader header;
 
   /**
-   * Type of the block (in big endian).
+   * Type of the block (in big endian).  Should never be zero.
    */
   uint32_t type GNUNET_PACKED;
 
   /**
    * When does this result expire? 
    */
-  struct GNUNET_TIME_RelativeNBO expiration;
+  struct GNUNET_TIME_AbsoluteNBO expiration;
 
   /* this is followed by the actual encrypted content */
 

Modified: gnunet/src/fs/fs_download.c
===================================================================
--- gnunet/src/fs/fs_download.c 2010-02-01 13:02:01 UTC (rev 10182)
+++ gnunet/src/fs/fs_download.c 2010-02-01 13:55:28 UTC (rev 10183)
@@ -36,7 +36,7 @@
 #include "fs.h"
 #include "fs_tree.h"
 
-#define DEBUG_DOWNLOAD GNUNET_NO
+#define DEBUG_DOWNLOAD GNUNET_YES
 
 /**
  * We're storing the IBLOCKS after the
@@ -539,22 +539,23 @@
                 const struct GNUNET_MessageHeader * msg)
 {
   struct GNUNET_FS_DownloadContext *dc = cls;
-  const struct ContentMessage *cm;
+  const struct PutMessage *cm;
   uint16_t msize;
 
   if ( (NULL == msg) ||
-       (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_CONTENT) ||
-       (ntohs (msg->size) <= sizeof (struct ContentMessage)) )
+       (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_PUT) ||
+       (sizeof (struct PutMessage) > ntohs(msg->size)) )
     {
+      GNUNET_break (msg == NULL);      
       try_reconnect (dc);
       return;
     }
-  msize = ntohs (msg->size);
-  cm = (const struct ContentMessage*) msg;
+  msize = ntohs(msg->size);
+  cm = (const struct PutMessage*) msg;
   process_result (dc, 
                  ntohl (cm->type),
                  &cm[1],
-                 msize - sizeof (struct ContentMessage));
+                 msize - sizeof (struct PutMessage));
   if (dc->client == NULL)
     return; /* fatal error */
   /* continue receiving */

Modified: gnunet/src/fs/fs_search.c
===================================================================
--- gnunet/src/fs/fs_search.c   2010-02-01 13:02:01 UTC (rev 10182)
+++ gnunet/src/fs/fs_search.c   2010-02-01 13:55:28 UTC (rev 10183)
@@ -574,23 +574,23 @@
                 const struct GNUNET_MessageHeader * msg)
 {
   struct GNUNET_FS_SearchContext *sc = cls;
-  const struct ContentMessage *cm;
+  const struct PutMessage *cm;
   uint16_t msize;
 
   if ( (NULL == msg) ||
-       (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_CONTENT) ||
-       (ntohs (msg->size) <= sizeof (struct ContentMessage)) )
+       (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_PUT) ||
+       (ntohs (msg->size) <= sizeof (struct PutMessage)) )
     {
       try_reconnect (sc);
       return;
     }
   msize = ntohs (msg->size);
-  cm = (const struct ContentMessage*) msg;
+  cm = (const struct PutMessage*) msg;
   process_result (sc, 
                  ntohl (cm->type),
                  GNUNET_TIME_absolute_ntoh (cm->expiration),
                  &cm[1],
-                 msize - sizeof (struct ContentMessage));
+                 msize - sizeof (struct PutMessage));
   /* continue receiving */
   GNUNET_CLIENT_receive (sc->client,
                         &receive_results,

Modified: gnunet/src/fs/gnunet-service-fs.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs.c   2010-02-01 13:02:01 UTC (rev 10182)
+++ gnunet/src/fs/gnunet-service-fs.c   2010-02-01 13:55:28 UTC (rev 10183)
@@ -1592,6 +1592,11 @@
                                                  GNUNET_TIME_UNIT_FOREVER_REL,
                                                  &transmit_to_client,
                                                  cl);
+#if DEBUG_FS
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Transmitted %u bytes to client\n",
+             (unsigned int) msize);
+#endif
   return msize;
 }
 
@@ -1655,7 +1660,6 @@
   struct ClientResponseMessage *creply;
   struct ClientList *cl;
   struct PutMessage *pm;
-  struct ContentMessage *cm;
   struct ConnectedPeer *cp;
   GNUNET_HashCode chash;
   GNUNET_HashCode mhash;
@@ -1740,8 +1744,8 @@
       pm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_PUT);
       pm->header.size = htons (msize);
       pm->type = htonl (prq->type);
-      pm->expiration = GNUNET_TIME_relative_hton 
(GNUNET_TIME_absolute_get_remaining (prq->expiration));
-      memcpy (&creply[1], prq->data, prq->size);      
+      pm->expiration = GNUNET_TIME_absolute_hton (prq->expiration);
+      memcpy (&pm[1], prq->data, prq->size);      
       if (NULL == cl->th)
        cl->th = GNUNET_SERVER_notify_transmit_ready (cl->client,
                                                      msize,
@@ -1759,18 +1763,18 @@
                  GNUNET_h2s (key),
                  (unsigned int) cp->pid);
 #endif  
-      msize = sizeof (struct ContentMessage) + prq->size;
+      msize = sizeof (struct PutMessage) + prq->size;
       reply = GNUNET_malloc (msize + sizeof (struct PendingMessage));
       reply->cont = &transmit_reply_continuation;
       reply->cont_cls = pr;
       reply->msize = msize;
       reply->priority = (uint32_t) -1; /* send replies first! */
-      cm = (struct ContentMessage*) &reply[1];
-      cm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_CONTENT);
-      cm->header.size = htons (msize);
-      cm->type = htonl (prq->type);
-      cm->expiration = GNUNET_TIME_absolute_hton (prq->expiration);
-      memcpy (&reply[1], prq->data, prq->size);
+      pm = (struct PutMessage*) &reply[1];
+      pm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_PUT);
+      pm->header.size = htons (msize);
+      pm->type = htonl (prq->type);
+      pm->expiration = GNUNET_TIME_absolute_hton (prq->expiration);
+      memcpy (&pm[1], prq->data, prq->size);
       add_to_pending_messages_for_peer (cp, reply, pr);
     }
 
@@ -1816,7 +1820,7 @@
   put = (const struct PutMessage*) message;
   dsize = msize - sizeof (struct PutMessage);
   type = ntohl (put->type);
-  expiration = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_ntoh 
(put->expiration));
+  expiration = GNUNET_TIME_absolute_ntoh (put->expiration);
 
   /* first, validate! */
   switch (type)

Modified: gnunet/src/fs/gnunet-service-fs_indexing.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs_indexing.c  2010-02-01 13:02:01 UTC (rev 
10182)
+++ gnunet/src/fs/gnunet-service-fs_indexing.c  2010-02-01 13:55:28 UTC (rev 
10183)
@@ -38,9 +38,8 @@
 #include "gnunet-service-fs_indexing.h"
 #include "fs.h"
 
-#define DEBUG_FS GNUNET_NO
+#define DEBUG_FS GNUNET_YES
 
-
 /**
  * In-memory information about indexed files (also available
  * on-disk).
@@ -624,6 +623,11 @@
         to remove the OnDemand block from the DS! */
       return GNUNET_SYSERR;
     }
+#if DEBUG_FS
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "On-demand encoded block for query `%s'\n",
+                 GNUNET_h2s (key));
+#endif  
   cont (cont_cls,
        key,
        nsize,

Modified: gnunet/src/fs/test_fs_download.c
===================================================================
--- gnunet/src/fs/test_fs_download.c    2010-02-01 13:02:01 UTC (rev 10182)
+++ gnunet/src/fs/test_fs_download.c    2010-02-01 13:55:28 UTC (rev 10183)
@@ -29,7 +29,7 @@
 #include "gnunet_arm_service.h"
 #include "gnunet_fs_service.h"
 
-#define VERBOSE GNUNET_NO
+#define VERBOSE GNUNET_YES
 
 #define START_ARM GNUNET_YES
 
@@ -78,16 +78,16 @@
 timeout_kill_task (void *cls,
                   const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
-  if (publish != NULL)
-    {
-      GNUNET_FS_publish_stop (publish);
-      publish = NULL;
-    }
   if (download != NULL)
     {
       GNUNET_FS_download_stop (download, GNUNET_YES);
       download = NULL;
     }
+  else if (publish != NULL)
+    {
+      GNUNET_FS_publish_stop (publish);
+      publish = NULL;
+    }
   timeout_kill = GNUNET_SCHEDULER_NO_TASK;
   err = 1;
 }

Modified: gnunet/src/include/gnunet_protocols.h
===================================================================
--- gnunet/src/include/gnunet_protocols.h       2010-02-01 13:02:01 UTC (rev 
10182)
+++ gnunet/src/include/gnunet_protocols.h       2010-02-01 13:55:28 UTC (rev 
10183)
@@ -441,21 +441,15 @@
 #define GNUNET_MESSAGE_TYPE_FS_START_SEARCH 136
 
 /**
- * FS service has found content matching this client's
- * request.
- */
-#define GNUNET_MESSAGE_TYPE_FS_CONTENT 137
-
-/**
  * P2P request for content (one FS to another).
  */
-#define GNUNET_MESSAGE_TYPE_FS_GET 138
+#define GNUNET_MESSAGE_TYPE_FS_GET 137
 
 /**
- * P2P response with content or active
- * migration of content.
+ * P2P response with content or active migration of content.  Also
+ * used between the service and clients (in response to START_SEARCH).
  */
-#define GNUNET_MESSAGE_TYPE_FS_PUT 139
+#define GNUNET_MESSAGE_TYPE_FS_PUT 138
 
 /**
  * Type used to match 'all' message types.





reply via email to

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