gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r6387 - in GNUnet: . src/applications/bootstrap_http src/ap


From: gnunet
Subject: [GNUnet-SVN] r6387 - in GNUnet: . src/applications/bootstrap_http src/applications/chat src/applications/datastore src/applications/fs/ecrs src/applications/fs/fsui src/applications/fs/gap src/applications/fs/tools src/applications/hostlist src/applications/sqstore_mysql src/applications/sqstore_sqlite src/applications/stats src/applications/vpn src/include
Date: Tue, 19 Feb 2008 20:41:55 -0700 (MST)

Author: grothoff
Date: 2008-02-19 20:41:55 -0700 (Tue, 19 Feb 2008)
New Revision: 6387

Modified:
   GNUnet/ChangeLog
   GNUnet/UPDATING
   GNUnet/src/applications/bootstrap_http/http.c
   GNUnet/src/applications/chat/chat.c
   GNUnet/src/applications/chat/clientapi.c
   GNUnet/src/applications/chat/gnunet-chat.c
   GNUnet/src/applications/datastore/datastore.c
   GNUnet/src/applications/fs/ecrs/upload.c
   GNUnet/src/applications/fs/fsui/upload.c
   GNUnet/src/applications/fs/gap/gap.c
   GNUnet/src/applications/fs/gap/ondemand.c
   GNUnet/src/applications/fs/tools/gnunet-auto-share.c
   GNUnet/src/applications/fs/tools/gnunet-insert.c
   GNUnet/src/applications/hostlist/hostlist.c
   GNUnet/src/applications/hostlist/hostlisttest.c
   GNUnet/src/applications/sqstore_mysql/mysql.c
   GNUnet/src/applications/sqstore_mysql/mysqltest.c
   GNUnet/src/applications/sqstore_sqlite/sqlite.c
   GNUnet/src/applications/sqstore_sqlite/sqlitetest.c
   GNUnet/src/applications/stats/clientapi.c
   GNUnet/src/applications/vpn/cs.c
   GNUnet/src/applications/vpn/cs.h
   GNUnet/src/applications/vpn/gnunet-vpn.c
   GNUnet/src/applications/vpn/helper.c
   GNUnet/src/applications/vpn/helper.h
   GNUnet/src/applications/vpn/vpn.c
   GNUnet/src/include/gnunet_sqstore_service.h
   GNUnet/todo
Log:
changing datastore to address serious performance issue

Modified: GNUnet/ChangeLog
===================================================================
--- GNUnet/ChangeLog    2008-02-20 00:09:30 UTC (rev 6386)
+++ GNUnet/ChangeLog    2008-02-20 03:41:55 UTC (rev 6387)
@@ -1,3 +1,9 @@
+Tue Feb 19 20:35:28 MST 2008
+       Updated database schemata to support O(1) operations
+       even if there are N files under the same keywords.
+       This breaks database backwards compatibility (and
+       no migration code is provided).
+
 Mon Feb 18 19:47:37 MST 2008
        Added new options -u and -s to gnunet-insert.
 

Modified: GNUnet/UPDATING
===================================================================
--- GNUnet/UPDATING     2008-02-20 00:09:30 UTC (rev 6386)
+++ GNUnet/UPDATING     2008-02-20 03:41:55 UTC (rev 6387)
@@ -11,12 +11,17 @@
 0.7.3 to HEAD
 =============
 
-Run gnunet-update.  Read up on gnunet-auto-share.  Note that
-due to the break in backwards-compatibility, peers running
-the new version will not connect to peers running 0.7.3 and
+Run gnunet-update.  Drop the tables in your old datastore(s) and
+delete "$GNUNETD_HOME/data/fs/" and "$GNUNETD_HOME/data/shared/".
+
+Note that due to the various breaks in backwards-compatibility, peers
+running the new version will not connect to peers running 0.7.3 and
 older.  Check that the hostlists that you are using in your
 configuration file are for peers running HEAD.
 
+Read up on gnunet-auto-share.  
+
+
 0.7.2c to 0.7.3
 ===============
 

Modified: GNUnet/src/applications/bootstrap_http/http.c
===================================================================
--- GNUnet/src/applications/bootstrap_http/http.c       2008-02-20 00:09:30 UTC 
(rev 6386)
+++ GNUnet/src/applications/bootstrap_http/http.c       2008-02-20 03:41:55 UTC 
(rev 6387)
@@ -223,13 +223,14 @@
   GNUNET_GE_LOG (ectx,
                  GNUNET_GE_INFO | GNUNET_GE_BULK | GNUNET_GE_USER,
                  _("Bootstrapping using `%s'.\n"), url);
-  purl = GNUNET_malloc(strlen(url) + 40);
+  purl = GNUNET_malloc (strlen (url) + 40);
   protocols = 0;
-  for 
(i=GNUNET_TRANSPORT_PROTOCOL_NUMBER_MAX;i>GNUNET_TRANSPORT_PROTOCOL_NUMBER_NAT;i--)
-    if (transport->isAvailable((unsigned short)i))
-      protocols |= (1LL << i);    
-  sprintf(purl, "%s&p=%llu", url, protocols);
-  GNUNET_free(url);
+  for (i = GNUNET_TRANSPORT_PROTOCOL_NUMBER_MAX;
+       i > GNUNET_TRANSPORT_PROTOCOL_NUMBER_NAT; i--)
+    if (transport->isAvailable ((unsigned short) i))
+      protocols |= (1LL << i);
+  sprintf (purl, "%s&p=%llu", url, protocols);
+  GNUNET_free (url);
   url = purl;
   bctx.url = url;
   bctx.total = 0;
@@ -285,7 +286,7 @@
         {
           GNUNET_GE_LOG (ectx,
                          GNUNET_GE_ERROR | GNUNET_GE_ADMIN | GNUNET_GE_USER |
-                        GNUNET_GE_BULK, _("%s failed at %s:%d: `%s'\n"),
+                         GNUNET_GE_BULK, _("%s failed at %s:%d: `%s'\n"),
                          "curl_multi_fdset", __FILE__, __LINE__,
                          curl_multi_strerror (mret));
           goto cleanup;

Modified: GNUnet/src/applications/chat/chat.c
===================================================================
--- GNUnet/src/applications/chat/chat.c 2008-02-20 00:09:30 UTC (rev 6386)
+++ GNUnet/src/applications/chat/chat.c 2008-02-20 03:41:55 UTC (rev 6387)
@@ -46,7 +46,7 @@
 
 struct GNUNET_Server_Chat_Room
 {
-  
+
   struct GNUNET_ThreadHandle *listen_thread;
 
   struct GNUNET_GE_Context *ectx;
@@ -61,10 +61,10 @@
 
 struct GNUNET_CS_chat_client
 {
-       struct GNUNET_ClientHandle *client;
-       struct GNUNET_CS_chat_client *next;
-       struct GNUNET_CS_chat_client *prev;
-       GNUNET_HashCode room_name_hash;
+  struct GNUNET_ClientHandle *client;
+  struct GNUNET_CS_chat_client *next;
+  struct GNUNET_CS_chat_client *prev;
+  GNUNET_HashCode room_name_hash;
 
 };
 
@@ -108,9 +108,9 @@
                  const GNUNET_MessageHeader * message)
 {
   CS_chat_MESSAGE *cmsg;
-  
+
   struct GNUNET_CS_chat_client *tempClient;
-  
+
   GNUNET_HashCode hc;
   GNUNET_HashCode room_name_hash;
 
@@ -122,7 +122,7 @@
   unsigned long nick_len;
   unsigned long msg_len;
   unsigned long room_name_len;
-  
+
   cmsg = (CS_chat_MESSAGE *) message;
 
   if (ntohs (cmsg->header.size) < sizeof (CS_chat_MESSAGE))
@@ -151,9 +151,9 @@
   nick[nick_len] = '\0';
   message_content[msg_len] = '\0';
   room_name[room_name_len] = '\0';
-  
-  GNUNET_hash(room_name,strlen(room_name),&room_name_hash);
 
+  GNUNET_hash (room_name, strlen (room_name), &room_name_hash);
+
   GNUNET_GE_LOG (ectx,
                  GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER,
                  "Received chat message from client.\n Message is %s\n from 
%s\n intended for room %s\n",
@@ -164,32 +164,36 @@
 
   GNUNET_mutex_lock (chatMutex);
 
-       /*TODO: we have received a message intended for some room, check 
current client contexts for matching room and send to those clients */
-       /*TODO: p2p messages will need to be sent as well at some point*/
-       
-       tempClient = &client_list;
-  while((tempClient->next != NULL)&&(tempClient->client != NULL))
-  {
-       
if(memcmp(&room_name_hash,&tempClient->room_name_hash,sizeof(GNUNET_HashCode))==0)
-       {
-               fprintf(stderr,"room names match, must send message to 
others!!\n");
-               coreAPI->cs_send_to_client (tempClient->client, message, 
GNUNET_YES);
-       }
-       
-       tempClient = tempClient->next;  
-  }
-         
+  /*TODO: we have received a message intended for some room, check current 
client contexts for matching room and send to those clients */
+  /*TODO: p2p messages will need to be sent as well at some point */
 
+  tempClient = &client_list;
+  while ((tempClient->next != NULL) && (tempClient->client != NULL))
+    {
+      if (memcmp
+          (&room_name_hash, &tempClient->room_name_hash,
+           sizeof (GNUNET_HashCode)) == 0)
+        {
+          fprintf (stderr,
+                   "room names match, must send message to others!!\n");
+          coreAPI->cs_send_to_client (tempClient->client, message,
+                                      GNUNET_YES);
+        }
+
+      tempClient = tempClient->next;
+    }
+
+
   markSeen (&hc);
   broadcastToConnected (message, 5, 1);
-  
-  
+
+
   GNUNET_mutex_unlock (chatMutex);
-  
-  GNUNET_free(room_name);
-  GNUNET_free(nick);
-  GNUNET_free(message_content);
-  
+
+  GNUNET_free (room_name);
+  GNUNET_free (nick);
+  GNUNET_free (message_content);
+
   return GNUNET_OK;
 }
 
@@ -212,7 +216,7 @@
   unsigned long pubkey_len;
   unsigned long room_name_len;
   struct GNUNET_CS_chat_client *tempClient;
-  
+
   pmsg = (P2P_chat_MESSAGE *) message;
   cmsg = (CS_chat_JOIN_MESSAGE *) message;
 
@@ -249,127 +253,129 @@
   nick[nick_len] = '\0';
   room_name[room_name_len] = '\0';
   GNUNET_hash (cmsg, header_size, &hc);
-  GNUNET_hash(room_name,strlen(room_name),&room_name_hash);
+  GNUNET_hash (room_name, strlen (room_name), &room_name_hash);
   GNUNET_mutex_lock (chatMutex);
   markSeen (&hc);
-  
+
   /*TODO: create client context on the server, very simple as of now */
   tempClient = &client_list;
-  while((tempClient->next != NULL)&&(tempClient->client != NULL))
-       tempClient = tempClient->next;
+  while ((tempClient->next != NULL) && (tempClient->client != NULL))
+    tempClient = tempClient->next;
 
-       tempClient->client = client;
-       tempClient->next = GNUNET_malloc(sizeof(struct GNUNET_CS_chat_client));
-       tempClient->next->prev = tempClient;
-       
memcpy(&tempClient->room_name_hash,&room_name_hash,sizeof(GNUNET_HashCode));
-       tempClient = &client_list;
-       
-       tempCount = 0;
-       while((tempClient->next != NULL)&&(tempClient->client != NULL))
-       {
-                       tempCount++;
-                       tempClient = tempClient->next;
-       }
-                       
-       fprintf(stderr,"Number of clients currently is... %d\n",tempCount);
-  
+  tempClient->client = client;
+  tempClient->next = GNUNET_malloc (sizeof (struct GNUNET_CS_chat_client));
+  tempClient->next->prev = tempClient;
+  memcpy (&tempClient->room_name_hash, &room_name_hash,
+          sizeof (GNUNET_HashCode));
+  tempClient = &client_list;
 
+  tempCount = 0;
+  while ((tempClient->next != NULL) && (tempClient->client != NULL))
+    {
+      tempCount++;
+      tempClient = tempClient->next;
+    }
+
+  fprintf (stderr, "Number of clients currently is... %d\n", tempCount);
+
+
   /* forward to all other TCP chat clients */
   /* marker to check if this is a new client */
   /*
-  j = -1;
-  for (i = 0; i < clientCount; i++)
-    if (clients[i] == client)
-      j = i;
-    else
-      coreAPI->cs_send_to_client (clients[i], message, GNUNET_YES);
-         if (j == -1)
-           {
-             if (clientCount == MAX_CLIENTS)
-               GNUNET_GE_LOG (ectx,
-                              GNUNET_GE_WARNING | GNUNET_GE_BULK | 
GNUNET_GE_USER,
-                              _("Maximum number of chat clients reached.\n"));
-             else
-               {
-                 GNUNET_array_grow (clients, clientCount, clientCount + 1);
-                 clients[clientCount] = client;
-                 ++clientCount;
-                 GNUNET_GE_LOG (ectx,
-                                GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | 
GNUNET_GE_USER,
-                                _("Now %d of %d chat clients at this node.\n"),
-                                clientCount, MAX_CLIENTS);
-               }
-           }
-       */
+     j = -1;
+     for (i = 0; i < clientCount; i++)
+     if (clients[i] == client)
+     j = i;
+     else
+     coreAPI->cs_send_to_client (clients[i], message, GNUNET_YES);
+     if (j == -1)
+     {
+     if (clientCount == MAX_CLIENTS)
+     GNUNET_GE_LOG (ectx,
+     GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER,
+     _("Maximum number of chat clients reached.\n"));
+     else
+     {
+     GNUNET_array_grow (clients, clientCount, clientCount + 1);
+     clients[clientCount] = client;
+     ++clientCount;
+     GNUNET_GE_LOG (ectx,
+     GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_USER,
+     _("Now %d of %d chat clients at this node.\n"),
+     clientCount, MAX_CLIENTS);
+     }
+     }
+   */
   /* forward to all other nodes in the network */
   /*pmsg->header.type = htons (GNUNET_P2P_PROTO_CHAT_MSG);
      broadcastToConnected (&pmsg->header, 5, 1); */
-  GNUNET_free(nick);
-  GNUNET_free(client_key);
-  GNUNET_free(room_name);
- 
+  GNUNET_free (nick);
+  GNUNET_free (client_key);
+  GNUNET_free (room_name);
+
   GNUNET_mutex_unlock (chatMutex);
   fprintf (stderr, "End of handleChatRequest\n");
   return GNUNET_OK;
 }
 
 static int
-csHandleChatLeaveRequest (struct GNUNET_ClientHandle *client,const 
GNUNET_MessageHeader * message)
+csHandleChatLeaveRequest (struct GNUNET_ClientHandle *client,
+                          const GNUNET_MessageHeader * message)
 {
-  /*GNUNET_RSA_PublicKey *client_key;*/ /*May use later for extra 
verification*/
+  /*GNUNET_RSA_PublicKey *client_key; *//*May use later for extra verification 
*/
   int tempCount;
 
   struct GNUNET_CS_chat_client *tempClient;
   struct GNUNET_CS_chat_client *tempClientToRemove;
- 
+
   /*client_key = GNUNET_malloc (sizeof (GNUNET_RSA_PublicKey));
-  memcpy (client_key, &cmsg->nick[nick_len], pubkey_len);*/
- 
+     memcpy (client_key, &cmsg->nick[nick_len], pubkey_len); */
+
   GNUNET_GE_LOG (ectx,
                  GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_DEVELOPER,
                  "Received leave chat room message from client.\n");
 
-  
+
   GNUNET_mutex_lock (chatMutex);
-  
-  /*TODO: delete client context on the server*/
-       
+
+  /*TODO: delete client context on the server */
+
   tempClient = &client_list;
-  while((tempClient->next != NULL)&&(tempClient->client != NULL))
-  {
-       if (memcmp(tempClient->client,client,sizeof(client)) == 0)
-       {
-               fprintf(stderr,"Client handle matches, remove it!\n");
-               if(tempClient->prev == NULL)
-               {
-                       tempClient->next->prev = NULL;
-                       /*tempClientToRemove = &client_list;*/
-                       client_list = *tempClient->next;        
-               }
-               else
-               {
-                       tempClient->next->prev = tempClient->prev;
-                       tempClient->prev->next = tempClient->next;
-                       tempClientToRemove = tempClient;
-                       tempClient = tempClient->next;
-                       GNUNET_free(tempClientToRemove);
-               }
-       }
-       else
-               tempClient = tempClient->next;
-  
-  }
-       
-       /*Count the number of current clients, will be removed*/
-       tempClient = &client_list;
-       tempCount = 0;
-       while((tempClient->next != NULL)&&(tempClient->client != NULL))
-       {
-               tempCount++;
-               tempClient = tempClient->next;
-       }               
-       fprintf(stderr,"Number of clients currently is... %d\n",tempCount);
+  while ((tempClient->next != NULL) && (tempClient->client != NULL))
+    {
+      if (memcmp (tempClient->client, client, sizeof (client)) == 0)
+        {
+          fprintf (stderr, "Client handle matches, remove it!\n");
+          if (tempClient->prev == NULL)
+            {
+              tempClient->next->prev = NULL;
+              /*tempClientToRemove = &client_list; */
+              client_list = *tempClient->next;
+            }
+          else
+            {
+              tempClient->next->prev = tempClient->prev;
+              tempClient->prev->next = tempClient->next;
+              tempClientToRemove = tempClient;
+              tempClient = tempClient->next;
+              GNUNET_free (tempClientToRemove);
+            }
+        }
+      else
+        tempClient = tempClient->next;
 
+    }
+
+  /*Count the number of current clients, will be removed */
+  tempClient = &client_list;
+  tempCount = 0;
+  while ((tempClient->next != NULL) && (tempClient->client != NULL))
+    {
+      tempCount++;
+      tempClient = tempClient->next;
+    }
+  fprintf (stderr, "Number of clients currently is... %d\n", tempCount);
+
   GNUNET_mutex_unlock (chatMutex);
   fprintf (stderr, "End of handleChatLeave\n");
   return GNUNET_OK;
@@ -380,8 +386,8 @@
 chatClientExitHandler (struct GNUNET_ClientHandle *client)
 {
   GNUNET_mutex_lock (chatMutex);
-  
-  
+
+
   GNUNET_mutex_unlock (chatMutex);
 }
 
@@ -409,17 +415,17 @@
   if (GNUNET_SYSERR ==
       capi->cs_exit_handler_register (&chatClientExitHandler))
     ok = GNUNET_SYSERR;
-    
+
   if (GNUNET_SYSERR ==
       capi->registerClientHandler (GNUNET_CS_PROTO_CHAT_JOIN_MSG,
                                    &csHandleChatRequest))
     ok = GNUNET_SYSERR;
-    
+
   if (GNUNET_SYSERR ==
       capi->registerClientHandler (GNUNET_CS_PROTO_CHAT_LEAVE_MSG,
                                    &csHandleChatLeaveRequest))
     ok = GNUNET_SYSERR;
-    
+
   if (GNUNET_SYSERR == capi->registerClientHandler (GNUNET_CS_PROTO_CHAT_MSG,
                                                     &csHandleChatMSG))
     ok = GNUNET_SYSERR;

Modified: GNUnet/src/applications/chat/clientapi.c
===================================================================
--- GNUnet/src/applications/chat/clientapi.c    2008-02-20 00:09:30 UTC (rev 
6386)
+++ GNUnet/src/applications/chat/clientapi.c    2008-02-20 03:41:55 UTC (rev 
6387)
@@ -79,73 +79,80 @@
 static void *
 poll_thread (void *rcls)
 {
-       int ret = GNUNET_OK;
-  struct GNUNET_CHAT_Room *room = (struct GNUNET_CHAT_Room *)rcls;
+  int ret = GNUNET_OK;
+  struct GNUNET_CHAT_Room *room = (struct GNUNET_CHAT_Room *) rcls;
   GNUNET_MessageHeader *reply;
-       
-       CS_chat_MESSAGE *received_msg;
-  
+
+  CS_chat_MESSAGE *received_msg;
+
   unsigned int size;
   unsigned int nick_len;
   unsigned int msg_len;
   unsigned int room_name_len;
   unsigned int retries;
-  
+
   char *nick;
   char *message_content;
   char *room_name;
-     
-  while(ret == GNUNET_OK)
-  {
-       if (GNUNET_client_connection_test_connected (room->sock) == GNUNET_NO)
-       {               
-               retries = 0;
-               while((GNUNET_client_connection_test_connected (room->sock) == 
GNUNET_NO) && (retries < MAX_RETRIES))
-               {
-                       
-               }
-       }
-       
-       reply = NULL;
-       
-               if (GNUNET_OK != GNUNET_client_connection_read (room->sock, 
&reply))
-               {
-      
-      break;
-               }
-    
-    if ((reply->size < ntohs(sizeof (GNUNET_MessageHeader) + sizeof 
(CS_chat_MESSAGE)))||(reply->type != ntohs (GNUNET_CS_PROTO_CHAT_MSG)))
-       break;
-       
-               size = ntohs(reply->size);
-               
-               received_msg = (CS_chat_MESSAGE *)reply;
-               
-               nick_len = ntohl (received_msg->nick_len);
-               msg_len = ntohl (received_msg->msg_len);
-               room_name_len = ntohl (received_msg->room_name_len);
-               
-               nick = GNUNET_malloc (nick_len + 1);
-               message_content = GNUNET_malloc (msg_len + 1);
-               room_name = GNUNET_malloc (room_name_len + 1);
-               
-               memcpy (nick, &received_msg->nick[0], nick_len);
-               memcpy (message_content, &received_msg->nick[nick_len], 
msg_len);
-               memcpy (room_name, &received_msg->nick[nick_len + msg_len], 
room_name_len);
-               
-               nick[nick_len] = '\0';
-               message_content[msg_len] = '\0';
-               room_name[room_name_len] = '\0';
-               
-               if(GNUNET_OK != 
room->callback(room->callback_cls,room,nick,message_content,GNUNET_get_time(),0))
-               {
-                       ret = GNUNET_SYSERR;
-               }
-       
-       }    
 
-  return (void *)ret;
+  while (ret == GNUNET_OK)
+    {
+      if (GNUNET_client_connection_test_connected (room->sock) == GNUNET_NO)
+        {
+          retries = 0;
+          while ((GNUNET_client_connection_test_connected (room->sock) ==
+                  GNUNET_NO) && (retries < MAX_RETRIES))
+            {
+
+            }
+        }
+
+      reply = NULL;
+
+      if (GNUNET_OK != GNUNET_client_connection_read (room->sock, &reply))
+        {
+
+          break;
+        }
+
+      if ((reply->size <
+           ntohs (sizeof (GNUNET_MessageHeader) + sizeof (CS_chat_MESSAGE)))
+          || (reply->type != ntohs (GNUNET_CS_PROTO_CHAT_MSG)))
+        break;
+
+      size = ntohs (reply->size);
+
+      received_msg = (CS_chat_MESSAGE *) reply;
+
+      nick_len = ntohl (received_msg->nick_len);
+      msg_len = ntohl (received_msg->msg_len);
+      room_name_len = ntohl (received_msg->room_name_len);
+
+      nick = GNUNET_malloc (nick_len + 1);
+      message_content = GNUNET_malloc (msg_len + 1);
+      room_name = GNUNET_malloc (room_name_len + 1);
+
+      memcpy (nick, &received_msg->nick[0], nick_len);
+      memcpy (message_content, &received_msg->nick[nick_len], msg_len);
+      memcpy (room_name, &received_msg->nick[nick_len + msg_len],
+              room_name_len);
+
+      nick[nick_len] = '\0';
+      message_content[msg_len] = '\0';
+      room_name[room_name_len] = '\0';
+
+      if (GNUNET_OK !=
+          room->callback (room->callback_cls, room, nick, message_content,
+                          GNUNET_get_time (), 0))
+        {
+          ret = GNUNET_SYSERR;
+        }
+
+    }
+
+  return (void *) ret;
 }
+
 /**
  * List all of the (publically visible) chat rooms.
  * @return number of rooms on success, GNUNET_SYSERR if iterator aborted
@@ -256,14 +263,15 @@
   chat_room->sock = sock;
 
   // create pthread
-  chat_room->listen_thread = GNUNET_thread_create (&poll_thread, chat_room, 
1024 * 2);
+  chat_room->listen_thread =
+    GNUNET_thread_create (&poll_thread, chat_room, 1024 * 2);
 
   // return room struct
   if (ret != GNUNET_OK)
-  {
-    GNUNET_free(chat_room);
-    return NULL;
-  }
+    {
+      GNUNET_free (chat_room);
+      return NULL;
+    }
   return chat_room;
 }
 
@@ -273,15 +281,17 @@
 void
 GNUNET_CHAT_leave_room (struct GNUNET_CHAT_Room *chat_room)
 {
-       GNUNET_MessageHeader csHdr;
-       csHdr.type = htons(GNUNET_CS_PROTO_CHAT_LEAVE_MSG);
-       csHdr.size = htons(sizeof(csHdr));
-               
-  /*If this fails we don't care, this means the socket is already gone and the 
server should know how to deal with that!*/
-  /*We may not even need this message at all, just let the server handle a 
dead socket*/
-  GNUNET_GE_ASSERT(NULL,GNUNET_client_connection_write (chat_room->sock, 
&csHdr) == GNUNET_OK);
-  
-  
+  GNUNET_MessageHeader csHdr;
+  csHdr.type = htons (GNUNET_CS_PROTO_CHAT_LEAVE_MSG);
+  csHdr.size = htons (sizeof (csHdr));
+
+  /*If this fails we don't care, this means the socket is already gone and the 
server should know how to deal with that! */
+  /*We may not even need this message at all, just let the server handle a 
dead socket */
+  GNUNET_GE_ASSERT (NULL,
+                    GNUNET_client_connection_write (chat_room->sock,
+                                                    &csHdr) == GNUNET_OK);
+
+
   // stop thread
   // join thread
   // free room struct

Modified: GNUnet/src/applications/chat/gnunet-chat.c
===================================================================
--- GNUnet/src/applications/chat/gnunet-chat.c  2008-02-20 00:09:30 UTC (rev 
6386)
+++ GNUnet/src/applications/chat/gnunet-chat.c  2008-02-20 03:41:55 UTC (rev 
6387)
@@ -152,15 +152,15 @@
       ret = GNUNET_SYSERR;
     }
 
-       if (ret == GNUNET_OK)
-       {
-       room = GNUNET_CHAT_join_room (ectx,
-                                cfg,
-                                nickname, room_name,
-                                &my_pub, my_priv, "", &receive_callback,
-                                NULL);
-       }
-       
+  if (ret == GNUNET_OK)
+    {
+      room = GNUNET_CHAT_join_room (ectx,
+                                    cfg,
+                                    nickname, room_name,
+                                    &my_pub, my_priv, "", &receive_callback,
+                                    NULL);
+    }
+
   if (room == NULL)
     {
       fprintf (stderr, _("Failed to join the room\n"));
@@ -198,16 +198,16 @@
 
     }
 
-  fprintf(stderr,"Cleaning up...\n");
-       if (room != NULL)
-       {
-       GNUNET_CHAT_leave_room (room);
-       GNUNET_free (room);
-       }
-       if (message != NULL)
-       {
-       GNUNET_free (message);
-       }
+  fprintf (stderr, "Cleaning up...\n");
+  if (room != NULL)
+    {
+      GNUNET_CHAT_leave_room (room);
+      GNUNET_free (room);
+    }
+  if (message != NULL)
+    {
+      GNUNET_free (message);
+    }
   GNUNET_fini (ectx, cfg);
   return GNUNET_OK;
 }

Modified: GNUnet/src/applications/datastore/datastore.c
===================================================================
--- GNUnet/src/applications/datastore/datastore.c       2008-02-20 00:09:30 UTC 
(rev 6386)
+++ GNUnet/src/applications/datastore/datastore.c       2008-02-20 03:41:55 UTC 
(rev 6387)
@@ -127,7 +127,7 @@
         stats->change (stat_filtered, 1);
       return 0;
     }
-  ret = sq->get (query, type, iter, closure);
+  ret = sq->get (query, NULL, type, iter, closure);
   if ((ret == 0) && (stats != NULL))
     stats->change (stat_filter_failed, 1);
   return ret;
@@ -159,6 +159,7 @@
   int ok;
   int ret;
   GNUNET_EncName enc;
+  GNUNET_HashCode vhc;
 
   if (!testAvailable (query))
     {
@@ -171,7 +172,9 @@
                      __FILE__, __LINE__);
       return GNUNET_NO;
     }
-  ok = sq->get (query, ntohl (value->type), &deleteCB, (void *) value);
+  GNUNET_hash (&value[1],
+               ntohl (value->size) - sizeof (GNUNET_DatastoreValue), &vhc);
+  ok = sq->get (query, &vhc, ntohl (value->type), &deleteCB, (void *) value);
   if (ok == GNUNET_SYSERR)
     return GNUNET_SYSERR;
   if (ok == 0)
@@ -287,15 +290,19 @@
   int ok;
   int comp_prio;
   GNUNET_DatastoreValue *nvalue;
+  GNUNET_HashCode vhc;
 
   /* check if it already exists... */
   cls.exists = GNUNET_NO;
   cls.value = value;
-  sq->get (key, ntohl (value->type), &checkExists, &cls);
+  GNUNET_hash (&value[1],
+               ntohl (value->size) - sizeof (GNUNET_DatastoreValue), &vhc);
+  sq->get (key, &vhc, ntohl (value->type), &checkExists, &cls);
   if ((!cls.exists) && (ntohl (value->type) == GNUNET_ECRS_BLOCKTYPE_DATA))
-    sq->get (key, GNUNET_ECRS_BLOCKTYPE_ONDEMAND, &checkExists, &cls);
+    sq->get (key, &vhc, GNUNET_ECRS_BLOCKTYPE_ONDEMAND, &checkExists, &cls);
   if ((!cls.exists) && (ntohl (value->type) == GNUNET_ECRS_BLOCKTYPE_DATA))
-    sq->get (key, GNUNET_ECRS_BLOCKTYPE_ONDEMAND_OLD, &checkExists, &cls);
+    sq->get (key, &vhc, GNUNET_ECRS_BLOCKTYPE_ONDEMAND_OLD, &checkExists,
+             &cls);
   if (cls.exists)
     {
       if ((ntohl (value->prio) == 0) &&

Modified: GNUnet/src/applications/fs/ecrs/upload.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/upload.c    2008-02-20 00:09:30 UTC (rev 
6386)
+++ GNUnet/src/applications/fs/ecrs/upload.c    2008-02-20 03:41:55 UTC (rev 
6387)
@@ -319,8 +319,8 @@
             }
           GNUNET_GE_ASSERT (ectx, value != NULL);
           *value = *dblock;     /* copy options! */
-         if ( (doIndex == GNUNET_NO) &&
-              (GNUNET_SYSERR == GNUNET_FS_insert (sock, value)) )
+          if ((doIndex == GNUNET_NO) &&
+              (GNUNET_SYSERR == GNUNET_FS_insert (sock, value)))
             {
               GNUNET_GE_BREAK (ectx, 0);
               GNUNET_free (value);
@@ -393,8 +393,8 @@
         }
       value->expirationTime = GNUNET_htonll (expirationTime);
       value->prio = htonl (priority);
-      if ( (doIndex != GNUNET_SYSERR) &&
-          (GNUNET_SYSERR == GNUNET_FS_insert (sock, value)) )
+      if ((doIndex != GNUNET_SYSERR) &&
+          (GNUNET_SYSERR == GNUNET_FS_insert (sock, value)))
         {
           GNUNET_GE_BREAK (ectx, 0);
           GNUNET_free (value);

Modified: GNUnet/src/applications/fs/fsui/upload.c
===================================================================
--- GNUnet/src/applications/fs/fsui/upload.c    2008-02-20 00:09:30 UTC (rev 
6386)
+++ GNUnet/src/applications/fs/fsui/upload.c    2008-02-20 03:41:55 UTC (rev 
6387)
@@ -347,7 +347,8 @@
                              utc->shared->doIndex ==
                              GNUNET_YES ? (utc->child ==
                                            NULL ? GNUNET_YES : GNUNET_NO) :
-                             utc->shared->doIndex, utc->shared->anonymityLevel,
+                             utc->shared->doIndex,
+                             utc->shared->anonymityLevel,
                              utc->shared->priority, utc->shared->expiration,
                              &progressCallback, utc, &testTerminate, utc,
                              &utc->uri);
@@ -385,106 +386,109 @@
   if (utc->shared->doIndex != GNUNET_SYSERR)
     {
       if (utc->child == NULL)
-       GNUNET_ECRS_meta_data_extract_from_file (utc->shared->ctx->ectx,
-                                                utc->meta, utc->filename,
-                                                utc->shared->extractors);
+        GNUNET_ECRS_meta_data_extract_from_file (utc->shared->ctx->ectx,
+                                                 utc->meta, utc->filename,
+                                                 utc->shared->extractors);
       while (GNUNET_OK ==
-            GNUNET_ECRS_meta_data_delete (utc->meta, EXTRACTOR_FILENAME, 
NULL));
+             GNUNET_ECRS_meta_data_delete (utc->meta, EXTRACTOR_FILENAME,
+                                           NULL));
       /* only publish the last part of the path
-        -- we do not want to publish $HOME or similar
-        trivially deanonymizing information */
+         -- we do not want to publish $HOME or similar
+         trivially deanonymizing information */
       tpos = strlen (utc->filename) - 1;
       if ((utc->filename[tpos] == DIR_SEPARATOR) && (tpos > 0))
-       tpos--;
+        tpos--;
       while ((tpos > 0) && (utc->filename[tpos] != DIR_SEPARATOR))
-       tpos--;
+        tpos--;
       pfn = GNUNET_malloc (strlen (&utc->filename[tpos + 1]) + 2);
       strcpy (pfn, &utc->filename[tpos + 1]);
       if ((utc->child != NULL) &&
-         ((strlen (pfn) == 0) || (pfn[strlen (pfn) - 1] != DIR_SEPARATOR)))
-       strcat (pfn, DIR_SEPARATOR_STR);
+          ((strlen (pfn) == 0) || (pfn[strlen (pfn) - 1] != DIR_SEPARATOR)))
+        strcat (pfn, DIR_SEPARATOR_STR);
       GNUNET_ECRS_meta_data_insert (utc->meta, EXTRACTOR_FILENAME, pfn);
       GNUNET_free (pfn);
       if ((utc->shared->anonymityLevel == 0)
-         && (utc->shared->doIndex == GNUNET_YES))
-       {
-         /* generate location URI for non-anonymous download */
-         struct GNUNET_ClientServerConnection *sock;
-         GNUNET_MessageHello *hello;
-         
-         sock = GNUNET_client_connection_create (utc->shared->ctx->ectx,
-                                                 utc->shared->ctx->cfg);
-         
-         if (GNUNET_OK == GNUNET_IDENTITY_get_self (sock, &hello))
-           {
-             loc = GNUNET_ECRS_location_to_uri (utc->uri,
-                                                &hello->publicKey,
-                                                ntohl (hello->expirationTime),
-                                                (GNUNET_ECRS_SignFunction) &
-                                                GNUNET_IDENTITY_sign_function,
-                                                sock);
-             
-             GNUNET_free (hello);
-           }
-         else
-           {
-             /* may happen if no transports are available... */
-             loc = GNUNET_ECRS_uri_duplicate (utc->uri);
-           }
-         GNUNET_client_connection_destroy (sock);
-       }
+          && (utc->shared->doIndex == GNUNET_YES))
+        {
+          /* generate location URI for non-anonymous download */
+          struct GNUNET_ClientServerConnection *sock;
+          GNUNET_MessageHello *hello;
+
+          sock = GNUNET_client_connection_create (utc->shared->ctx->ectx,
+                                                  utc->shared->ctx->cfg);
+
+          if (GNUNET_OK == GNUNET_IDENTITY_get_self (sock, &hello))
+            {
+              loc = GNUNET_ECRS_location_to_uri (utc->uri,
+                                                 &hello->publicKey,
+                                                 ntohl (hello->
+                                                        expirationTime),
+                                                 (GNUNET_ECRS_SignFunction) &
+                                                 GNUNET_IDENTITY_sign_function,
+                                                 sock);
+
+              GNUNET_free (hello);
+            }
+          else
+            {
+              /* may happen if no transports are available... */
+              loc = GNUNET_ECRS_uri_duplicate (utc->uri);
+            }
+          GNUNET_client_connection_destroy (sock);
+        }
       else
-       {
-         /* no location URI, use standard URI
-            (copied here to allow free later) */
-         loc = GNUNET_ECRS_uri_duplicate (utc->uri);
-       }
+        {
+          /* no location URI, use standard URI
+             (copied here to allow free later) */
+          loc = GNUNET_ECRS_uri_duplicate (utc->uri);
+        }
       while (GNUNET_OK ==
-            GNUNET_ECRS_meta_data_delete (utc->meta, EXTRACTOR_SPLIT, NULL));
+             GNUNET_ECRS_meta_data_delete (utc->meta, EXTRACTOR_SPLIT, NULL));
       while (GNUNET_OK ==
-            GNUNET_ECRS_meta_data_delete (utc->meta, EXTRACTOR_LOWERCASE, 
NULL));
+             GNUNET_ECRS_meta_data_delete (utc->meta, EXTRACTOR_LOWERCASE,
+                                           NULL));
       if (utc->shared->global_keywords != NULL)
-       GNUNET_ECRS_publish_under_keyword (ectx,
-                                          utc->shared->ctx->cfg,
-                                          utc->shared->global_keywords,
-                                          utc->shared->anonymityLevel,
-                                          utc->shared->priority,
-                                          utc->shared->expiration, loc,
-                                          utc->meta);
+        GNUNET_ECRS_publish_under_keyword (ectx,
+                                           utc->shared->ctx->cfg,
+                                           utc->shared->global_keywords,
+                                           utc->shared->anonymityLevel,
+                                           utc->shared->priority,
+                                           utc->shared->expiration, loc,
+                                           utc->meta);
       if (utc->keywords != NULL)
-       GNUNET_ECRS_publish_under_keyword (ectx,
-                                          utc->shared->ctx->cfg,
-                                          utc->keywords,
-                                          utc->shared->anonymityLevel,
-                                          utc->shared->priority,
-                                          utc->shared->expiration, loc,
-                                          utc->meta);
+        GNUNET_ECRS_publish_under_keyword (ectx,
+                                           utc->shared->ctx->cfg,
+                                           utc->keywords,
+                                           utc->shared->anonymityLevel,
+                                           utc->shared->priority,
+                                           utc->shared->expiration, loc,
+                                           utc->meta);
       if (utc->shared->individualKeywords == GNUNET_YES)
-       {
-         uri = GNUNET_ECRS_meta_data_to_uri (utc->meta);
-         GNUNET_ECRS_publish_under_keyword (ectx,
-                                            utc->shared->ctx->cfg,
-                                            uri,
-                                            utc->shared->anonymityLevel,
-                                            utc->shared->priority,
-                                            utc->shared->expiration, loc,
-                                            utc->meta);
-         GNUNET_ECRS_uri_destroy (uri);
-       }
+        {
+          uri = GNUNET_ECRS_meta_data_to_uri (utc->meta);
+          GNUNET_ECRS_publish_under_keyword (ectx,
+                                             utc->shared->ctx->cfg,
+                                             uri,
+                                             utc->shared->anonymityLevel,
+                                             utc->shared->priority,
+                                             utc->shared->expiration, loc,
+                                             utc->meta);
+          GNUNET_ECRS_uri_destroy (uri);
+        }
       GNUNET_ECRS_uri_destroy (loc);
       loc = NULL;
       fi.meta = utc->meta;
       fi.uri = utc->uri;
       if (utc->shared->doIndex != GNUNET_SYSERR)
-       {
-         GNUNET_URITRACK_track (ectx, utc->shared->ctx->cfg, &fi);
-         GNUNET_URITRACK_add_state (ectx,
-                                    utc->shared->ctx->cfg,
-                                    utc->uri,
-                                    utc->shared->doIndex ==
-                                    GNUNET_YES ? GNUNET_URITRACK_INDEXED :
-                                    GNUNET_URITRACK_INSERTED);
-       }
+        {
+          GNUNET_URITRACK_track (ectx, utc->shared->ctx->cfg, &fi);
+          GNUNET_URITRACK_add_state (ectx,
+                                     utc->shared->ctx->cfg,
+                                     utc->uri,
+                                     utc->shared->doIndex ==
+                                     GNUNET_YES ? GNUNET_URITRACK_INDEXED :
+                                     GNUNET_URITRACK_INSERTED);
+        }
     }
   event.type = GNUNET_FSUI_upload_completed;
   event.data.UploadCompleted.uc.pos = utc;

Modified: GNUnet/src/applications/fs/gap/gap.c
===================================================================
--- GNUnet/src/applications/fs/gap/gap.c        2008-02-20 00:09:30 UTC (rev 
6386)
+++ GNUnet/src/applications/fs/gap/gap.c        2008-02-20 03:41:55 UTC (rev 
6387)
@@ -258,8 +258,8 @@
               GNUNET_FS_PT_change_rc (peer, -1);
               if (stats != NULL)
                 stats->change (stat_gap_query_dropped_redundant, 1);
-             if (type != GNUNET_ECRS_BLOCKTYPE_DATA)
-               goto CHECK; /* we may have more local results! */
+              if (type != GNUNET_ECRS_BLOCKTYPE_DATA)
+                goto CHECK;     /* we may have more local results! */
               GNUNET_mutex_unlock (GNUNET_FS_lock);
               return;
             }
@@ -279,8 +279,8 @@
                                          bloomfilter_data, filter_size);
                 }
               GNUNET_FS_PT_change_rc (peer, -1);
-             if (type != GNUNET_ECRS_BLOCKTYPE_DATA)
-               goto CHECK; /* we may have more local results! */
+              if (type != GNUNET_ECRS_BLOCKTYPE_DATA)
+                goto CHECK;     /* we may have more local results! */
               GNUNET_mutex_unlock (GNUNET_FS_lock);
               return;
             }
@@ -297,8 +297,8 @@
           else
             rl->bloomfilter = NULL;
           GNUNET_FS_PT_change_rc (peer, -1);
-         if (type != GNUNET_ECRS_BLOCKTYPE_DATA)
-           goto CHECK; /* we may have more local results! */
+          if (type != GNUNET_ECRS_BLOCKTYPE_DATA)
+            goto CHECK;         /* we may have more local results! */
           GNUNET_mutex_unlock (GNUNET_FS_lock);
           return;
         }
@@ -361,7 +361,7 @@
   if (stats != NULL)
     stats->change (stat_gap_query_routed, 1);
   /* check local data store */
- CHECK:
+CHECK:
   cls.request = rl;
   cls.iteration_count = 0;
   cls.result_count = 0;
@@ -374,7 +374,7 @@
   /* if not found or not unique, forward */
   if (((ret != 1) || (type != GNUNET_ECRS_BLOCKTYPE_DATA)) &&
       (0 != (policy & GNUNET_FS_RoutingPolicy_FORWARD)) &&
-      (rl->plan_entries == NULL) )
+      (rl->plan_entries == NULL))
     GNUNET_FS_PLAN_request (NULL, peer, rl);
   GNUNET_mutex_unlock (GNUNET_FS_lock);
 }

Modified: GNUnet/src/applications/fs/gap/ondemand.c
===================================================================
--- GNUnet/src/applications/fs/gap/ondemand.c   2008-02-20 00:09:30 UTC (rev 
6386)
+++ GNUnet/src/applications/fs/gap/ondemand.c   2008-02-20 03:41:55 UTC (rev 
6387)
@@ -472,7 +472,7 @@
   char *fn;
 
   fn = get_indexed_filename (fileId);
-  if (0 != STAT(fn, &filestat))
+  if (0 != STAT (fn, &filestat))
     {
       GNUNET_free (fn);
       return GNUNET_NO;

Modified: GNUnet/src/applications/fs/tools/gnunet-auto-share.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-auto-share.c        2008-02-20 
00:09:30 UTC (rev 6386)
+++ GNUnet/src/applications/fs/tools/gnunet-auto-share.c        2008-02-20 
03:41:55 UTC (rev 6387)
@@ -92,7 +92,7 @@
           fprintf (myout,
                    _("Upload of `%s' complete, URI is `%s'.\n"),
                    event->data.UploadCompleted.filename, fstring);
-         fflush(myout);
+          fflush (myout);
           GNUNET_free (fstring);
         }
       if (ul == event->data.UploadCompleted.uc.pos)
@@ -100,24 +100,24 @@
       break;
     case GNUNET_FSUI_upload_aborted:
       fprintf (myout, _("\nUpload aborted.\n"));
-      fflush(myout);
+      fflush (myout);
       upload_done = GNUNET_YES;
       break;
     case GNUNET_FSUI_upload_error:
       fprintf (myout,
                _("\nError uploading file: %s"),
                event->data.UploadError.message);
-      fflush(myout);     
+      fflush (myout);
       upload_done = GNUNET_YES;
       break;
     case GNUNET_FSUI_upload_started:
     case GNUNET_FSUI_upload_stopped:
-    case GNUNET_FSUI_upload_suspended:      
+    case GNUNET_FSUI_upload_suspended:
     case GNUNET_FSUI_upload_resumed:
       break;
     default:
       fprintf (myout, _("\nUnexpected event: %d\n"), event->type);
-      fflush(myout);     
+      fflush (myout);
       GNUNET_GE_BREAK (ectx, 0);
       break;
     }
@@ -184,7 +184,7 @@
   if (0 != stat (fn, &buf))
     {
       fprintf (myout, "Could not stat `%s': %s\n", fn, strerror (errno));
-      fflush(myout);
+      fflush (myout);
       GNUNET_free (fn);
       return GNUNET_OK;
     }
@@ -288,7 +288,7 @@
   if (0 != stat (fn, &buf))
     {
       fprintf (myout, "Could not stat `%s': %s\n", fn, strerror (errno));
-      fflush(myout);
+      fflush (myout);
       GNUNET_free (fn);
       return GNUNET_OK;
     }
@@ -351,12 +351,12 @@
   errorCode = 0;
   if ((GNUNET_NO == debug_flag)
       && (GNUNET_OK != GNUNET_terminal_detach (ectx, cfg, filedes)))
-      return GNUNET_SYSERR;
+    return GNUNET_SYSERR;
   sock = GNUNET_client_connection_create (ectx, cfg);
   if (sock == NULL)
     {
       fprintf (myout, _("Failed to connect to gnunetd.\n"));
-      fflush(myout);
+      fflush (myout);
       errorCode = -1;
       if (GNUNET_NO == debug_flag)
         GNUNET_terminal_detach_complete (ectx, filedes, GNUNET_NO);
@@ -481,15 +481,14 @@
                                                   &log_file_name);
       myout = fopen (log_file_name, "a");
       if (myout == NULL)
-       {
-         fprintf(stderr,
-                 "Could not open logfile `%s': %s\n",
-                 log_file_name,
-                 strerror(errno));
-         GNUNET_free (log_file_name);
-         errorCode = -1;
-         goto end;
-       }
+        {
+          fprintf (stderr,
+                   "Could not open logfile `%s': %s\n",
+                   log_file_name, strerror (errno));
+          GNUNET_free (log_file_name);
+          errorCode = -1;
+          goto end;
+        }
       GNUNET_free (log_file_name);
 
       GNUNET_GC_get_configuration_value_filename (cfg,
@@ -497,14 +496,14 @@
                                                   "GNUNET_HOME",
                                                   
GNUNET_DEFAULT_HOME_DIRECTORY,
                                                   &log_file_name);
-      log_file_name = GNUNET_realloc(log_file_name, strlen(log_file_name) + 
30);
-      strcat(log_file_name, "gnunet-auto-share.pid");
-      GNUNET_GC_set_configuration_value_string(cfg,
-                                              NULL,
-                                              "GNUNETD",
-                                              "PIDFILE",
-                                              log_file_name);
-      GNUNET_free (log_file_name);         
+      log_file_name =
+        GNUNET_realloc (log_file_name, strlen (log_file_name) + 30);
+      strcat (log_file_name, "gnunet-auto-share.pid");
+      GNUNET_GC_set_configuration_value_string (cfg,
+                                                NULL,
+                                                "GNUNETD",
+                                                "PIDFILE", log_file_name);
+      GNUNET_free (log_file_name);
     }
 #ifdef MINGW
   if (GNUNET_GC_get_configuration_value_yesno (cfg,
@@ -523,12 +522,12 @@
     {
       dirname = GNUNET_expand_file_name (ectx, argv[i]);
       errorCode = auto_share_main (dirname);
-      GNUNET_free(dirname);
+      GNUNET_free (dirname);
     }
 end:
   GNUNET_fini (ectx, cfg);
   if (myout != stdout)
-    fclose(myout);
+    fclose (myout);
   return errorCode;
 }
 

Modified: GNUnet/src/applications/fs/tools/gnunet-insert.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-insert.c    2008-02-20 00:09:30 UTC 
(rev 6386)
+++ GNUnet/src/applications/fs/tools/gnunet-insert.c    2008-02-20 03:41:55 UTC 
(rev 6387)
@@ -325,7 +325,7 @@
    1, &GNUNET_getopt_configure_set_string, &pseudonym},
   {'s', "simulate-only", NULL,
    gettext_noop ("only simulte the process but do not do any "
-                "actual publishing (useful to compute URIs)"),
+                 "actual publishing (useful to compute URIs)"),
    0, &GNUNET_getopt_configure_set_one, &do_simulate},
   {'S', "sporadic", NULL,
    gettext_noop ("specifies this as an aperiodic but updated publication"
@@ -341,7 +341,7 @@
    1, &GNUNET_getopt_configure_set_string, &creation_time},
   {'u', "uri", "URI",
    gettext_noop ("URI to be published (can be used instead of passing a "
-                "file to add keywords to the file with the respective URI)"),
+                 "file to add keywords to the file with the respective URI)"),
    1, &GNUNET_getopt_configure_set_string, &uri_string},
   {'U', "update", "ID",
    gettext_noop ("ID of the previous version of the content"
@@ -377,28 +377,22 @@
       errorCode = -1;
       goto quit;
     }
-  if ( ( (uri_string == NULL) ||
-        (extract_only) ) &&
-       (i != argc - 1) )      
+  if (((uri_string == NULL) || (extract_only)) && (i != argc - 1))
     {
       printf (_
               ("You must specify one and only one filename for insertion.\n"));
       errorCode = -1;
       goto quit;
     }
-  if ( (uri_string != NULL) &&
-       (i != argc) )      
+  if ((uri_string != NULL) && (i != argc))
     {
-      printf (_
-              ("You must NOT specify an URI and a filename.\n"));
+      printf (_("You must NOT specify an URI and a filename.\n"));
       errorCode = -1;
       goto quit;
     }
-  if ( (uri_string != NULL) &&
-       (extract_only) )      
+  if ((uri_string != NULL) && (extract_only))
     {
-      printf (_
-              ("Cannot extract metadata from a URI!\n"));
+      printf (_("Cannot extract metadata from a URI!\n"));
       errorCode = -1;
       goto quit;
     }
@@ -520,33 +514,31 @@
 
   if (uri_string != NULL)
     {
-      struct GNUNET_ECRS_URI * us 
-       = GNUNET_ECRS_string_to_uri(ectx, uri_string);
+      struct GNUNET_ECRS_URI *us
+        = GNUNET_ECRS_string_to_uri (ectx, uri_string);
       if (us == NULL)
-       {
-         errorCode = -1;
-         goto quit;
-       }
-      postProcess(us);
+        {
+          errorCode = -1;
+          goto quit;
+        }
+      postProcess (us);
       if (gloKeywords != NULL)
-       GNUNET_ECRS_publish_under_keyword(ectx,
-                                         cfg,
-                                         gloKeywords, 
-                                         anonymity,
-                                         priority,
-                                         start_time + 2 * GNUNET_CRON_YEARS,
-                                         us,
-                                         meta);
+        GNUNET_ECRS_publish_under_keyword (ectx,
+                                           cfg,
+                                           gloKeywords,
+                                           anonymity,
+                                           priority,
+                                           start_time + 2 * GNUNET_CRON_YEARS,
+                                           us, meta);
       if (topKeywords != NULL)
-       GNUNET_ECRS_publish_under_keyword(ectx,
-                                         cfg,
-                                         topKeywords, 
-                                         anonymity,
-                                         priority,
-                                         start_time + 2 * GNUNET_CRON_YEARS,
-                                         us,
-                                         meta);
-      GNUNET_ECRS_uri_destroy(us);
+        GNUNET_ECRS_publish_under_keyword (ectx,
+                                           cfg,
+                                           topKeywords,
+                                           anonymity,
+                                           priority,
+                                           start_time + 2 * GNUNET_CRON_YEARS,
+                                           us, meta);
+      GNUNET_ECRS_uri_destroy (us);
       goto quit;
     }
 
@@ -554,26 +546,27 @@
   ctx = GNUNET_FSUI_start (ectx, cfg, "gnunet-insert", GNUNET_NO, 32,   /* 
make configurable */
                            &printstatus, &verbose);
 
-  /* first insert all of the top-level files or directories */  
+  /* first insert all of the top-level files or directories */
   tmp = GNUNET_expand_file_name (ectx, filename);
   if (!do_disable_creation_time)
     GNUNET_ECRS_meta_data_add_publication_date (meta);
   start_time = GNUNET_get_time ();
   errorCode = 1;
   ul = GNUNET_FSUI_upload_start (ctx,
-                                tmp,
-                                (GNUNET_FSUI_DirectoryScanCallback) &
-                                GNUNET_disk_directory_scan, ectx, anonymity,
-                                priority, do_simulate? GNUNET_SYSERR : 
(!do_insert), GNUNET_YES,
-                                !do_no_direct_references,
-                                start_time + 2 * GNUNET_CRON_YEARS, meta,
-                                gloKeywords, topKeywords);
+                                 tmp,
+                                 (GNUNET_FSUI_DirectoryScanCallback) &
+                                 GNUNET_disk_directory_scan, ectx, anonymity,
+                                 priority,
+                                 do_simulate ? GNUNET_SYSERR : (!do_insert),
+                                 GNUNET_YES, !do_no_direct_references,
+                                 start_time + 2 * GNUNET_CRON_YEARS, meta,
+                                 gloKeywords, topKeywords);
   GNUNET_free (tmp);
   if (ul != NULL)
     {
       GNUNET_shutdown_wait_for ();
       if (errorCode == 1)
-       GNUNET_FSUI_upload_abort (ctx, ul);
+        GNUNET_FSUI_upload_abort (ctx, ul);
       GNUNET_FSUI_upload_stop (ctx, ul);
     }
   GNUNET_FSUI_stop (ctx);

Modified: GNUnet/src/applications/hostlist/hostlist.c
===================================================================
--- GNUnet/src/applications/hostlist/hostlist.c 2008-02-20 00:09:30 UTC (rev 
6386)
+++ GNUnet/src/applications/hostlist/hostlist.c 2008-02-20 03:41:55 UTC (rev 
6387)
@@ -99,7 +99,7 @@
   static int dummy;
   struct MHD_Response *response;
   struct HostSet results;
-  const char * protos;
+  const char *protos;
   int ret;
 
   if (0 != strcmp (method, MHD_HTTP_METHOD_GET))
@@ -112,16 +112,12 @@
   if (*upload_data_size != 0)
     return MHD_NO;              /* do not support upload data */
   memset (&results, 0, sizeof (struct HostSet));
-  protos = MHD_lookup_connection_value(connection,
-                                      MHD_GET_ARGUMENT_KIND,
-                                      "p");  
-  if ( (protos == NULL) ||
-       (1 != sscanf(protos, "%llu", &results.protocols)) )
+  protos = MHD_lookup_connection_value (connection,
+                                        MHD_GET_ARGUMENT_KIND, "p");
+  if ((protos == NULL) || (1 != sscanf (protos, "%llu", &results.protocols)))
     results.protocols = -1;
-  host_processor(coreAPI->myIdentity,
-                GNUNET_TRANSPORT_PROTOCOL_NUMBER_ANY,
-                GNUNET_YES,
-                &results);
+  host_processor (coreAPI->myIdentity,
+                  GNUNET_TRANSPORT_PROTOCOL_NUMBER_ANY, GNUNET_YES, &results);
   identity->forEachHost (GNUNET_get_time (), &host_processor, &results);
   if (results.size == 0)
     return MHD_NO;              /* no known hosts!? */
@@ -130,7 +126,7 @@
   ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
   MHD_destroy_response (response);
   if (stats != NULL)
-    stats->change(stat_request_count, 1);
+    stats->change (stat_request_count, 1);
   return ret;
 }
 

Modified: GNUnet/src/applications/hostlist/hostlisttest.c
===================================================================
--- GNUnet/src/applications/hostlist/hostlisttest.c     2008-02-20 00:09:30 UTC 
(rev 6386)
+++ GNUnet/src/applications/hostlist/hostlisttest.c     2008-02-20 03:41:55 UTC 
(rev 6387)
@@ -67,12 +67,12 @@
       return -1;
     }
 #if START_PEERS
-  GNUNET_disk_directory_remove(NULL, "/tmp/gnunet-hostlist-test-server");
-  GNUNET_disk_directory_remove(NULL, "/tmp/gnunet-hostlist-test-client");
+  GNUNET_disk_directory_remove (NULL, "/tmp/gnunet-hostlist-test-server");
+  GNUNET_disk_directory_remove (NULL, "/tmp/gnunet-hostlist-test-client");
   peer1 = GNUNET_daemon_start (NULL, cfg, "tcp-peer.conf", GNUNET_NO);
   if (peer1 == -1)
     {
-      GNUNET_GC_free (cfg);  
+      GNUNET_GC_free (cfg);
       return -1;
     }
   peer2 = GNUNET_daemon_start (NULL, cfg, "nat-peer.conf", GNUNET_NO);
@@ -86,11 +86,11 @@
   if (GNUNET_OK ==
       GNUNET_wait_for_daemon_running (NULL, cfg, 30 * GNUNET_CRON_SECONDS))
     {
-      GNUNET_thread_sleep(GNUNET_CRON_SECONDS); /* give stats time to load!*/
+      GNUNET_thread_sleep (GNUNET_CRON_SECONDS);        /* give stats time to 
load! */
       sock1 = GNUNET_client_connection_create (NULL, cfg);
       left = 30;                /* how many iterations should we wait? */
       while (GNUNET_OK ==
-            GNUNET_STATS_get_statistics (NULL, sock1, &waitForConnect, NULL))
+             GNUNET_STATS_get_statistics (NULL, sock1, &waitForConnect, NULL))
         {
           printf ("Waiting for peers to connect (%u iterations left)...\n",
                   left);
@@ -103,7 +103,7 @@
             }
         }
       GNUNET_client_connection_destroy (sock1);
-     }
+    }
   else
     {
       printf ("Could not establish connection with peer.\n");

Modified: GNUnet/src/applications/sqstore_mysql/mysql.c
===================================================================
--- GNUnet/src/applications/sqstore_mysql/mysql.c       2008-02-20 00:09:30 UTC 
(rev 6386)
+++ GNUnet/src/applications/sqstore_mysql/mysql.c       2008-02-20 03:41:55 UTC 
(rev 6387)
@@ -111,7 +111,7 @@
  * - The tables can be verified/fixed in two ways;
  *   1) by running mysqlcheck -A, or
  *   2) by executing (inside of mysql using the GNUnet database):
- *   mysql> REPAIR TABLE gn071;
+ *   mysql> REPAIR TABLE gn080;
  *   mysql> REPAIR TABLE gn072;
  *
  * PROBLEMS?
@@ -190,43 +190,55 @@
 #define INSERT_VALUE "INSERT INTO gn072 (value) VALUES (?)"
   MYSQL_STMT *insert_value;
 
-  /* stuff dealing with gn071 table */
-#define INSERT_ENTRY "INSERT INTO gn071 
(size,type,prio,anonLevel,expire,hash,vkey) VALUES (?,?,?,?,?,?,?)"
+  /* stuff dealing with gn080 table */
+#define INSERT_ENTRY "INSERT INTO gn080 
(size,type,prio,anonLevel,expire,hash,vhash,vkey) VALUES (?,?,?,?,?,?,?,?)"
   MYSQL_STMT *insert_entry;
 
-#define DELETE_ENTRY_BY_VKEY "DELETE FROM gn071 WHERE vkey=?"
+#define DELETE_ENTRY_BY_VKEY "DELETE FROM gn080 WHERE vkey=?"
   MYSQL_STMT *delete_entry_by_vkey;
 
-#define SELECT_ENTRY_BY_HASH "SELECT * FROM gn071 WHERE hash=? AND vkey > ? 
ORDER BY vkey ASC LIMIT 1 OFFSET ?"
+#define SELECT_ENTRY_BY_HASH "SELECT size,type,prio,anonLevel,expire,hash,vkey 
FROM gn080 WHERE hash=? AND vkey > ? ORDER BY vkey ASC LIMIT 1 OFFSET ?"
   MYSQL_STMT *select_entry_by_hash;
 
-#define SELECT_ENTRY_BY_HASH_AND_TYPE "SELECT * FROM gn071 WHERE hash=? AND 
vkey > ? AND type=? ORDER BY vkey ASC LIMIT 1 OFFSET ?"
+#define SELECT_ENTRY_BY_HASH_AND_VHASH "SELECT 
size,type,prio,anonLevel,expire,hash,vkey FROM gn080 WHERE hash=? AND vhash=? 
AND vkey > ? ORDER BY vkey ASC LIMIT 1 OFFSET ?"
+  MYSQL_STMT *select_entry_by_hash_and_vhash;
+
+#define SELECT_ENTRY_BY_HASH_AND_TYPE "SELECT 
size,type,prio,anonLevel,expire,hash,vkey FROM gn080 WHERE hash=? AND vkey > ? 
AND type=? ORDER BY vkey ASC LIMIT 1 OFFSET ?"
   MYSQL_STMT *select_entry_by_hash_and_type;
 
-#define COUNT_ENTRY_BY_HASH "SELECT count(*) FROM gn071 WHERE hash=?"
+#define SELECT_ENTRY_BY_HASH_VHASH_AND_TYPE "SELECT 
size,type,prio,anonLevel,expire,hash,vkey FROM gn080 WHERE hash=? AND vhash=? 
AND vkey > ? AND type=? ORDER BY vkey ASC LIMIT 1 OFFSET ?"
+  MYSQL_STMT *select_entry_by_hash_vhash_and_type;
+
+#define COUNT_ENTRY_BY_HASH "SELECT count(*) FROM gn080 WHERE hash=?"
   MYSQL_STMT *count_entry_by_hash;
 
-#define COUNT_ENTRY_BY_HASH_AND_TYPE "SELECT count(*) FROM gn071 WHERE hash=? 
AND type=?"
+#define COUNT_ENTRY_BY_HASH_AND_VHASH "SELECT count(*) FROM gn080 WHERE hash=? 
AND vhash=?"
+  MYSQL_STMT *count_entry_by_hash_and_vhash;
+
+#define COUNT_ENTRY_BY_HASH_AND_TYPE "SELECT count(*) FROM gn080 WHERE hash=? 
AND type=?"
   MYSQL_STMT *count_entry_by_hash_and_type;
 
-#define UPDATE_ENTRY "UPDATE gn071 SET 
prio=prio+?,expire=IF(expire>=?,expire,?) WHERE vkey=?"
+#define COUNT_ENTRY_BY_HASH_VHASH_AND_TYPE "SELECT count(*) FROM gn080 WHERE 
hash=? AND vhash=? AND type=?"
+  MYSQL_STMT *count_entry_by_hash_vhash_and_type;
+
+#define UPDATE_ENTRY "UPDATE gn080 SET 
prio=prio+?,expire=IF(expire>=?,expire,?) WHERE vkey=?"
   MYSQL_STMT *update_entry;
 
 
 #if 0
   /* old, easier to read statments -- do not use,
      C code no longer works with these! */
-#define SELECT_IT_LOW_PRIORITY "SELECT * FROM gn071 WHERE ( (prio = ? AND vkey 
> ?) OR (prio > ? AND vkey != ?) )"\
+#define SELECT_IT_LOW_PRIORITY "SELECT 
size,type,prio,anonLevel,expire,hash,vkey FROM gn080 WHERE ( (prio = ? AND vkey 
> ?) OR (prio > ? AND vkey != ?) )"\
                                "ORDER BY prio ASC,vkey ASC LIMIT 1"
 
-#define SELECT_IT_NON_ANONYMOUS "SELECT * FROM gn071 WHERE ( (prio = ? AND 
vkey < ?) OR (prio < ? AND vkey != ?) ) "\
+#define SELECT_IT_NON_ANONYMOUS "SELECT 
size,type,prio,anonLevel,expire,hash,vkey FROM gn080 WHERE ( (prio = ? AND vkey 
< ?) OR (prio < ? AND vkey != ?) ) "\
                                 "AND anonLevel=0 AND type != 0xFFFFFFFF "\
                                 "ORDER BY prio DESC,vkey DESC LIMIT 1"
 
-#define SELECT_IT_EXPIRATION_TIME "SELECT * FROM gn071 WHERE ( (expire = ? AND 
vkey > ?) OR (expire > ? AND vkey != ?) ) "\
+#define SELECT_IT_EXPIRATION_TIME "SELECT 
size,type,prio,anonLevel,expire,hash,vkey FROM gn080 WHERE ( (expire = ? AND 
vkey > ?) OR (expire > ? AND vkey != ?) ) "\
                                   "ORDER BY expire ASC,vkey ASC LIMIT 1"
 
-#define SELECT_IT_MIGRATION_ORDER "SELECT * FROM gn071 WHERE ( (expire = ? AND 
vkey < ?) OR (expire < ? AND vkey != ?) ) "\
+#define SELECT_IT_MIGRATION_ORDER "SELECT 
size,type,prio,anonLevel,expire,hash,vkey FROM gn080 WHERE ( (expire = ? AND 
vkey < ?) OR (expire < ? AND vkey != ?) ) "\
                                   "AND expire > ? AND type!=3 "\
                                   "ORDER BY expire DESC,vkey DESC LIMIT 1"
 
@@ -237,33 +249,33 @@
    automatically apply a LIMIT on the outermost clause, so we need to
    repeat ourselves quite a bit.  All hail the performance gods (and thanks
    to #mysql on freenode) */
-#define SELECT_IT_LOW_PRIORITY "(SELECT * FROM gn071 FORCE INDEX(prio) WHERE 
(prio = ? AND vkey > ?) "\
+#define SELECT_IT_LOW_PRIORITY "(SELECT 
size,type,prio,anonLevel,expire,hash,vkey FROM gn080 FORCE INDEX(prio) WHERE 
(prio = ? AND vkey > ?) "\
                                "ORDER BY prio ASC,vkey ASC LIMIT 1) "\
                                "UNION "\
-                               "(SELECT * FROM gn071 FORCE INDEX(prio) WHERE 
(prio > ? AND vkey != ?)"\
+                               "(SELECT 
size,type,prio,anonLevel,expire,hash,vkey FROM gn080 FORCE INDEX(prio) WHERE 
(prio > ? AND vkey != ?)"\
                                "ORDER BY prio ASC,vkey ASC LIMIT 1)"\
                                "ORDER BY prio ASC,vkey ASC LIMIT 1"
 
-#define SELECT_IT_NON_ANONYMOUS "(SELECT * FROM gn071 FORCE INDEX(prio) WHERE 
(prio = ? AND vkey < ?)"\
+#define SELECT_IT_NON_ANONYMOUS "(SELECT 
size,type,prio,anonLevel,expire,hash,vkey FROM gn080 FORCE INDEX(prio) WHERE 
(prio = ? AND vkey < ?)"\
                                 " AND anonLevel=0 AND type != 0xFFFFFFFF ORDER 
BY prio DESC,vkey DESC LIMIT 1) "\
                                 "UNION "\
-                                "(SELECT * FROM gn071 FORCE INDEX(prio) WHERE 
(prio < ? AND vkey != ?)"\
+                                "(SELECT 
size,type,prio,anonLevel,expire,hash,vkey FROM gn080 FORCE INDEX(prio) WHERE 
(prio < ? AND vkey != ?)"\
                                 " AND anonLevel=0 AND type != 0xFFFFFFFF ORDER 
BY prio DESC,vkey DESC LIMIT 1) "\
                                 "ORDER BY prio DESC,vkey DESC LIMIT 1"
 
-#define SELECT_IT_EXPIRATION_TIME "(SELECT * FROM gn071 FORCE INDEX(expire) 
WHERE (expire = ? AND vkey > ?) "\
+#define SELECT_IT_EXPIRATION_TIME "(SELECT 
size,type,prio,anonLevel,expire,hash,vkey FROM gn080 FORCE INDEX(expire) WHERE 
(expire = ? AND vkey > ?) "\
                                   "ORDER BY expire ASC,vkey ASC LIMIT 1) "\
                                   "UNION "\
-                                  "(SELECT * FROM gn071 FORCE INDEX(expire) 
WHERE (expire > ? AND vkey != ?) "\
+                                  "(SELECT 
size,type,prio,anonLevel,expire,hash,vkey FROM gn080 FORCE INDEX(expire) WHERE 
(expire > ? AND vkey != ?) "\
                                   "ORDER BY expire ASC,vkey ASC LIMIT 1)"\
                                   "ORDER BY expire ASC,vkey ASC LIMIT 1"
 
 
-#define SELECT_IT_MIGRATION_ORDER "(SELECT * FROM gn071 FORCE INDEX(expire) 
WHERE (expire = ? AND vkey < ?)"\
+#define SELECT_IT_MIGRATION_ORDER "(SELECT 
size,type,prio,anonLevel,expire,hash,vkey FROM gn080 FORCE INDEX(expire) WHERE 
(expire = ? AND vkey < ?)"\
                                   " AND expire > ? AND type!=3"\
                                   " ORDER BY expire DESC,vkey DESC LIMIT 1) "\
                                   "UNION "\
-                                  "(SELECT * FROM gn071 FORCE INDEX(expire) 
WHERE (expire < ? AND vkey != ?)"\
+                                  "(SELECT 
size,type,prio,anonLevel,expire,hash,vkey FROM gn080 FORCE INDEX(expire) WHERE 
(expire < ? AND vkey != ?)"\
                                   " AND expire > ? AND type!=3"\
                                   " ORDER BY expire DESC,vkey DESC LIMIT 1)"\
                                   "ORDER BY expire DESC,vkey DESC LIMIT 1"
@@ -272,7 +284,7 @@
 } mysqlHandle;
 
 
-#define SELECT_SIZE "SELECT sum(size) FROM gn071"
+#define SELECT_SIZE "SELECT sum(size) FROM gn080"
 
 static mysqlHandle *dbh;
 
@@ -362,13 +374,14 @@
     {
       /* MySQL 5.0.46 fixes bug in MyISAM */
       mysql_query (dbh->dbf,
-                   "CREATE TABLE IF NOT EXISTS gn071 ("
+                   "CREATE TABLE IF NOT EXISTS gn080 ("
                    " size INT(11) UNSIGNED NOT NULL DEFAULT 0,"
                    " type INT(11) UNSIGNED NOT NULL DEFAULT 0,"
                    " prio INT(11) UNSIGNED NOT NULL DEFAULT 0,"
                    " anonLevel INT(11) UNSIGNED NOT NULL DEFAULT 0,"
                    " expire BIGINT UNSIGNED NOT NULL DEFAULT 0,"
                    " hash BINARY(64) NOT NULL DEFAULT '',"
+                   " vhash BINARY(64) NOT NULL DEFAULT '',"
                    " vkey BIGINT UNSIGNED NOT NULL DEFAULT 0,"
                    " INDEX hash (hash(64)),"
                    " INDEX vkey (vkey),"
@@ -380,13 +393,14 @@
   else
     {
       mysql_query (dbh->dbf,
-                   "CREATE TABLE IF NOT EXISTS gn071 ("
+                   "CREATE TABLE IF NOT EXISTS gn080 ("
                    " size INT(11) UNSIGNED NOT NULL DEFAULT 0,"
                    " type INT(11) UNSIGNED NOT NULL DEFAULT 0,"
                    " prio INT(11) UNSIGNED NOT NULL DEFAULT 0,"
                    " anonLevel INT(11) UNSIGNED NOT NULL DEFAULT 0,"
                    " expire BIGINT UNSIGNED NOT NULL DEFAULT 0,"
                    " hash BINARY(64) NOT NULL DEFAULT '',"
+                   " vhash BINARY(64) NOT NULL DEFAULT '',"
                    " vkey BIGINT UNSIGNED NOT NULL DEFAULT 0,"
                    " INDEX hash (hash(64)),"
                    " INDEX vkey (vkey),"
@@ -547,7 +561,7 @@
 }
 
 /**
- * Delete an entry from the gn071 table.
+ * Delete an entry from the gn080 table.
  *
  * @param vkey vkey identifying the entry to delete
  * @return GNUNET_OK on success, GNUNET_NO if no such value exists, 
GNUNET_SYSERR on error
@@ -595,7 +609,7 @@
 }
 
 /**
- * Given a full (SELECT *) result set from gn071 table,
+ * Given a full (SELECT *) result set from gn080 table,
  * assemble it into a GNUNET_DatastoreValue representation.
  *
  * Call *without* holding the lock, but while within
@@ -744,13 +758,15 @@
 {
   unsigned long contentSize;
   unsigned long hashSize;
+  unsigned long hashSize2;
   unsigned int size;
   unsigned int type;
   unsigned int prio;
   unsigned int level;
   unsigned long long expiration;
   unsigned long long vkey;
-  MYSQL_BIND qbind[7];
+  GNUNET_HashCode vhash;
+  MYSQL_BIND qbind[8];
 #if DEBUG_MYSQL
   GNUNET_EncName enc;
 #endif
@@ -762,6 +778,15 @@
       GNUNET_GE_BREAK (ectx, 0);
       return GNUNET_SYSERR;
     }
+  hashSize = sizeof (GNUNET_HashCode);
+  hashSize2 = sizeof (GNUNET_HashCode);
+  size = ntohl (value->size);
+  type = ntohl (value->type);
+  prio = ntohl (value->prio);
+  level = ntohl (value->anonymityLevel);
+  expiration = GNUNET_ntohll (value->expirationTime);
+  contentSize = ntohl (value->size) - sizeof (GNUNET_DatastoreValue);
+  GNUNET_hash (&value[1], contentSize, &vhash);
   GNUNET_mutex_lock (lock);
   mysql_thread_init ();
   if (GNUNET_OK != CHECK_DBH)
@@ -770,19 +795,12 @@
       GNUNET_mutex_unlock (lock);
       return GNUNET_SYSERR;
     }
-  contentSize = ntohl (value->size) - sizeof (GNUNET_DatastoreValue);
   if (GNUNET_OK != insert_value (&value[1], contentSize, &vkey))
     {
       mysql_thread_end ();
       GNUNET_mutex_unlock (lock);
       return GNUNET_SYSERR;
     }
-  hashSize = sizeof (GNUNET_HashCode);
-  size = ntohl (value->size);
-  type = ntohl (value->type);
-  prio = ntohl (value->prio);
-  level = ntohl (value->anonymityLevel);
-  expiration = GNUNET_ntohll (value->expirationTime);
 #if DEBUG_MYSQL
   IF_GELOG (ectx, GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_USER,
             GNUNET_hash_to_enc (key, &enc));
@@ -790,7 +808,7 @@
                  "Storing in database block with type %u and key %s.\n", type,
                  &enc);
 #endif
-  GNUNET_GE_ASSERT (ectx, mysql_stmt_param_count (dbh->insert_entry) == 7);
+  GNUNET_GE_ASSERT (ectx, mysql_stmt_param_count (dbh->insert_entry) == 8);
   memset (qbind, 0, sizeof (qbind));
   qbind[0].buffer_type = MYSQL_TYPE_LONG;       /* size */
   qbind[0].buffer = &size;
@@ -811,9 +829,13 @@
   qbind[5].buffer = (void *) key;
   qbind[5].length = &hashSize;
   qbind[5].buffer_length = hashSize;
-  qbind[6].buffer_type = MYSQL_TYPE_LONGLONG;   /* vkey */
-  qbind[6].is_unsigned = 1;
-  qbind[6].buffer = &vkey;
+  qbind[6].buffer_type = MYSQL_TYPE_BLOB;       /* vhash */
+  qbind[6].buffer = (void *) &vhash;
+  qbind[6].length = &hashSize2;
+  qbind[6].buffer_length = hashSize2;
+  qbind[7].buffer_type = MYSQL_TYPE_LONGLONG;   /* vkey */
+  qbind[7].is_unsigned = 1;
+  qbind[7].buffer = &vkey;
 
   if (mysql_stmt_bind_param (dbh->insert_entry, qbind))
     {
@@ -1149,6 +1171,7 @@
  * the responses if iterators process only a subset.
  *
  * @param key maybe NULL (to match all entries)
+ * @param vhash hash of the value; maybe NULL
  * @param type entries of which type are relevant?
  *     Use 0 for any type.
  * @param iter maybe NULL (to just count); iter
@@ -1160,6 +1183,7 @@
  */
 static int
 get (const GNUNET_HashCode * query,
+     const GNUNET_HashCode * vhash,
      unsigned int type, GNUNET_DatastoreValueIterator iter, void *closure)
 {
   int count;
@@ -1178,11 +1202,13 @@
   GNUNET_DatastoreValue *datum;
   GNUNET_HashCode key;
   unsigned long hashSize;
-  MYSQL_BIND qbind[4];
+  unsigned long hashSize2;
+  MYSQL_BIND qbind[5];
   MYSQL_BIND rbind[7];
 #if DEBUG_MYSQL
   GNUNET_EncName enc;
 #endif
+  int sqoff;
 
   if (query == NULL)
     return iterateLowPriority (type, iter, closure);
@@ -1195,26 +1221,45 @@
 #endif
 
   hashSize = sizeof (GNUNET_HashCode);
+  hashSize2 = sizeof (GNUNET_HashCode);
   memset (qbind, 0, sizeof (qbind));
   qbind[0].buffer_type = MYSQL_TYPE_BLOB;
   qbind[0].buffer = (void *) query;
   qbind[0].length = &hashSize;
   qbind[0].buffer_length = hashSize;
-  qbind[1].buffer_type = MYSQL_TYPE_LONG;
-  qbind[1].is_unsigned = GNUNET_YES;
-  qbind[1].buffer = &type;
+  sqoff = 1;
+  if (vhash != NULL)
+    {
+      qbind[sqoff].buffer_type = MYSQL_TYPE_BLOB;
+      qbind[sqoff].buffer = (void *) &vhash;
+      qbind[sqoff].length = &hashSize2;
+      qbind[sqoff].buffer_length = hashSize2;
+      sqoff++;
+    }
+  if (type != 0)
+    {
+      qbind[sqoff].buffer_type = MYSQL_TYPE_LONG;
+      qbind[sqoff].is_unsigned = GNUNET_YES;
+      qbind[sqoff].buffer = &type;
+      sqoff++;
+    }
   memset (rbind, 0, sizeof (rbind));
   rbind[0].buffer_type = MYSQL_TYPE_LONGLONG;
   rbind[0].buffer = &total;
   rbind[0].is_unsigned = GNUNET_YES;
   /* first, determine total number of results */
   if (type != 0)
-    stmt = dbh->count_entry_by_hash_and_type;
+    stmt =
+      (vhash !=
+       NULL) ? dbh->count_entry_by_hash_vhash_and_type : dbh->
+      count_entry_by_hash_and_type;
   else
-    stmt = dbh->count_entry_by_hash;
+    stmt =
+      (vhash !=
+       NULL) ? dbh->count_entry_by_hash_and_vhash : dbh->count_entry_by_hash;
   mysql_thread_init ();
   GNUNET_mutex_lock (lock);
-  GNUNET_GE_ASSERT (ectx, mysql_stmt_param_count (stmt) <= 2);
+  GNUNET_GE_ASSERT (ectx, mysql_stmt_param_count (stmt) <= 3);
   GNUNET_GE_ASSERT (ectx, mysql_stmt_field_count (stmt) == 1);
   if (mysql_stmt_bind_param (stmt, qbind))
     {
@@ -1287,24 +1332,30 @@
   qbind[0].buffer = (void *) query;
   qbind[0].length = &hashSize;
   qbind[0].buffer_length = hashSize;
-  qbind[1].buffer_type = MYSQL_TYPE_LONGLONG;
-  qbind[1].is_unsigned = GNUNET_YES;
-  qbind[1].buffer = &last_vkey;
-  if (type != 0)
+  sqoff = 1;
+  if (vhash != NULL)
     {
-      qbind[2].buffer_type = MYSQL_TYPE_LONG;
-      qbind[2].is_unsigned = GNUNET_YES;
-      qbind[2].buffer = &type;
-      qbind[3].buffer_type = MYSQL_TYPE_LONG;
-      qbind[3].is_unsigned = GNUNET_YES;
-      qbind[3].buffer = &limit_off;
+      qbind[sqoff].buffer_type = MYSQL_TYPE_BLOB;
+      qbind[sqoff].buffer = (void *) &vhash;
+      qbind[sqoff].length = &hashSize2;
+      qbind[sqoff].buffer_length = hashSize2;
+      sqoff++;
     }
-  else
+  qbind[sqoff].buffer_type = MYSQL_TYPE_LONGLONG;
+  qbind[sqoff].is_unsigned = GNUNET_YES;
+  qbind[sqoff].buffer = &last_vkey;
+  sqoff++;
+  if (type != 0)
     {
-      qbind[2].buffer_type = MYSQL_TYPE_LONG;
-      qbind[2].is_unsigned = GNUNET_YES;
-      qbind[2].buffer = &limit_off;
+      qbind[sqoff].buffer_type = MYSQL_TYPE_LONG;
+      qbind[sqoff].is_unsigned = GNUNET_YES;
+      qbind[sqoff].buffer = &type;
+      sqoff++;
     }
+  qbind[sqoff].buffer_type = MYSQL_TYPE_LONG;
+  qbind[sqoff].is_unsigned = GNUNET_YES;
+  qbind[sqoff].buffer = &limit_off;
+  sqoff++;
   memset (rbind, 0, sizeof (rbind));
   rbind[0].buffer_type = MYSQL_TYPE_LONG;
   rbind[0].buffer = &size;
@@ -1338,14 +1389,20 @@
           return GNUNET_SYSERR;
         }
       if (type != 0)
-        stmt = dbh->select_entry_by_hash_and_type;
+        stmt =
+          (vhash !=
+           NULL) ? dbh->select_entry_by_hash_vhash_and_type : dbh->
+          select_entry_by_hash_and_type;
       else
-        stmt = dbh->select_entry_by_hash;
+        stmt =
+          (vhash !=
+           NULL) ? dbh->select_entry_by_hash_and_vhash : dbh->
+          select_entry_by_hash;
       if (count == 0)
         limit_off = off;
       else
         limit_off = 0;
-      GNUNET_GE_ASSERT (ectx, mysql_stmt_param_count (stmt) <= 4);
+      GNUNET_GE_ASSERT (ectx, mysql_stmt_param_count (stmt) <= 5);
       GNUNET_GE_ASSERT (ectx, mysql_stmt_field_count (stmt) == 7);
       if (mysql_stmt_bind_param (stmt, qbind))
         {
@@ -1528,7 +1585,7 @@
       GNUNET_mutex_unlock (lock);
       return;
     }
-  mysql_query (dbh->dbf, "DROP TABLE gn071");
+  mysql_query (dbh->dbf, "DROP TABLE gn080");
   if (mysql_error (dbh->dbf)[0])
     {
       LOG_MYSQL (GNUNET_GE_ERROR | GNUNET_GE_ADMIN | GNUNET_GE_BULK,
@@ -1776,16 +1833,7 @@
       dbh = NULL;
       return;
     }
-  if ((0 == mysql_query (dbh->dbf,
-                         "ALTER TABLE gn070 ADD COLUMN vkey BIGINT UNSIGNED 
PRIMARY KEY AUTO_INCREMENT"))
-      && (0 ==
-          mysql_query (dbh->dbf,
-                       "INSERT INTO gn071 
(size,type,prio,anonLevel,expire,hash,vkey) (SELECT 
size,type,prio,anonLevel,expire,hash,vkey FROM gn070)"))
-      && (0 ==
-          mysql_query (dbh->dbf,
-                       "INSERT INTO gn072 (vkey,value) (SELECT vkey,value FROM 
gn070)")))
-    mysql_query (dbh->dbf, "DROP TABLE gn070");
-
+  /* run update queries here */
   iclose (dbh);
   GNUNET_free (dbh->cnffile);
   GNUNET_free (dbh);

Modified: GNUnet/src/applications/sqstore_mysql/mysqltest.c
===================================================================
--- GNUnet/src/applications/sqstore_mysql/mysqltest.c   2008-02-20 00:09:30 UTC 
(rev 6386)
+++ GNUnet/src/applications/sqstore_mysql/mysqltest.c   2008-02-20 03:41:55 UTC 
(rev 6387)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2004, 2005, 2006, 2007 Christian Grothoff (and other contributing 
authors)
+     (C) 2004, 2005, 2006, 2007, 2008 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
@@ -175,7 +175,7 @@
   for (i = 255; i >= 0; i--)
     {
       memset (&key, 256 - i, sizeof (GNUNET_HashCode));
-      ASSERT (1 == api->get (&key, i, &checkValue, (void *) &i));
+      ASSERT (1 == api->get (&key, NULL, i, &checkValue, (void *) &i));
     }
 
   oldSize = api->getSize ();
@@ -183,7 +183,7 @@
     {
       memset (&key, 256 - i, sizeof (GNUNET_HashCode));
       value = initValue (i);
-      ASSERT (1 == api->get (&key, 0, &iterateDelete, NULL));
+      ASSERT (1 == api->get (&key, NULL, 0, &iterateDelete, NULL));
       GNUNET_free (value);
     }
   ASSERT (oldSize > api->getSize ());

Modified: GNUnet/src/applications/sqstore_sqlite/sqlite.c
===================================================================
--- GNUnet/src/applications/sqstore_sqlite/sqlite.c     2008-02-20 00:09:30 UTC 
(rev 6386)
+++ GNUnet/src/applications/sqstore_sqlite/sqlite.c     2008-02-20 03:41:55 UTC 
(rev 6387)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 Christian Grothoff (and 
other contributing authors)
+     (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 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
@@ -52,35 +52,35 @@
 #define LOG_SQLITE(db, level, cmd) do { GNUNET_GE_LOG(ectx, level, _("`%s' 
failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, 
sqlite3_errmsg(db->dbh)); } while(0)
 
 #define SELECT_IT_LOW_PRIORITY_1 \
-  "SELECT size,type,prio,anonLevel,expire,hash,value,_ROWID_ FROM gn070 WHERE 
(prio = ? AND hash > ?) "\
+  "SELECT size,type,prio,anonLevel,expire,hash,value,_ROWID_ FROM gn080 WHERE 
(prio = ? AND hash > ?) "\
   "ORDER BY hash ASC LIMIT 1"
 
 #define SELECT_IT_LOW_PRIORITY_2 \
-  "SELECT size,type,prio,anonLevel,expire,hash,value,_ROWID_ FROM gn070 WHERE 
(prio > ?) "\
+  "SELECT size,type,prio,anonLevel,expire,hash,value,_ROWID_ FROM gn080 WHERE 
(prio > ?) "\
   "ORDER BY prio ASC, hash ASC LIMIT 1"
 
 #define SELECT_IT_NON_ANONYMOUS_1 \
-  "SELECT size,type,prio,anonLevel,expire,hash,value,_ROWID_ FROM gn070 WHERE 
(prio = ? AND hash < ? AND anonLevel = 0) "\
+  "SELECT size,type,prio,anonLevel,expire,hash,value,_ROWID_ FROM gn080 WHERE 
(prio = ? AND hash < ? AND anonLevel = 0) "\
   " ORDER BY hash DESC LIMIT 1"
 
 #define SELECT_IT_NON_ANONYMOUS_2 \
-  "SELECT size,type,prio,anonLevel,expire,hash,value,_ROWID_ FROM gn070 WHERE 
(prio < ? AND anonLevel = 0)"\
+  "SELECT size,type,prio,anonLevel,expire,hash,value,_ROWID_ FROM gn080 WHERE 
(prio < ? AND anonLevel = 0)"\
   " ORDER BY prio DESC, hash DESC LIMIT 1"
 
 #define SELECT_IT_EXPIRATION_TIME_1 \
-  "SELECT size,type,prio,anonLevel,expire,hash,value,_ROWID_ FROM gn070 WHERE 
(expire = ? AND hash > ?) "\
+  "SELECT size,type,prio,anonLevel,expire,hash,value,_ROWID_ FROM gn080 WHERE 
(expire = ? AND hash > ?) "\
   " ORDER BY hash ASC LIMIT 1"
 
 #define SELECT_IT_EXPIRATION_TIME_2 \
-  "SELECT size,type,prio,anonLevel,expire,hash,value,_ROWID_ FROM gn070 WHERE 
(expire > ?) "\
+  "SELECT size,type,prio,anonLevel,expire,hash,value,_ROWID_ FROM gn080 WHERE 
(expire > ?) "\
   " ORDER BY expire ASC, hash ASC LIMIT 1"
 
 #define SELECT_IT_MIGRATION_ORDER_1 \
-  "SELECT size,type,prio,anonLevel,expire,hash,value,_ROWID_ FROM gn070 WHERE 
(expire = ? AND hash < ?) "\
+  "SELECT size,type,prio,anonLevel,expire,hash,value,_ROWID_ FROM gn080 WHERE 
(expire = ? AND hash < ?) "\
   " ORDER BY hash DESC LIMIT 1"
 
 #define SELECT_IT_MIGRATION_ORDER_2 \
-  "SELECT size,type,prio,anonLevel,expire,hash,value,_ROWID_ FROM gn070 WHERE 
(expire < ?) "\
+  "SELECT size,type,prio,anonLevel,expire,hash,value,_ROWID_ FROM gn080 WHERE 
(expire < ?) "\
   " ORDER BY expire DESC, hash DESC LIMIT 1"
 
 /**
@@ -114,10 +114,6 @@
   /**
    * Precompiled SQL
    */
-  sqlite3_stmt *exists;
-
-  sqlite3_stmt *countContent;
-
   sqlite3_stmt *updPrio;
 
   sqlite3_stmt *insertContent;
@@ -170,25 +166,20 @@
 {
   /* create indices */
   sqlite3_exec (dbh,
-                "CREATE INDEX idx_hash ON gn070 (hash)", NULL, NULL, ENULL);
+                "CREATE INDEX idx_hash ON gn080 (hash)", NULL, NULL, ENULL);
   sqlite3_exec (dbh,
-                "CREATE INDEX idx_prio ON gn070 (prio)", NULL, NULL, ENULL);
-  sqlite3_exec (dbh,
-                "CREATE INDEX idx_expire ON gn070 (expire)",
+                "CREATE INDEX idx_hash_vhash ON gn080 (hash,vhash)", NULL,
+                NULL, ENULL);
+  sqlite3_exec (dbh, "CREATE INDEX idx_prio ON gn080 (prio)", NULL, NULL,
+                ENULL);
+  sqlite3_exec (dbh, "CREATE INDEX idx_expire ON gn080 (expire)", NULL, NULL,
+                ENULL);
+  sqlite3_exec (dbh, "CREATE INDEX idx_comb3 ON gn080 (prio,anonLevel)", NULL,
+                NULL, ENULL);
+  sqlite3_exec (dbh, "CREATE INDEX idx_comb4 ON gn080 (prio,hash,anonLevel)",
                 NULL, NULL, ENULL);
-  sqlite3_exec (dbh, "DROP INDEX idx_comb1", NULL, NULL, ENULL);
-  sqlite3_exec (dbh, "DROP INDEX idx_comb2", NULL, NULL, ENULL);
-  sqlite3_exec (dbh, "DROP INDEX idx_comb5", NULL, NULL, ENULL);
-  sqlite3_exec (dbh, "DROP INDEX idx_comb6", NULL, NULL, ENULL);
-  sqlite3_exec (dbh,
-                "CREATE INDEX idx_comb3 ON gn070 (prio,anonLevel)",
-                NULL, NULL, ENULL);
-  sqlite3_exec (dbh,
-                "CREATE INDEX idx_comb4 ON gn070 (prio,hash,anonLevel)",
-                NULL, NULL, ENULL);
-  sqlite3_exec (dbh,
-                "CREATE INDEX idx_comb7 ON gn070 (expire,hash)",
-                NULL, NULL, ENULL);
+  sqlite3_exec (dbh, "CREATE INDEX idx_comb7 ON gn080 (expire,hash)", NULL,
+                NULL, ENULL);
 }
 
 /**
@@ -245,18 +236,19 @@
   /* We have to do it here, because otherwise precompiling SQL might fail */
   CHECK (SQLITE_OK ==
          sq_prepare (ret->dbh,
-                     "SELECT 1 FROM sqlite_master WHERE tbl_name = 'gn070'",
+                     "SELECT 1 FROM sqlite_master WHERE tbl_name = 'gn080'",
                      &stmt));
   if (sqlite3_step (stmt) == SQLITE_DONE)
     {
       if (sqlite3_exec (ret->dbh,
-                        "CREATE TABLE gn070 ("
+                        "CREATE TABLE gn080 ("
                         "  size INTEGER NOT NULL DEFAULT 0,"
                         "  type INTEGER NOT NULL DEFAULT 0,"
                         "  prio INTEGER NOT NULL DEFAULT 0,"
                         "  anonLevel INTEGER NOT NULL DEFAULT 0,"
                         "  expire INTEGER NOT NULL DEFAULT 0,"
                         "  hash TEXT NOT NULL DEFAULT '',"
+                        "  vhash TEXT NOT NULL DEFAULT '',"
                         "  value BLOB NOT NULL DEFAULT '')", NULL, NULL,
                         NULL) != SQLITE_OK)
         {
@@ -294,29 +286,18 @@
   sqlite3_finalize (stmt);
 
   if ((sq_prepare (ret->dbh,
-                   "SELECT COUNT(*) FROM gn070 WHERE hash=?",
-                   &ret->countContent) != SQLITE_OK) ||
-      (sq_prepare (ret->dbh,
-                   "SELECT LENGTH(hash), LENGTH(value), size, type, prio, 
anonLevel, expire, _ROWID_ "
-                   "FROM gn070 WHERE hash=?",
-                   &ret->exists) != SQLITE_OK) ||
-      (sq_prepare (ret->dbh,
-                   "UPDATE gn070 SET prio = prio + ?, expire = MAX(expire,?) 
WHERE "
+                   "UPDATE gn080 SET prio = prio + ?, expire = MAX(expire,?) 
WHERE "
                    "_ROWID_ = ?",
                    &ret->updPrio) != SQLITE_OK) ||
       (sq_prepare (ret->dbh,
-                   "INSERT INTO gn070 (size, type, prio, "
-                   "anonLevel, expire, hash, value) VALUES "
-                   "(?, ?, ?, ?, ?, ?, ?)",
+                   "INSERT INTO gn080 (size, type, prio, "
+                   "anonLevel, expire, hash, vhash, value) VALUES "
+                   "(?, ?, ?, ?, ?, ?, ?, ?)",
                    &ret->insertContent) != SQLITE_OK))
     {
       LOG_SQLITE (ret,
                   GNUNET_GE_ERROR | GNUNET_GE_ADMIN | GNUNET_GE_USER |
                   GNUNET_GE_BULK, "precompiling");
-      if (ret->countContent != NULL)
-        sqlite3_finalize (ret->countContent);
-      if (ret->exists != NULL)
-        sqlite3_finalize (ret->exists);
       if (ret->updPrio != NULL)
         sqlite3_finalize (ret->updPrio);
       if (ret->insertContent != NULL)
@@ -363,7 +344,7 @@
 static unsigned int
 getContentDatastoreSize (const GNUNET_DatastoreValue * value)
 {
-  return sizeof (GNUNET_HashCode) + ntohl (value->size) -
+  return sizeof (GNUNET_HashCode) * 2 + ntohl (value->size) -
     sizeof (GNUNET_DatastoreValue) + getIntSize (ntohl (value->size)) +
     getIntSize (ntohl (value->type)) + getIntSize (ntohl (value->prio)) +
     getIntSize (ntohl (value->anonymityLevel)) +
@@ -398,7 +379,7 @@
   sqlite3_stmt *stmt;
 
   if (sq_prepare (handle->dbh,
-                  "DELETE FROM gn070 WHERE _ROWID_ = ?", &stmt) != SQLITE_OK)
+                  "DELETE FROM gn080 WHERE _ROWID_ = ?", &stmt) != SQLITE_OK)
     {
       LOG_SQLITE (handle,
                   GNUNET_GE_ERROR | GNUNET_GE_ADMIN | GNUNET_GE_USER |
@@ -419,7 +400,7 @@
 }
 
 /**
- * Given a full row from gn070 table 
(size,type,prio,anonLevel,expire,GNUNET_hash,value),
+ * Given a full row from gn080 table 
(size,type,prio,anonLevel,expire,GNUNET_hash,value),
  * assemble it into a GNUNET_DatastoreValue representation.
  */
 static GNUNET_DatastoreValue *
@@ -441,13 +422,13 @@
       GNUNET_GE_LOG (ectx,
                      GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER,
                      _
-                     ("Invalid data in %s (NCS).  Trying to fix (by 
deletion).\n"),
+                     ("Invalid data in %s.  Trying to fix (by deletion).\n"),
                      _("sqlite datastore"));
       if (SQLITE_OK != sqlite3_reset (stmt))
         LOG_SQLITE (handle,
                     GNUNET_GE_ERROR | GNUNET_GE_ADMIN | GNUNET_GE_USER |
                     GNUNET_GE_BULK, "sqlite3_reset");
-      if (sq_prepare (dbh, "DELETE FROM gn070 WHERE size < ?", &stmtd) !=
+      if (sq_prepare (dbh, "DELETE FROM gn080 WHERE size < ?", &stmtd) !=
           SQLITE_OK)
         {
           LOG_SQLITE (handle,
@@ -484,7 +465,7 @@
                     GNUNET_GE_BULK, "sqlite3_reset");
       if (sq_prepare
           (dbh,
-           "DELETE FROM gn070 WHERE NOT ((LENGTH(hash) = ?) AND (size = 
LENGTH(value) + ?))",
+           "DELETE FROM gn080 WHERE NOT ((LENGTH(hash) = ?) AND (size = 
LENGTH(value) + ?))",
            &stmtd) != SQLITE_OK)
         {
           LOG_SQLITE (handle,
@@ -974,7 +955,7 @@
      http://permalink.gmane.org/gmane.network.gnunet.devel/1363 */
   if (sq_prepare (dbh,
                   "SELECT size,type,prio,anonLevel,expire,hash,value,_ROWID_"
-                  " FROM gn070 WHERE _ROWID_ > :1 ORDER BY _ROWID_ ASC LIMIT 
1",
+                  " FROM gn080 WHERE _ROWID_ > :1 ORDER BY _ROWID_ ASC LIMIT 
1",
                   &stmt) != SQLITE_OK)
     {
       LOG_SQLITE (handle,
@@ -1064,8 +1045,6 @@
       sqliteHandle *h = handles[idx];
 
       GNUNET_thread_release_self (h->tid);
-      sqlite3_finalize (h->countContent);
-      sqlite3_finalize (h->exists);
       sqlite3_finalize (h->updPrio);
       sqlite3_finalize (h->insertContent);
       if (sqlite3_close (h->dbh) != SQLITE_OK)
@@ -1100,6 +1079,7 @@
  * type.
  *
  * @param key maybe NULL (to match all entries)
+ * @param vhash hash of the value; maybe NULL (to match all entries)
  * @param type entries of which type are relevant?
  *     Use 0 for any type.
  * @param iter maybe NULL (to just count); iter
@@ -1111,6 +1091,7 @@
  */
 static int
 get (const GNUNET_HashCode * key,
+     const GNUNET_HashCode * vhash,
      unsigned int type, GNUNET_DatastoreValueIterator iter, void *closure)
 {
   int ret;
@@ -1126,6 +1107,7 @@
   GNUNET_HashCode rkey;
   unsigned long long last_rowid;
   unsigned long long rowid;
+  int sqoff;
 
   if (key == NULL)
     return iterateLowPriority (type, iter, closure);
@@ -1133,9 +1115,11 @@
   handle = getDBHandle ();
   dbh = handle->dbh;
 
-  strcpy (scratch, "SELECT count(*) FROM gn070 WHERE hash = :1");
-  if (type)
-    strcat (scratch, " AND type = :2");
+  GNUNET_snprintf (scratch, 256,
+                   "SELECT count(*) FROM gn080 WHERE hash=:1%s%s",
+                   vhash == NULL ? "" : " AND vhash=:2",
+                   type == 0 ? "" : (vhash ==
+                                     NULL) ? " AND type=:2" : " AND type=:3");
   if (sq_prepare (dbh, scratch, &stmt) != SQLITE_OK)
     {
       LOG_SQLITE (handle,
@@ -1144,11 +1128,17 @@
       GNUNET_mutex_unlock (lock);
       return GNUNET_SYSERR;
     }
+  sqoff = 1;
   ret = sqlite3_bind_blob (stmt,
-                           1,
+                           sqoff++,
                            key, sizeof (GNUNET_HashCode), SQLITE_TRANSIENT);
-  if (type && (ret == SQLITE_OK))
-    ret = sqlite3_bind_int (stmt, 2, type);
+  if ((vhash != NULL) && (ret == SQLITE_OK))
+    ret = sqlite3_bind_blob (stmt,
+                             sqoff++,
+                             vhash,
+                             sizeof (GNUNET_HashCode), SQLITE_TRANSIENT);
+  if ((type != 0) && (ret == SQLITE_OK))
+    ret = sqlite3_bind_int (stmt, sqoff++, type);
   if (ret != SQLITE_OK)
     {
       LOG_SQLITE (handle,
@@ -1181,16 +1171,14 @@
       return total;
     }
 
-  strcpy (scratch,
-          "SELECT size, type, prio, anonLevel, expire, hash, value, _ROWID_ "
-          "FROM gn070 WHERE hash = :1 AND _ROWID_ >= :2");
-  if (type)
-    strcat (scratch, " AND type = :3");
-  strcat (scratch, " ORDER BY _ROWID_ ASC LIMIT 1");
-  if (type)
-    strcat (scratch, " OFFSET :4");
-  else
-    strcat (scratch, " OFFSET :3");
+  GNUNET_snprintf (scratch, 256,
+                   "SELECT size, type, prio, anonLevel, expire, hash, value, 
_ROWID_ "
+                   "FROM gn080 WHERE hash=:1%s%s AND _ROWID_ >= :%d "
+                   "ORDER BY _ROWID_ ASC LIMIT 1 OFFSET :d",
+                   vhash == NULL ? "" : " AND vhash=:2",
+                   type == 0 ? "" : (vhash ==
+                                     NULL) ? " AND type=:2" : " AND type=:3",
+                   sqoff, sqoff + 1);
   if (sq_prepare (dbh, scratch, &stmt) != SQLITE_OK)
     {
       LOG_SQLITE (handle,
@@ -1208,16 +1196,22 @@
         limit_off = off;
       else
         limit_off = 0;
+      sqoff = 1;
       ret = sqlite3_bind_blob (stmt,
-                               1,
+                               sqoff++,
                                key, sizeof (GNUNET_HashCode),
                                SQLITE_TRANSIENT);
+      if ((vhash != NULL) && (ret == SQLITE_OK))
+        ret = sqlite3_bind_blob (stmt,
+                                 sqoff++,
+                                 vhash,
+                                 sizeof (GNUNET_HashCode), SQLITE_TRANSIENT);
+      if ((type != 0) && (ret == SQLITE_OK))
+        ret = sqlite3_bind_int (stmt, sqoff++, type);
       if (ret == SQLITE_OK)
-        ret = sqlite3_bind_int64 (stmt, 2, last_rowid);
-      if (type && (ret == SQLITE_OK))
-        ret = sqlite3_bind_int (stmt, 3, type);
+        ret = sqlite3_bind_int64 (stmt, sqoff++, last_rowid);
       if (ret == SQLITE_OK)
-        ret = sqlite3_bind_int (stmt, (type == 0) ? 3 : 4, limit_off);
+        ret = sqlite3_bind_int (stmt, sqoff++, limit_off);
       if (ret == SQLITE_OK)
         {
           ret = sqlite3_step (stmt);
@@ -1277,6 +1271,7 @@
   unsigned int contentSize;
   unsigned int size, type, prio, anon;
   unsigned long long expir;
+  GNUNET_HashCode vhash;
   sqliteHandle *dbh;
 #if DEBUG_SQLITE
   GNUNET_EncName enc;
@@ -1294,17 +1289,18 @@
       GNUNET_GE_BREAK (ectx, 0);
       return GNUNET_SYSERR;
     }
-  GNUNET_mutex_lock (lock);
-  dbh = getDBHandle ();
-  if (lastSync > 1000)
-    syncStats (dbh);
-  contentSize = ntohl (value->size) - sizeof (GNUNET_DatastoreValue);
-  stmt = dbh->insertContent;
   size = ntohl (value->size);
   type = ntohl (value->type);
   prio = ntohl (value->prio);
   anon = ntohl (value->anonymityLevel);
   expir = GNUNET_ntohll (value->expirationTime);
+  contentSize = size - sizeof (GNUNET_DatastoreValue);
+  GNUNET_hash (&value[1], contentSize, &vhash);
+  GNUNET_mutex_lock (lock);
+  dbh = getDBHandle ();
+  if (lastSync > 1000)
+    syncStats (dbh);
+  stmt = dbh->insertContent;
   if ((SQLITE_OK != sqlite3_bind_int (stmt, 1, size)) ||
       (SQLITE_OK != sqlite3_bind_int (stmt, 2, type)) ||
       (SQLITE_OK != sqlite3_bind_int (stmt, 3, prio)) ||
@@ -1312,9 +1308,12 @@
       (SQLITE_OK != sqlite3_bind_int64 (stmt, 5, expir)) ||
       (SQLITE_OK !=
        sqlite3_bind_blob (stmt, 6, key, sizeof (GNUNET_HashCode),
+                          SQLITE_TRANSIENT)) ||
+      (SQLITE_OK !=
+       sqlite3_bind_blob (stmt, 7, &vhash, sizeof (GNUNET_HashCode),
                           SQLITE_TRANSIENT))
       || (SQLITE_OK !=
-          sqlite3_bind_blob (stmt, 7, &value[1], contentSize,
+          sqlite3_bind_blob (stmt, 8, &value[1], contentSize,
                              SQLITE_TRANSIENT)))
     {
       LOG_SQLITE (dbh,

Modified: GNUnet/src/applications/sqstore_sqlite/sqlitetest.c
===================================================================
--- GNUnet/src/applications/sqstore_sqlite/sqlitetest.c 2008-02-20 00:09:30 UTC 
(rev 6386)
+++ GNUnet/src/applications/sqstore_sqlite/sqlitetest.c 2008-02-20 03:41:55 UTC 
(rev 6387)
@@ -172,7 +172,7 @@
   for (i = 255; i >= 0; i--)
     {
       memset (&key, 256 - i, sizeof (GNUNET_HashCode));
-      ASSERT (1 == api->get (&key, i, &checkValue, (void *) &i));
+      ASSERT (1 == api->get (&key, NULL, i, &checkValue, (void *) &i));
     }
   ASSERT (256 ==
           api->iterateLowPriority (GNUNET_ECRS_BLOCKTYPE_ANY, NULL, NULL));
@@ -181,7 +181,7 @@
   for (i = 255; i >= 0; i--)
     {
       memset (&key, 256 - i, sizeof (GNUNET_HashCode));
-      ASSERT (1 == api->get (&key, i, &checkValue, (void *) &i));
+      ASSERT (1 == api->get (&key, NULL, i, &checkValue, (void *) &i));
     }
 
   oldSize = api->getSize ();
@@ -189,7 +189,7 @@
     {
       memset (&key, 256 - i, sizeof (GNUNET_HashCode));
       value = initValue (i);
-      ASSERT (1 == api->get (&key, 0, &iterateDelete, NULL));
+      ASSERT (1 == api->get (&key, NULL, 0, &iterateDelete, NULL));
       GNUNET_free (value);
     }
   ASSERT (oldSize > api->getSize ());

Modified: GNUnet/src/applications/stats/clientapi.c
===================================================================
--- GNUnet/src/applications/stats/clientapi.c   2008-02-20 00:09:30 UTC (rev 
6386)
+++ GNUnet/src/applications/stats/clientapi.c   2008-02-20 03:41:55 UTC (rev 
6387)
@@ -247,9 +247,6 @@
     case GNUNET_CS_PROTO_VPN_REPLY:
       name = "GNUNET_CS_PROTO_VPN_REPLY";
       break;
-    case GNUNET_CS_PROTO_VPN_DEBUGOFF:
-      name = "GNUNET_CS_PROTO_VPN_DEBUGOFF";
-      break;
     case GNUNET_CS_PROTO_VPN_TUNNELS:
       name = "GNUNET_CS_PROTO_VPN_TUNNELS";
       break;
@@ -262,9 +259,6 @@
     case GNUNET_CS_PROTO_VPN_RESET:
       name = "GNUNET_CS_PROTO_VPN_RESET";
       break;
-    case GNUNET_CS_PROTO_VPN_REALISE:
-      name = "GNUNET_CS_PROTO_VPN_REALISE";
-      break;
     case GNUNET_CS_PROTO_VPN_ADD:
       name = "GNUNET_CS_PROTO_VPN_ADD";
       break;

Modified: GNUnet/src/applications/vpn/cs.c
===================================================================
--- GNUnet/src/applications/vpn/cs.c    2008-02-20 00:09:30 UTC (rev 6386)
+++ GNUnet/src/applications/vpn/cs.c    2008-02-20 03:41:55 UTC (rev 6387)
@@ -35,8 +35,8 @@
 #include "helper.h"
 
 /** The console client is used to admin/debug vpn */
-int csHandle (struct GNUNET_ClientHandle *c,
-             const GNUNET_MessageHeader * message)
+int
+csHandle (struct GNUNET_ClientHandle *c, const GNUNET_MessageHeader * message)
 {
   GNUNET_MessageHeader *rgp = NULL;
   int i;
@@ -239,6 +239,3 @@
     }
   return GNUNET_OK;
 }
-
-
-

Modified: GNUnet/src/applications/vpn/cs.h
===================================================================
--- GNUnet/src/applications/vpn/cs.h    2008-02-20 00:09:30 UTC (rev 6386)
+++ GNUnet/src/applications/vpn/cs.h    2008-02-20 03:41:55 UTC (rev 6387)
@@ -30,6 +30,6 @@
 
 /** The console client is used to admin/debug vpn */
 int csHandle (struct GNUNET_ClientHandle *c,
-             const GNUNET_MessageHeader * message);
+              const GNUNET_MessageHeader * message);
 
-#endif 
+#endif

Modified: GNUnet/src/applications/vpn/gnunet-vpn.c
===================================================================
--- GNUnet/src/applications/vpn/gnunet-vpn.c    2008-02-20 00:09:30 UTC (rev 
6386)
+++ GNUnet/src/applications/vpn/gnunet-vpn.c    2008-02-20 03:41:55 UTC (rev 
6387)
@@ -270,8 +270,7 @@
         }
       else
         {
-          printf
-            ("tunnels, route, realised, reset, trust, add <hash>\n");
+          printf ("tunnels, route, realised, reset, trust, add <hash>\n");
         }
     }
   /* wait for shutdown... */

Modified: GNUnet/src/applications/vpn/helper.c
===================================================================
--- GNUnet/src/applications/vpn/helper.c        2008-02-20 00:09:30 UTC (rev 
6386)
+++ GNUnet/src/applications/vpn/helper.c        2008-02-20 03:41:55 UTC (rev 
6387)
@@ -43,8 +43,8 @@
   int size = 100;
   GNUNET_MessageHeader *b;
 
-  GNUNET_GE_ASSERT(NULL, c != NULL);
-    
+  GNUNET_GE_ASSERT (NULL, c != NULL);
+
   b = GNUNET_malloc (sizeof (GNUNET_MessageHeader) + size);
   while (1)
     {
@@ -74,8 +74,8 @@
  * Convert a PeerIdentify into a "random" RFC4193 prefix
  * actually we make the first 40 bits of the GNUNET_hash into the prefix!
  */
-void id2ip (struct GNUNET_ClientHandle *cx,
-                   const GNUNET_PeerIdentity * them)
+void
+id2ip (struct GNUNET_ClientHandle *cx, const GNUNET_PeerIdentity * them)
 {
   unsigned char a, b, c, d, e;
   a = (them->hashPubKey.bits[0] >> 8) & 0xff;
@@ -93,15 +93,15 @@
 isEqualP (const GNUNET_RSA_PublicKey * first,
           const GNUNET_RSA_PublicKey * second)
 {
-  return 0 == memcmp(first, second,
-                    sizeof(GNUNET_RSA_PublicKey));
+  return 0 == memcmp (first, second, sizeof (GNUNET_RSA_PublicKey));
 }
 
 
 /**
  * Render IPv4 or IPv6 packet info for logging.
  */
-void ipinfo (char *info, const struct ip6_hdr *fp)
+void
+ipinfo (char *info, const struct ip6_hdr *fp)
 {
   struct in_addr fr4;
   struct in_addr to4;
@@ -142,17 +142,19 @@
 
 
 /** Test if two GNUNET_PeerIdentity are equal or not */
-int isEqual (const GNUNET_PeerIdentity * first,
-                    const GNUNET_PeerIdentity * second)
+int
+isEqual (const GNUNET_PeerIdentity * first,
+         const GNUNET_PeerIdentity * second)
 {
-  return (0 == memcmp(first, second, sizeof(GNUNET_PeerIdentity)))?-1:0;
+  return (0 == memcmp (first, second, sizeof (GNUNET_PeerIdentity))) ? -1 : 0;
 }
 
 
 
 
 /* convert GNUNET_PeerIdentity into network octet order IPv6 address */
-void id2net (struct in6_addr *buf, const GNUNET_PeerIdentity * them)
+void
+id2net (struct in6_addr *buf, const GNUNET_PeerIdentity * them)
 {
   unsigned char a, b, c, d, e;
   a = (them->hashPubKey.bits[0] >> 8) & 0xff;
@@ -175,4 +177,3 @@
   buf->s6_addr16[6] = 0;
   buf->s6_addr16[7] = 0;
 }
-

Modified: GNUnet/src/applications/vpn/helper.h
===================================================================
--- GNUnet/src/applications/vpn/helper.h        2008-02-20 00:09:30 UTC (rev 
6386)
+++ GNUnet/src/applications/vpn/helper.h        2008-02-20 03:41:55 UTC (rev 
6387)
@@ -32,15 +32,13 @@
 /**
  * send given string to client 
  */
-void
-cprintf (struct GNUNET_ClientHandle *c, int t, const char *format, ...);
+void cprintf (struct GNUNET_ClientHandle *c, int t, const char *format, ...);
 
 /**
  * Convert a PeerIdentify into a "random" RFC4193 prefix
  * actually we make the first 40 bits of the GNUNET_hash into the prefix!
  */
-void id2ip (struct GNUNET_ClientHandle *cx,
-           const GNUNET_PeerIdentity * them);
+void id2ip (struct GNUNET_ClientHandle *cx, const GNUNET_PeerIdentity * them);
 
 
 /** Test if two GNUNET_RSA_PublicKey are equal or not */
@@ -55,7 +53,7 @@
 
 /** Test if two GNUNET_PeerIdentity are equal or not */
 int isEqual (const GNUNET_PeerIdentity * first,
-            const GNUNET_PeerIdentity * second);
+             const GNUNET_PeerIdentity * second);
 
 /* convert GNUNET_PeerIdentity into network octet order IPv6 address */
 void id2net (struct in6_addr *buf, const GNUNET_PeerIdentity * them);

Modified: GNUnet/src/applications/vpn/vpn.c
===================================================================
--- GNUnet/src/applications/vpn/vpn.c   2008-02-20 00:09:30 UTC (rev 6386)
+++ GNUnet/src/applications/vpn/vpn.c   2008-02-20 03:41:55 UTC (rev 6387)
@@ -173,9 +173,11 @@
               /* we don't store alternative routes to ourselves,
                * as we already know how to route to ourself
                */
-             GNUNET_GE_LOG (ectx,
-                            GNUNET_GE_DEBUG | GNUNET_GE_BULK | GNUNET_GE_ADMIN,
-                            _("Not storing route to myself from peer %d\n"), 
tunnel);
+              GNUNET_GE_LOG (ectx,
+                             GNUNET_GE_DEBUG | GNUNET_GE_BULK |
+                             GNUNET_GE_ADMIN,
+                             _("Not storing route to myself from peer %d\n"),
+                             tunnel);
               return;
             }
           if ((route_store + i)->tunnel == tunnel)
@@ -184,11 +186,12 @@
                * but store the lowest hop count that the peer is advertising 
for that node.
                */
               (route_store + i)->hops = mini ((route_store + i)->hops, hops);
-             GNUNET_GE_LOG (ectx,
-                            GNUNET_GE_DEBUG | GNUNET_GE_BULK | GNUNET_GE_ADMIN,
-                            _
-                            ("Duplicate route to node from peer %d, choosing 
minimum hops"),
-                            tunnel);
+              GNUNET_GE_LOG (ectx,
+                             GNUNET_GE_DEBUG | GNUNET_GE_BULK |
+                             GNUNET_GE_ADMIN,
+                             _
+                             ("Duplicate route to node from peer %d, choosing 
minimum hops"),
+                             tunnel);
               return;
             }
         }
@@ -221,9 +224,10 @@
           i--;
         }
       GNUNET_GE_LOG (ectx,
-                    GNUNET_GE_DEBUG | GNUNET_GE_BULK | GNUNET_GE_ADMIN,
-                    _("Inserting route from peer %d in route table at location 
%d\n"),
-        tunnel, i);
+                     GNUNET_GE_DEBUG | GNUNET_GE_BULK | GNUNET_GE_ADMIN,
+                     _
+                     ("Inserting route from peer %d in route table at location 
%d\n"),
+                     tunnel, i);
       (route_store + i)->hops = hops;
       (route_store + i)->tunnel = tunnel;
       (route_store + i)->owner = *them;
@@ -232,7 +236,8 @@
 
 
 /** check that ethertype matches ip version for incoming packets from linux 
specific code */
-static int valid_incoming (int len, struct tun_pi *tp, struct ip6_hdr *fp)
+static int
+valid_incoming (int len, struct tun_pi *tp, struct ip6_hdr *fp)
 {
   char info[100];
   if (len > (65535 - sizeof (struct tun_pi)))
@@ -258,8 +263,9 @@
     {
       ipinfo (info, fp);
       GNUNET_GE_LOG (ectx,
-                    GNUNET_GE_DEBUG | GNUNET_GE_BULK | GNUNET_GE_ADMIN,
-                    "-> GNUnet(%d) : %s\n", len - sizeof (struct tun_pi), 
info);
+                     GNUNET_GE_DEBUG | GNUNET_GE_BULK | GNUNET_GE_ADMIN,
+                     "-> GNUnet(%d) : %s\n", len - sizeof (struct tun_pi),
+                     info);
       return GNUNET_YES;
     }
   GNUNET_GE_LOG (ectx, GNUNET_GE_ERROR | GNUNET_GE_BULK | GNUNET_GE_USER,
@@ -268,7 +274,8 @@
   return GNUNET_NO;
 }
 
-static void setup_tunnel (int n, const GNUNET_PeerIdentity * them)
+static void
+setup_tunnel (int n, const GNUNET_PeerIdentity * them)
 {
   struct ifreq ifr;
   struct in6_ifreq ifr6;
@@ -485,8 +492,8 @@
  * See if we already got a TUN/TAP open for the given GNUnet peer. if not, 
make one, stick
  * GNUNET_PeerIdentity and the filehandle and name of the TUN/TAP in an array 
so we remember we did it.
  */
-static void checkensure_peer (const GNUNET_PeerIdentity * them,
-                              void *callerinfo)
+static void
+checkensure_peer (const GNUNET_PeerIdentity * them, void *callerinfo)
 {
   int i;
   tunnel_info *rstore1;
@@ -539,7 +546,8 @@
  * own IPv6 addr is fdXX:XXXX:XXXX::P/48 where X= 40 bits own key, P = gnu0 + 2
  * route add -net fdXX(remote key) dev gnu0 is then used.
  */
-static void *tunThread (void *arg)
+static void *
+tunThread (void *arg)
 {
   fd_set readSet;
   fd_set errorSet;
@@ -689,8 +697,9 @@
  * Mainly this routine exchanges the GNUNET_MessageHeader on incoming ipv6 
packets
  * for a TUN/TAP header for writing it to TUNTAP.
  */
-static int handlep2pMSG (const GNUNET_PeerIdentity * sender,
-                         const GNUNET_MessageHeader * gp)
+static int
+handlep2pMSG (const GNUNET_PeerIdentity * sender,
+              const GNUNET_MessageHeader * gp)
 {
   int i = 0, fd;
   char loginfo[100];
@@ -759,9 +768,10 @@
 
       GNUNET_mutex_lock (lock);
       GNUNET_GE_LOG (ectx,
-                    GNUNET_GE_DEBUG | GNUNET_GE_BULK | GNUNET_GE_ADMIN,
-                    _("<- GNUnet(%d) : %s\n"),
-                    ntohs (gp->size) - sizeof (GNUNET_MessageHeader), loginfo);
+                     GNUNET_GE_DEBUG | GNUNET_GE_BULK | GNUNET_GE_ADMIN,
+                     _("<- GNUnet(%d) : %s\n"),
+                     ntohs (gp->size) - sizeof (GNUNET_MessageHeader),
+                     loginfo);
       for (i = 0; i < entries1; i++)
         {
           if (isEqual (sender, &((store1 + i)->peer)))
@@ -810,17 +820,18 @@
     case GNUNET_P2P_PROTO_AIP_GETROUTE:
         /** peer wants an entry from our routing table */
       GNUNET_GE_LOG (ectx,
-                    GNUNET_GE_DEBUG | GNUNET_GE_BULK | GNUNET_GE_ADMIN,
-                    _("Receive route request\n"));
+                     GNUNET_GE_DEBUG | GNUNET_GE_BULK | GNUNET_GE_ADMIN,
+                     _("Receive route request\n"));
       if (ntohs (gp->size) == (sizeof (GNUNET_MessageHeader) + sizeof (int)))
         {
           i = ntohl (*((int *) fp));
           GNUNET_mutex_lock (lock);
           if (i < realised_entries)
             {
-             GNUNET_GE_LOG (ectx,
-                            GNUNET_GE_DEBUG | GNUNET_GE_BULK | GNUNET_GE_ADMIN,
-                            _("Prepare route announcement level %d\n"), i);
+              GNUNET_GE_LOG (ectx,
+                             GNUNET_GE_DEBUG | GNUNET_GE_BULK |
+                             GNUNET_GE_ADMIN,
+                             _("Prepare route announcement level %d\n"), i);
               rgp =
                 GNUNET_malloc (sizeof (GNUNET_MessageHeader) +
                                sizeof (transit_route));
@@ -838,17 +849,20 @@
               ((transit_route *) (rgp + 1))->hops =
                 htonl ((realised_store + i)->hops);
               GNUNET_mutex_unlock (lock);
-             GNUNET_GE_LOG (ectx,
-                            GNUNET_GE_DEBUG | GNUNET_GE_BULK | GNUNET_GE_ADMIN,
-                            _("Send route announcement %d with route 
announce\n"), i);
+              GNUNET_GE_LOG (ectx,
+                             GNUNET_GE_DEBUG | GNUNET_GE_BULK |
+                             GNUNET_GE_ADMIN,
+                             _
+                             ("Send route announcement %d with route 
announce\n"),
+                             i);
               /* it must be delivered if possible, but it can wait longer than 
IP */
               coreAPI->unicast (sender, rgp, GNUNET_EXTREME_PRIORITY, 15);
               GNUNET_free (rgp);
               return GNUNET_OK;
             }
-         GNUNET_GE_LOG (ectx,
-                        GNUNET_GE_DEBUG | GNUNET_GE_BULK | GNUNET_GE_ADMIN,
-                        _("Send outside table info %d\n"), i);
+          GNUNET_GE_LOG (ectx,
+                         GNUNET_GE_DEBUG | GNUNET_GE_BULK | GNUNET_GE_ADMIN,
+                         _("Send outside table info %d\n"), i);
           rgp = GNUNET_malloc (sizeof (GNUNET_MessageHeader) + sizeof (int));
           if (rgp == NULL)
             {
@@ -866,25 +880,26 @@
       return GNUNET_OK;
     case GNUNET_P2P_PROTO_AIP_ROUTE:
       GNUNET_GE_LOG (ectx,
-                    GNUNET_GE_DEBUG | GNUNET_GE_BULK | GNUNET_GE_ADMIN,
-                    _("Receive route announce.\n"));
+                     GNUNET_GE_DEBUG | GNUNET_GE_BULK | GNUNET_GE_ADMIN,
+                     _("Receive route announce.\n"));
         /** peer sent us a route, insert it into routing table, then req next 
entry */
       if (ntohs (gp->size) ==
           (sizeof (GNUNET_MessageHeader) + sizeof (transit_route)))
         {
           GNUNET_mutex_lock (lock);
-         GNUNET_GE_LOG (ectx,
-                        GNUNET_GE_DEBUG | GNUNET_GE_BULK | GNUNET_GE_ADMIN,
-                        _("Going to try insert route into local table.\n"));
+          GNUNET_GE_LOG (ectx,
+                         GNUNET_GE_DEBUG | GNUNET_GE_BULK | GNUNET_GE_ADMIN,
+                         _("Going to try insert route into local table.\n"));
           for (i = 0; i < entries1; i++)
             {
               if (isEqual (sender, &((store1 + i)->peer)))
                 {
                   (store1 + i)->active = GNUNET_YES;
-                 GNUNET_GE_LOG (ectx,
-                                GNUNET_GE_DEBUG | GNUNET_GE_BULK | 
GNUNET_GE_ADMIN,
-                                _("Inserting with hops %d\n"),
-                                ntohl (((transit_route *) (gp + 1))->hops));
+                  GNUNET_GE_LOG (ectx,
+                                 GNUNET_GE_DEBUG | GNUNET_GE_BULK |
+                                 GNUNET_GE_ADMIN,
+                                 _("Inserting with hops %d\n"),
+                                 ntohl (((transit_route *) (gp + 1))->hops));
                   add_route (&(((transit_route *) (gp + 1))->owner),
                              1 + ntohl (((transit_route *) (gp + 1))->hops),
                              i);
@@ -904,10 +919,11 @@
                         htons (sizeof (GNUNET_MessageHeader) + sizeof (int));
                       *((int *) (rgp + 1)) =
                         htonl ((store1 + i)->route_entry);
-                     GNUNET_GE_LOG (ectx,
-                                    GNUNET_GE_DEBUG | GNUNET_GE_BULK | 
GNUNET_GE_ADMIN,
-                                    _("Request level %d from peer %d\n"),
-                                    (store1 + i)->route_entry, i);
+                      GNUNET_GE_LOG (ectx,
+                                     GNUNET_GE_DEBUG | GNUNET_GE_BULK |
+                                     GNUNET_GE_ADMIN,
+                                     _("Request level %d from peer %d\n"),
+                                     (store1 + i)->route_entry, i);
                       coreAPI->unicast (&((store1 + i)->peer), rgp,
                                         GNUNET_EXTREME_PRIORITY, 60);
                       GNUNET_free (rgp);
@@ -924,10 +940,10 @@
           /* if this is the last route message, we do route realisation
            * that is, insert the routes into the operating system.
            */
-         GNUNET_GE_LOG (ectx,
-                        GNUNET_GE_DEBUG | GNUNET_GE_BULK | GNUNET_GE_ADMIN,
-                        _("Receive table limit on peer reached %d\n"),
-                        ntohl (*((int *) fp)));
+          GNUNET_GE_LOG (ectx,
+                         GNUNET_GE_DEBUG | GNUNET_GE_BULK | GNUNET_GE_ADMIN,
+                         _("Receive table limit on peer reached %d\n"),
+                         ntohl (*((int *) fp)));
 /*             GNUNET_mutex_lock(lock);
                for (i = 0; i < entries1; i++) {
                        if (isEqual(sender, &((store1+i)->peer))) {
@@ -949,7 +965,8 @@
  * here we copy the prototype route table we are collecting from peers to the 
actual
  * "realised" route table we distribute to peers, and to the kernel's table.
  */
-static void realise (void * unused)
+static void
+realise (void *unused)
 {
   int i, j, found;
   GNUNET_PeerIdentity id;
@@ -970,9 +987,10 @@
           reqstore = GNUNET_realloc (realised_store, reqcapacity);
           if (reqstore == NULL)
             {
-             GNUNET_GE_LOG (ectx,
-                            GNUNET_GE_WARNING | GNUNET_GE_DEVELOPER | 
GNUNET_GE_BULK,
-                            "I cannot up the ram for realised routes.\n");
+              GNUNET_GE_LOG (ectx,
+                             GNUNET_GE_WARNING | GNUNET_GE_DEVELOPER |
+                             GNUNET_GE_BULK,
+                             "I cannot up the ram for realised routes.\n");
               GNUNET_mutex_unlock (lock);
               return;
             }
@@ -1014,29 +1032,32 @@
           rt.rtmsg_metric = (route_store + i)->hops;
           /* how many hops to owner of public key */
           rt.rtmsg_dst_len = 48;        /* always 48 as per RFC4193 */
-         GNUNET_GE_LOG (ectx,
-                        GNUNET_GE_DEBUG | GNUNET_GE_DEVELOPER | 
GNUNET_GE_REQUEST,
-                   "Add route gnu%d hops %d dst %x:%x:%x:%x:%x:%x:%x:%x/%d\n",
-                   id, rt.rtmsg_metric, ntohs (rt.rtmsg_dst.s6_addr16[0]),
-                   ntohs (rt.rtmsg_dst.s6_addr16[1]),
-                   ntohs (rt.rtmsg_dst.s6_addr16[2]),
-                   ntohs (rt.rtmsg_dst.s6_addr16[3]),
-                   ntohs (rt.rtmsg_dst.s6_addr16[4]),
-                   ntohs (rt.rtmsg_dst.s6_addr16[5]),
-                   ntohs (rt.rtmsg_dst.s6_addr16[6]),
-                   ntohs (rt.rtmsg_dst.s6_addr16[7]), rt.rtmsg_dst_len);
+          GNUNET_GE_LOG (ectx,
+                         GNUNET_GE_DEBUG | GNUNET_GE_DEVELOPER |
+                         GNUNET_GE_REQUEST,
+                         "Add route gnu%d hops %d dst 
%x:%x:%x:%x:%x:%x:%x:%x/%d\n",
+                         id, rt.rtmsg_metric,
+                         ntohs (rt.rtmsg_dst.s6_addr16[0]),
+                         ntohs (rt.rtmsg_dst.s6_addr16[1]),
+                         ntohs (rt.rtmsg_dst.s6_addr16[2]),
+                         ntohs (rt.rtmsg_dst.s6_addr16[3]),
+                         ntohs (rt.rtmsg_dst.s6_addr16[4]),
+                         ntohs (rt.rtmsg_dst.s6_addr16[5]),
+                         ntohs (rt.rtmsg_dst.s6_addr16[6]),
+                         ntohs (rt.rtmsg_dst.s6_addr16[7]), rt.rtmsg_dst_len);
           if (ioctl (admin_fd, SIOCADDRT, &rt) < 0)
             {
-             GNUNET_GE_LOG (ectx,
-                            GNUNET_GE_WARNING | GNUNET_GE_DEVELOPER | 
GNUNET_GE_BULK,
-                       "Cannot add route IPv6 address for gnu%s because %s\n",
-                       id, strerror (errno));
+              GNUNET_GE_LOG (ectx,
+                             GNUNET_GE_WARNING | GNUNET_GE_DEVELOPER |
+                             GNUNET_GE_BULK,
+                             "Cannot add route IPv6 address for gnu%s because 
%s\n",
+                             id, strerror (errno));
             }
         }
     }
   GNUNET_GE_LOG (ectx,
-                GNUNET_GE_DEBUG | GNUNET_GE_DEVELOPER | GNUNET_GE_REQUEST,
-                "Removing routes\n");
+                 GNUNET_GE_DEBUG | GNUNET_GE_DEVELOPER | GNUNET_GE_REQUEST,
+                 "Removing routes\n");
   /* pull routes that are in the old table but not the new */
   for (i = 0; i < realised_entries; i++)
     {
@@ -1069,23 +1090,26 @@
           rt.rtmsg_metric = (realised_store + i)->hops;
           /* how many hops to owner of public key */
           rt.rtmsg_dst_len = 48;        /* always 48 as per RFC4193 */
-         GNUNET_GE_LOG (ectx,
-                        GNUNET_GE_DEBUG | GNUNET_GE_DEVELOPER | 
GNUNET_GE_REQUEST,
-                        "Delete route gnu%d hops %d dst 
%x:%x:%x:%x:%x:%x:%x:%x/%d\n",
-                   id, rt.rtmsg_metric, ntohs (rt.rtmsg_dst.s6_addr16[0]),
-                   ntohs (rt.rtmsg_dst.s6_addr16[1]),
-                   ntohs (rt.rtmsg_dst.s6_addr16[2]),
-                   ntohs (rt.rtmsg_dst.s6_addr16[3]),
-                   ntohs (rt.rtmsg_dst.s6_addr16[4]),
-                   ntohs (rt.rtmsg_dst.s6_addr16[5]),
-                   ntohs (rt.rtmsg_dst.s6_addr16[6]),
-                   ntohs (rt.rtmsg_dst.s6_addr16[7]), rt.rtmsg_dst_len);
+          GNUNET_GE_LOG (ectx,
+                         GNUNET_GE_DEBUG | GNUNET_GE_DEVELOPER |
+                         GNUNET_GE_REQUEST,
+                         "Delete route gnu%d hops %d dst 
%x:%x:%x:%x:%x:%x:%x:%x/%d\n",
+                         id, rt.rtmsg_metric,
+                         ntohs (rt.rtmsg_dst.s6_addr16[0]),
+                         ntohs (rt.rtmsg_dst.s6_addr16[1]),
+                         ntohs (rt.rtmsg_dst.s6_addr16[2]),
+                         ntohs (rt.rtmsg_dst.s6_addr16[3]),
+                         ntohs (rt.rtmsg_dst.s6_addr16[4]),
+                         ntohs (rt.rtmsg_dst.s6_addr16[5]),
+                         ntohs (rt.rtmsg_dst.s6_addr16[6]),
+                         ntohs (rt.rtmsg_dst.s6_addr16[7]), rt.rtmsg_dst_len);
           if (ioctl (admin_fd, SIOCDELRT, &rt) < 0)
             {
-             GNUNET_GE_LOG (ectx,
-                            GNUNET_GE_WARNING | GNUNET_GE_DEVELOPER | 
GNUNET_GE_BULK,
-                            "Cannot del route IPv6 address for gnu%s because 
%s\n",
-                       id, strerror (errno));
+              GNUNET_GE_LOG (ectx,
+                             GNUNET_GE_WARNING | GNUNET_GE_DEVELOPER |
+                             GNUNET_GE_BULK,
+                             "Cannot del route IPv6 address for gnu%s because 
%s\n",
+                             id, strerror (errno));
             }
         }
     }
@@ -1106,10 +1130,11 @@
  * Also enumerate all current peers and create taps for them.
  *
  */
-int initialize_module_vpn (GNUNET_CoreAPIForPlugins * capi)
+int
+initialize_module_vpn (GNUNET_CoreAPIForPlugins * capi)
 {
   int pfd;
-  char *str = GNUNET_strdup("OK\r\n");
+  char *str = GNUNET_strdup ("OK\r\n");
 
   ectx = capi->ectx;
   lock = GNUNET_mutex_create (GNUNET_NO);
@@ -1131,7 +1156,7 @@
       CLOSE (pfd);
     }
   UNLINK ("/var/lib/gnunet/gnunet.vpn");
-  GNUNET_free(str);
+  GNUNET_free (str);
 
   /* system("sudo setpcaps cap_net_admin+eip `pidof gnunetd`"); */
 
@@ -1205,20 +1230,17 @@
   PIPE (signalingPipe);
   /* important: make signalingPipe non-blocking
      to avoid stalling on signaling! */
-  GNUNET_pipe_make_nonblocking(ectx, signalingPipe[1]);
+  GNUNET_pipe_make_nonblocking (ectx, signalingPipe[1]);
 
   /* Yes we have to make our own thread, cause the GUNnet API is
    * missing some callbacks (Namely CanReadThisFd - SELECT()) that I would 
like ;-(
    * They may go in the thread that usually monitors the GUI port.
    */
-  tunThreadInfo =
-    GNUNET_thread_create (&tunThread, NULL,
-                          128 * 1024);
-  GNUNET_cron_add_job(capi->cron,
-                     &realise,
-                     5 * GNUNET_CRON_MINUTES,
-                     5 * GNUNET_CRON_MINUTES,
-                     NULL);
+  tunThreadInfo = GNUNET_thread_create (&tunThread, NULL, 128 * 1024);
+  GNUNET_cron_add_job (capi->cron,
+                       &realise,
+                       5 * GNUNET_CRON_MINUTES,
+                       5 * GNUNET_CRON_MINUTES, NULL);
   /* use capi->unicast to send messages to connected peers */
   GNUNET_GE_ASSERT (capi->ectx,
                     0 == GNUNET_GC_set_configuration_value_string (capi->cfg,
@@ -1234,16 +1256,15 @@
 /**
  * Module uninserted.
  */
-void done_module_vpn ()
+void
+done_module_vpn ()
 {
   int i;
   int ret;
   void *returnval;
 
-  GNUNET_cron_del_job(coreAPI->cron,
-                     &realise,
-                     5 * GNUNET_CRON_MINUTES,
-                     NULL);
+  GNUNET_cron_del_job (coreAPI->cron,
+                       &realise, 5 * GNUNET_CRON_MINUTES, NULL);
   coreAPI->unregisterHandler (GNUNET_P2P_PROTO_AIP_IP, &handlep2pMSG);
   coreAPI->unregisterHandler (GNUNET_P2P_PROTO_AIP_GETROUTE, &handlep2pMSG);
   coreAPI->unregisterHandler (GNUNET_P2P_PROTO_AIP_ROUTE, &handlep2pMSG);
@@ -1257,7 +1278,7 @@
   coreAPI->unregisterClientHandler (GNUNET_CS_PROTO_VPN_RESET, &csHandle);
   coreAPI->unregisterClientHandler (GNUNET_CS_PROTO_VPN_ADD, &csHandle);
   coreAPI->unregisterClientHandler (GNUNET_CS_PROTO_VPN_TRUST, &csHandle);
-  coreAPI->unregisterClientHandler (GNUNET_CS_PROTO_VPN_REPLY, &csHandle);  
+  coreAPI->unregisterClientHandler (GNUNET_CS_PROTO_VPN_REPLY, &csHandle);
 
   GNUNET_GE_LOG (ectx, GNUNET_GE_INFO | GNUNET_GE_REQUEST | GNUNET_GE_USER,
                  _("RFC4193 Waiting for tun thread to end\n"));

Modified: GNUnet/src/include/gnunet_sqstore_service.h
===================================================================
--- GNUnet/src/include/gnunet_sqstore_service.h 2008-02-20 00:09:30 UTC (rev 
6386)
+++ GNUnet/src/include/gnunet_sqstore_service.h 2008-02-20 03:41:55 UTC (rev 
6387)
@@ -72,6 +72,11 @@
    * in the datastore.
    *
    * @param key maybe NULL (to match all entries)
+   * @param vhash hash of the value, maybe NULL (to 
+   *        match all values that have the right key).
+   *        Note that for DBlocks there is no difference
+   *        betwen key and vhash, but for other blocks
+   *        there may be!
    * @param type entries of which type are relevant?
    *     Use 0 for any type.
    * @param iter maybe NULL (to just count); iter
@@ -82,6 +87,7 @@
    *         GNUNET_SYSERR on error
    */
   int (*get) (const GNUNET_HashCode * key,
+              const GNUNET_HashCode * vhash,
               unsigned int type, GNUNET_DatastoreValueIterator iter,
               void *closure);
 

Modified: GNUnet/todo
===================================================================
--- GNUnet/todo 2008-02-20 00:09:30 UTC (rev 6386)
+++ GNUnet/todo 2008-02-20 03:41:55 UTC (rev 6387)
@@ -14,6 +14,29 @@
 
 TESTING:
 - test GAP code in general (still have one unexplained crazy crash!)
+  Program terminated with signal 11, Segmentation fault.
+ #0  0xb4e8e73a in GNUNET_FS_SHARED_test_valid_new_response (rl=0x8060,
+     primary_key=0xb343f1c8, size=820, data=0xb0b8f0e8, hc=0xb343f134) at 
shared.c:94
+ 94        if (((rl->type != GNUNET_ECRS_BLOCKTYPE_ANY) &&
+ (gdb) ba
+ #0  0xb4e8e73a in GNUNET_FS_SHARED_test_valid_new_response (rl=0x8060,
+     primary_key=0xb343f1c8, size=820, data=0xb0b8f0e8, hc=0xb343f134) at 
shared.c:94
+ #1  0xb4e876f9 in GNUNET_FS_GAP_handle_response (sender=0x0, 
primary_query=0xb343f1c8,
+      expiration=12012449401453674496, size=820, data=0xb0b8f0e8) at gap.c:433
+ #2  0xb4e852ec in handle_p2p_content (sender=0x0, pmsg=0xb0b8f0d8) at fs.c:702
+ #3  0xb7f0911b in GNUNET_CORE_p2p_inject_message (sender=0x0, msg=0xb0b8f0d8 
"\003D",
+     size=836, wasEncrypted=1, session=0x0) at handler.c:499
+ #4  0xb4e86bc5 in send_delayed (cls=0xb0b8f0d8) at gap.c:101
+ #5  0xb7c72ec3 in runJob (cron=0x8099438) at cron.c:529
+ #6  0xb7c72fad in cron_main_method (ctx=0x8099438) at cron.c:569
+ #7  0xb7de9383 in start_thread () from /lib/libpthread.so.0
+ #8  0xb7d6d73e in clone () from /lib/libc.so.6
+  Analysis shows that "prev->next" was set to rl in the previous
+  iteration in #1.  "prev" was not zero'ed out.  table[index] points
+  to a valid entry, and table[index]->next is NULL at the time of the
+  crash.
+
+ 
 - test RPC code (write a small demo)
 
 Hostlist for network testing:





reply via email to

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