gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r6415 - in GNUnet/src: applications/chat applications/datas


From: gnunet
Subject: [GNUnet-SVN] r6415 - in GNUnet/src: applications/chat applications/datastore applications/fs applications/fs/gap applications/fs/tools applications/rpc applications/stats include transports
Date: Fri, 22 Feb 2008 20:35:38 -0700 (MST)

Author: grothoff
Date: 2008-02-22 20:35:38 -0700 (Fri, 22 Feb 2008)
New Revision: 6415

Modified:
   GNUnet/src/applications/chat/chat.c
   GNUnet/src/applications/chat/chat.h
   GNUnet/src/applications/chat/clientapi.c
   GNUnet/src/applications/datastore/datastore.c
   GNUnet/src/applications/fs/ecrs_core.c
   GNUnet/src/applications/fs/gap/gap.c
   GNUnet/src/applications/fs/gap/migration.c
   GNUnet/src/applications/fs/tools/gnunet-auto-share.c
   GNUnet/src/applications/rpc/rpc.c
   GNUnet/src/applications/stats/sqstats.c
   GNUnet/src/include/gnunet_protocols.h
   GNUnet/src/transports/common.c
Log:
code cleanup and improving migration choices

Modified: GNUnet/src/applications/chat/chat.c
===================================================================
--- GNUnet/src/applications/chat/chat.c 2008-02-22 19:48:54 UTC (rev 6414)
+++ GNUnet/src/applications/chat/chat.c 2008-02-23 03:35:38 UTC (rev 6415)
@@ -52,7 +52,7 @@
 
 };
 
-static struct GNUNET_CS_chat_client * client_list_head;
+static struct GNUNET_CS_chat_client *client_list_head;
 
 static int
 csHandleChatMSG (struct GNUNET_ClientHandle *client,
@@ -77,7 +77,7 @@
   cmsg = (CS_chat_MESSAGE *) message;
   if (ntohs (cmsg->header.size) < sizeof (CS_chat_MESSAGE))
     {
-      GNUNET_GE_BREAK(NULL, 0);
+      GNUNET_GE_BREAK (NULL, 0);
       return GNUNET_SYSERR;     /* invalid message */
     }
 
@@ -141,7 +141,7 @@
 
 static int
 csHandleChatJoinRequest (struct GNUNET_ClientHandle *client,
-                     const GNUNET_MessageHeader * message)
+                         const GNUNET_MessageHeader * message)
 {
   const CS_chat_JOIN_MESSAGE *cmsg;
   P2P_chat_MESSAGE *pmsg;
@@ -164,7 +164,7 @@
 
   if (ntohs (cmsg->header.size) < sizeof (CS_chat_JOIN_MESSAGE))
     {
-      GNUNET_GE_BREAK(NULL, 0);
+      GNUNET_GE_BREAK (NULL, 0);
       return GNUNET_SYSERR;     /* invalid message */
     }
 
@@ -196,21 +196,20 @@
   /*TODO: create client context on the server, very simple as of now */
 #if EXTRA_CHECKS
   tempClient = client_list;
-  while ( (tempClient->client != client) &&
-         (tempClient != NULL) )
+  while ((tempClient->client != client) && (tempClient != NULL))
     tempClient = tempClient->next;
   if (tempClient != NULL)
     {
-      GNUNET_GE_BREAK(NULL, 0);
+      GNUNET_GE_BREAK (NULL, 0);
       GNUNET_free (nick);
       GNUNET_free (client_key);
       GNUNET_free (room_name);
       GNUNET_mutex_unlock (chatMutex);
-      return GNUNET_SYSERR;      
+      return GNUNET_SYSERR;
     }
 #endif
   tempClient = GNUNET_malloc (sizeof (struct GNUNET_CS_chat_client));
-  memset(tempClient, 0, sizeof (struct GNUNET_CS_chat_client));
+  memset (tempClient, 0, sizeof (struct GNUNET_CS_chat_client));
   tempClient->next = client_list_head;
   if (client_list_head != NULL)
     client_list_head->prev = tempClient;
@@ -274,9 +273,9 @@
 {
   int tempCount;
 
-       struct GNUNET_CS_chat_client * tempClient;
-  struct GNUNET_CS_chat_client * pos;
-  struct GNUNET_CS_chat_client * prev;
+  struct GNUNET_CS_chat_client *tempClient;
+  struct GNUNET_CS_chat_client *pos;
+  struct GNUNET_CS_chat_client *prev;
 
   /*client_key = GNUNET_malloc (sizeof (GNUNET_RSA_PublicKey));
      memcpy (client_key, &cmsg->nick[nick_len], pubkey_len); */
@@ -291,20 +290,20 @@
   /*TODO: delete client context on the server */
   pos = client_list_head;
   prev = NULL;
-  while ( (pos != NULL) && (pos->client != client) )
-       {
+  while ((pos != NULL) && (pos->client != client))
+    {
       prev = pos;
       pos = pos->next;
     }
   if (pos != NULL)
-       {
+    {
       if (prev == NULL)
-       client_list_head = pos->next;
+        client_list_head = pos->next;
       else
-       prev->next = pos->next;
+        prev->next = pos->next;
       if (pos->next != NULL)
-       pos->next->prev = pos->prev;
-      GNUNET_free(pos);
+        pos->next->prev = pos->prev;
+      GNUNET_free (pos);
     }
   /*Count the number of current clients, will be removed */
 
@@ -332,7 +331,7 @@
   GNUNET_GE_ASSERT (ectx,
                     sizeof (P2P_chat_MESSAGE) == sizeof (CS_chat_MESSAGE));
   chatMutex = GNUNET_mutex_create (GNUNET_NO);
-  
+
   coreAPI = capi;
   GNUNET_GE_LOG (ectx, GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_USER,
                  _("`%s' registering handlers %d and %d\n"),

Modified: GNUnet/src/applications/chat/chat.h
===================================================================
--- GNUnet/src/applications/chat/chat.h 2008-02-22 19:48:54 UTC (rev 6414)
+++ GNUnet/src/applications/chat/chat.h 2008-02-23 03:35:38 UTC (rev 6415)
@@ -87,15 +87,15 @@
   char *memberInfo;
 
   GNUNET_CHAT_MessageCallback callback;
-  
+
   int shutdown_flag;
 
   void *callback_cls;
 
 };
 
-int  GNUNET_CHAT_rejoin_room (struct GNUNET_CHAT_Room *chat_room);
-                       
+int GNUNET_CHAT_rejoin_room (struct GNUNET_CHAT_Room *chat_room);
+
 #endif
 
 /* end of chat.h */

Modified: GNUnet/src/applications/chat/clientapi.c
===================================================================
--- GNUnet/src/applications/chat/clientapi.c    2008-02-22 19:48:54 UTC (rev 
6414)
+++ GNUnet/src/applications/chat/clientapi.c    2008-02-23 03:35:38 UTC (rev 
6415)
@@ -54,70 +54,73 @@
   int disconnected;
 
   ret = GNUNET_OK;
-       disconnected = GNUNET_NO;
+  disconnected = GNUNET_NO;
   while (room->shutdown_flag != GNUNET_YES)
-  {
-       if (disconnected)
-               {
-                       GNUNET_thread_sleep(15 * GNUNET_CRON_SECONDS);
-                       if (GNUNET_client_connection_ensure_connected 
(room->sock) == GNUNET_OK)
-           {
-             /* send join! */
-             disconnected = GNUNET_NO;
-             GNUNET_CHAT_rejoin_room(room);
-             continue;
-           }
-           else
-             break;
-               }
-               
-               fprintf(stderr,"polling\n");
-    reply = NULL;
+    {
+      if (disconnected)
+        {
+          GNUNET_thread_sleep (15 * GNUNET_CRON_SECONDS);
+          if (GNUNET_client_connection_ensure_connected (room->sock) ==
+              GNUNET_OK)
+            {
+              /* send join! */
+              disconnected = GNUNET_NO;
+              GNUNET_CHAT_rejoin_room (room);
+              continue;
+            }
+          else
+            break;
+        }
 
-    if (GNUNET_OK != GNUNET_client_connection_read (room->sock, &reply))
-               {
-                 disconnected = GNUNET_YES;
-                 continue;
-               }
+      fprintf (stderr, "polling\n");
+      reply = NULL;
 
-    if ((reply->size <
-         ntohs (sizeof (GNUNET_MessageHeader) + sizeof (CS_chat_MESSAGE)))
-        || (reply->type != ntohs (GNUNET_CS_PROTO_CHAT_MSG)))
-               {
-                 GNUNET_GE_BREAK(NULL, 0);
-                 GNUNET_client_connection_close_temporarily(room->sock);
-                 disconnected = GNUNET_YES;
-                 continue;
-               }
+      if (GNUNET_OK != GNUNET_client_connection_read (room->sock, &reply))
+        {
+          disconnected = GNUNET_YES;
+          continue;
+        }
 
-    size = ntohs (reply->size);
+      if ((reply->size <
+           ntohs (sizeof (GNUNET_MessageHeader) + sizeof (CS_chat_MESSAGE)))
+          || (reply->type != ntohs (GNUNET_CS_PROTO_CHAT_MSG)))
+        {
+          GNUNET_GE_BREAK (NULL, 0);
+          GNUNET_client_connection_close_temporarily (room->sock);
+          disconnected = GNUNET_YES;
+          continue;
+        }
 
-    received_msg = (CS_chat_MESSAGE *) reply;
+      size = ntohs (reply->size);
 
-    nick_len = ntohl (received_msg->nick_len);
-    msg_len = ntohl (received_msg->msg_len);
-    /* NO NEED TO SEND ROOM! */
-    room_name_len = ntohl (received_msg->room_name_len);
+      received_msg = (CS_chat_MESSAGE *) reply;
 
-    nick = GNUNET_malloc (nick_len + 1);
-    message_content = GNUNET_malloc (msg_len + 1);
-    room_name = GNUNET_malloc (room_name_len + 1);
+      nick_len = ntohl (received_msg->nick_len);
+      msg_len = ntohl (received_msg->msg_len);
+      /* NO NEED TO SEND ROOM! */
+      room_name_len = ntohl (received_msg->room_name_len);
 
-    /* BUFFER OVERFLOWS! */
-    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 = GNUNET_malloc (nick_len + 1);
+      message_content = GNUNET_malloc (msg_len + 1);
+      room_name = GNUNET_malloc (room_name_len + 1);
 
-    nick[nick_len] = '\0';
-    message_content[msg_len] = '\0';
-    room_name[room_name_len] = '\0';
+      /* BUFFER OVERFLOWS! */
+      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);
 
-    if (GNUNET_OK != room->callback (room->callback_cls, room, nick, 
message_content,GNUNET_get_time (), 0))
-    {
-      ret = GNUNET_SYSERR;
+      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 NULL;
 }
 
@@ -204,7 +207,7 @@
     {
       /* ALREADY LOGGED */
       fprintf (stderr, _("Error writing to socket.\n"));
-      GNUNET_free(join_msg);
+      GNUNET_free (join_msg);
       return NULL;
     }
 
@@ -251,8 +254,10 @@
   csHdr.size = htons (sizeof (CS_chat_JOIN_MESSAGE));
   csHdr.type = htons (GNUNET_CS_PROTO_CHAT_JOIN_MSG);
 
-  GNUNET_hash (chat_room->my_public_key, sizeof (GNUNET_RSA_PublicKey), 
&hash_of_me);
-  GNUNET_hash (chat_room->room_name, strlen (chat_room->room_name), 
&hash_of_room_name);
+  GNUNET_hash (chat_room->my_public_key, sizeof (GNUNET_RSA_PublicKey),
+               &hash_of_me);
+  GNUNET_hash (chat_room->room_name, strlen (chat_room->room_name),
+               &hash_of_room_name);
 
   size_of_join =
     sizeof (CS_chat_JOIN_MESSAGE) + strlen (chat_room->nickname) +
@@ -264,10 +269,12 @@
   join_msg->room_name_len = htonl (strlen (chat_room->room_name));
 
 
-  memcpy (&join_msg->nick[0], chat_room->nickname, strlen 
(chat_room->nickname));
-  memcpy (&join_msg->nick[strlen (chat_room->nickname)], 
chat_room->my_public_key,
-          sizeof (GNUNET_RSA_PublicKey));
-  memcpy (&join_msg->nick[strlen (chat_room->nickname) + sizeof 
(GNUNET_RSA_PublicKey)],
+  memcpy (&join_msg->nick[0], chat_room->nickname,
+          strlen (chat_room->nickname));
+  memcpy (&join_msg->nick[strlen (chat_room->nickname)],
+          chat_room->my_public_key, sizeof (GNUNET_RSA_PublicKey));
+  memcpy (&join_msg->
+          nick[strlen (chat_room->nickname) + sizeof (GNUNET_RSA_PublicKey)],
           chat_room->room_name, strlen (chat_room->room_name));
 
   join_msg->header = csHdr;
@@ -276,11 +283,11 @@
   if (GNUNET_SYSERR ==
       GNUNET_client_connection_write (chat_room->sock, &join_msg->header))
     {
-      GNUNET_free(join_msg);
+      GNUNET_free (join_msg);
       return GNUNET_SYSERR;
     }
 
-  GNUNET_free (join_msg);  
+  GNUNET_free (join_msg);
   return GNUNET_OK;
 }
 
@@ -290,11 +297,11 @@
 void
 GNUNET_CHAT_leave_room (struct GNUNET_CHAT_Room *chat_room)
 {
-  void * unused;
+  void *unused;
   chat_room->shutdown_flag = GNUNET_YES;
   GNUNET_client_connection_close_forever (chat_room->sock);
-  GNUNET_thread_stop_sleep(chat_room->listen_thread);
-  GNUNET_thread_join(chat_room->listen_thread, &unused);
+  GNUNET_thread_stop_sleep (chat_room->listen_thread);
+  GNUNET_thread_join (chat_room->listen_thread, &unused);
   GNUNET_free (chat_room->nickname);
   GNUNET_free (chat_room->memberInfo);
   GNUNET_client_connection_destroy (chat_room->sock);

Modified: GNUnet/src/applications/datastore/datastore.c
===================================================================
--- GNUnet/src/applications/datastore/datastore.c       2008-02-22 19:48:54 UTC 
(rev 6414)
+++ GNUnet/src/applications/datastore/datastore.c       2008-02-23 03:35:38 UTC 
(rev 6415)
@@ -249,25 +249,22 @@
   cls.value = value;
   GNUNET_hash (&value[1],
                ntohl (value->size) - sizeof (GNUNET_DatastoreValue), &vhc);
-  GNUNET_mutex_lock(lock);
+  GNUNET_mutex_lock (lock);
   sq->get (key, &vhc, ntohl (value->type), &checkExists, &cls);
   if ((!cls.exists) && (ntohl (value->type) == GNUNET_ECRS_BLOCKTYPE_DATA))
     sq->get (key, &vhc, GNUNET_ECRS_BLOCKTYPE_ONDEMAND, &checkExists, &cls);
-  if ((!cls.exists) && (ntohl (value->type) == GNUNET_ECRS_BLOCKTYPE_DATA))
-    sq->get (key, &vhc, GNUNET_ECRS_BLOCKTYPE_ONDEMAND_OLD, &checkExists,
-             &cls);
   if (cls.exists)
     {
       if ((ntohl (value->prio) == 0) &&
           (GNUNET_ntohll (value->expirationTime) <= cls.expiration))
         {
-         GNUNET_mutex_unlock(lock);
-         return GNUNET_OK;
+          GNUNET_mutex_unlock (lock);
+          return GNUNET_OK;
         }
       /* update prio */
       sq->update (cls.uid,
                   ntohl (value->prio), GNUNET_ntohll (value->expirationTime));
-      GNUNET_mutex_unlock(lock);
+      GNUNET_mutex_unlock (lock);
       return GNUNET_OK;
     }
   comp_prio = comp_priority ();
@@ -282,9 +279,9 @@
   if ((available < ntohl (value->size)) &&
       (minPriority > ntohl (value->prio) + comp_prio))
     {
-      GNUNET_mutex_unlock(lock);
-      return GNUNET_NO;           /* new content has such a low priority that
-                                    we should not even bother! */
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_NO;         /* new content has such a low priority that
+                                   we should not even bother! */
     }
   if (ntohl (value->prio) + comp_prio < minPriority)
     minPriority = ntohl (value->prio) + comp_prio;
@@ -300,7 +297,7 @@
       makeAvailable (key);
       available -= ntohl (value->size);
     }
-  GNUNET_mutex_unlock(lock);
+  GNUNET_mutex_unlock (lock);
   return ok;
 }
 
@@ -436,7 +433,7 @@
         }
       return NULL;
     }
-  lock = GNUNET_mutex_create(GNUNET_NO);
+  lock = GNUNET_mutex_create (GNUNET_NO);
   fsdir = NULL;
   GNUNET_GC_get_configuration_value_filename (capi->cfg,
                                               "FS",
@@ -484,7 +481,7 @@
       coreAPI->release_service (stats);
       stats = NULL;
     }
-  GNUNET_mutex_destroy(lock);
+  GNUNET_mutex_destroy (lock);
   sq = NULL;
   coreAPI = NULL;
 }

Modified: GNUnet/src/applications/fs/ecrs_core.c
===================================================================
--- GNUnet/src/applications/fs/ecrs_core.c      2008-02-22 19:48:54 UTC (rev 
6414)
+++ GNUnet/src/applications/fs/ecrs_core.c      2008-02-23 03:35:38 UTC (rev 
6415)
@@ -256,7 +256,6 @@
         return GNUNET_OK;
       }
     case GNUNET_ECRS_BLOCKTYPE_ONDEMAND:
-    case GNUNET_ECRS_BLOCKTYPE_ONDEMAND_OLD:
       {
         GNUNET_GE_BREAK (NULL, 0);      /* should never be used here! */
         return GNUNET_SYSERR;

Modified: GNUnet/src/applications/fs/gap/gap.c
===================================================================
--- GNUnet/src/applications/fs/gap/gap.c        2008-02-22 19:48:54 UTC (rev 
6414)
+++ GNUnet/src/applications/fs/gap/gap.c        2008-02-23 03:35:38 UTC (rev 
6415)
@@ -424,6 +424,7 @@
   unsigned int index;
   PID_INDEX blocked[MAX_ENTRIES_PER_SLOT + 1];
   unsigned int block_count;
+  int was_new;
 
   value = 0;
   GNUNET_mutex_lock (GNUNET_FS_lock);
@@ -440,6 +441,7 @@
     {
       block_count = 0;
     }
+  was_new = GNUNET_NO;
   while (rl != NULL)
     {
       if (GNUNET_OK == GNUNET_FS_SHARED_test_valid_new_response (rl,
@@ -447,6 +449,7 @@
                                                                  size,
                                                                  data, &hc))
         {
+         was_new = GNUNET_YES;
           GNUNET_GE_ASSERT (NULL, rl->response_target != 0);
           GNUNET_FS_PT_resolve (rl->response_target, &target);
           GNUNET_GE_ASSERT (NULL, block_count <= MAX_ENTRIES_PER_SLOT);
@@ -485,8 +488,9 @@
       prev = rl;
       rl = rl->next;
     }
-  GNUNET_FS_MIGRATION_inject (primary_query,
-                              size, data, expiration, block_count, blocked);
+  if (was_new == GNUNET_YES)
+    GNUNET_FS_MIGRATION_inject (primary_query,
+                               size, data, expiration, block_count, blocked);
   GNUNET_mutex_unlock (GNUNET_FS_lock);
   GNUNET_FS_PT_change_rc (rid, -1);
   return value;

Modified: GNUnet/src/applications/fs/gap/migration.c
===================================================================
--- GNUnet/src/applications/fs/gap/migration.c  2008-02-22 19:48:54 UTC (rev 
6414)
+++ GNUnet/src/applications/fs/gap/migration.c  2008-02-23 03:35:38 UTC (rev 
6415)
@@ -71,6 +71,8 @@
 
 static int stat_migration_factor;
 
+static int stat_migration_injected;
+
 static int stat_on_demand_migration_attempts;
 
 /**
@@ -127,6 +129,7 @@
   int match;
   unsigned int dist;
   unsigned int minDist;
+  struct MigrationRecord *rec;
 
   if (content_size == 0)
     return 0;
@@ -139,15 +142,15 @@
   minDist = -1;                 /* max */
   for (i = 0; i < content_size; i++)
     {
-      if (content[i].value == NULL)
+      rec = &content[i];
+      if (rec->value == NULL)
         {
           if (discard_time >= now - MAX_POLL_FREQUENCY)
             continue;
           discard_time = now;
-          if (GNUNET_OK !=
-              datastore->getRandom (&content[i].key, &content[i].value))
+          if (GNUNET_OK != datastore->getRandom (&rec->key, &rec->value))
             {
-              content[i].value = NULL;  /* just to be sure... */
+              rec->value = NULL;        /* just to be sure... */
               continue;
             }
           else
@@ -157,14 +160,13 @@
             }
         }
       match = 1;
-      if (ntohl (content[i].value->size) + sizeof (P2P_gap_reply_MESSAGE) -
+      if (ntohl (rec->value->size) + sizeof (P2P_gap_reply_MESSAGE) -
           sizeof (GNUNET_DatastoreValue) <= padding)
         {
           match = 0;
-          for (j = 0; j < content[i].sentCount; j++)
-
+          for (j = 0; j < rec->sentCount; j++)
             {
-              if (content[i].receiverIndices[j] == index)
+              if (rec->receiverIndices[j] == index)
                 {
                   match = 1;
                   break;
@@ -173,8 +175,7 @@
         }
       if (match == 0)
         {
-          dist =
-            GNUNET_hash_distance_u32 (&content[i].key, &receiver->hashPubKey);
+          dist = GNUNET_hash_distance_u32 (&rec->key, &receiver->hashPubKey);
           if (dist <= minDist)
             {
               entry = i;
@@ -184,9 +185,9 @@
         }
       else
         {
-          if ((content[i].sentCount > discard_match) || (discard_match == -1))
+          if ((rec->sentCount > discard_match) || (discard_match == -1))
             {
-              discard_match = content[i].sentCount;
+              discard_match = rec->sentCount;
               discard_entry = i;
             }
         }
@@ -195,16 +196,15 @@
       (discard_match > MAX_RECEIVERS / 2) &&
       (discard_time < now - MAX_POLL_FREQUENCY))
     {
+      rec = &content[discard_entry];
       discard_time = now;
-      GNUNET_free_non_null (content[discard_entry].value);
-      content[discard_entry].value = NULL;
-      GNUNET_FS_PT_decrement_rcs (content[discard_entry].receiverIndices,
-                                  content[discard_entry].sentCount);
-      content[discard_entry].sentCount = 0;
-      if (GNUNET_OK != datastore->getRandom (&content[discard_entry].key,
-                                             &content[discard_entry].value))
+      GNUNET_free_non_null (rec->value);
+      rec->value = NULL;
+      GNUNET_FS_PT_decrement_rcs (rec->receiverIndices, rec->sentCount);
+      rec->sentCount = 0;
+      if (GNUNET_OK != datastore->getRandom (&rec->key, &rec->value))
         {
-          content[discard_entry].value = NULL;  /* just to be sure... */
+          rec->value = NULL;    /* just to be sure... */
           discard_entry = -1;
         }
       else
@@ -226,7 +226,8 @@
       GNUNET_FS_PT_change_rc (index, -1);
       return 0;
     }
-  value = content[entry].value;
+  rec = &content[entry];
+  value = rec->value;
   if (value == NULL)
     {
       GNUNET_GE_ASSERT (NULL, 0);
@@ -255,22 +256,13 @@
                  "Migration: random lookup in datastore returned type %d.\n",
                  ntohl (value->type));
 #endif
-  if (ntohl (value->type) == GNUNET_ECRS_BLOCKTYPE_ONDEMAND_OLD)
-    {
-      datastore->del (&content[entry].key, value);
-      GNUNET_free_non_null (value);
-      content[entry].value = NULL;
-      GNUNET_mutex_unlock (GNUNET_FS_lock);
-      GNUNET_FS_PT_change_rc (index, -1);
-      return 0;
-    }
   if (ntohl (value->type) == GNUNET_ECRS_BLOCKTYPE_ONDEMAND)
     {
       if (GNUNET_FS_ONDEMAND_get_indexed_content
-          (value, &content[entry].key, &enc) != GNUNET_OK)
+          (value, &rec->key, &enc) != GNUNET_OK)
         {
           GNUNET_free_non_null (value);
-          content[entry].value = NULL;
+          rec->value = NULL;
           GNUNET_mutex_unlock (GNUNET_FS_lock);
 #if DEBUG_MIGRATION
           GNUNET_GE_LOG (ectx,
@@ -282,7 +274,7 @@
         }
       if (stats != NULL)
         stats->change (stat_on_demand_migration_attempts, 1);
-      content[entry].value = enc;
+      rec->value = enc;
       GNUNET_free (value);
       value = enc;
     }
@@ -320,17 +312,16 @@
       msg->expiration = GNUNET_htonll (et);
       memcpy (&msg[1], &value[1], size - sizeof (P2P_gap_reply_MESSAGE));
       ret = size;
-      if (content[entry].sentCount == MAX_RECEIVERS)
+      if (rec->sentCount == MAX_RECEIVERS)
         {
-          GNUNET_free (content[entry].value);
-          content[entry].value = NULL;
-          GNUNET_FS_PT_decrement_rcs (content[entry].receiverIndices,
-                                      content[entry].sentCount);
-          content[entry].sentCount = 0;
+          GNUNET_free (rec->value);
+          rec->value = NULL;
+          GNUNET_FS_PT_decrement_rcs (rec->receiverIndices, rec->sentCount);
+          rec->sentCount = 0;
         }
       else
         {
-          content[entry].receiverIndices[content[entry].sentCount++] = index;
+          rec->receiverIndices[rec->sentCount++] = index;
           GNUNET_FS_PT_change_rc (index, 1);
         }
     }
@@ -401,6 +392,8 @@
       GNUNET_mutex_unlock (GNUNET_FS_lock);
       return;
     }
+  if (stats != NULL)
+    stats->change (stat_migration_injected, 1);
   record = &content[discard_entry];
   GNUNET_free_non_null (record->value);
   record->value = NULL;
@@ -440,6 +433,8 @@
     {
       stat_migration_count
         = stats->create (gettext_noop ("# blocks migrated"));
+      stat_migration_injected
+        = stats->create (gettext_noop ("# blocks injected for migration"));
       stat_migration_factor
         = stats->create (gettext_noop ("# blocks fetched for migration"));
       stat_on_demand_migration_attempts

Modified: GNUnet/src/applications/fs/tools/gnunet-auto-share.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-auto-share.c        2008-02-22 
19:48:54 UTC (rev 6414)
+++ GNUnet/src/applications/fs/tools/gnunet-auto-share.c        2008-02-23 
03:35:38 UTC (rev 6415)
@@ -201,10 +201,10 @@
       rec->next = records;
       records = rec;
       if (GNUNET_NO == GNUNET_FS_test_indexed (sock, &rec->hc))
-       {
-         *run = 1;
-         return GNUNET_SYSERR;
-       }
+        {
+          *run = 1;
+          return GNUNET_SYSERR;
+        }
     }
   else
     {
@@ -380,7 +380,7 @@
     GNUNET_GC_parse_configuration (meta_cfg, metafn);
   if (GNUNET_NO == debug_flag)
     GNUNET_terminal_detach_complete (ectx, filedes, GNUNET_YES);
-  GNUNET_free(metafn);
+  GNUNET_free (metafn);
   /* fundamental init */
   ctx = GNUNET_FSUI_start (ectx, cfg, "gnunet-auto-share", GNUNET_NO, 32,
                            &printstatus, &verbose);

Modified: GNUnet/src/applications/rpc/rpc.c
===================================================================
--- GNUnet/src/applications/rpc/rpc.c   2008-02-22 19:48:54 UTC (rev 6414)
+++ GNUnet/src/applications/rpc/rpc.c   2008-02-23 03:35:38 UTC (rev 6415)
@@ -385,8 +385,8 @@
             prev->next = pos->next;
           GNUNET_free (pos->name);
           GNUNET_free (pos);
-         GNUNET_mutex_unlock (lock);
-         return GNUNET_OK;
+          GNUNET_mutex_unlock (lock);
+          return GNUNET_OK;
         }
       prev = pos;
       pos = pos->next;
@@ -507,7 +507,8 @@
     ret->functionNameLength = htonl (errorCode);
   else
     ret->functionNameLength = htonl (slen);
-  ret->argumentCount = htonl ((values == NULL) ? 0 : 
GNUNET_RPC_parameters_count (values));
+  ret->argumentCount =
+    htonl ((values == NULL) ? 0 : GNUNET_RPC_parameters_count (values));
   if (name != NULL)
     memcpy (&ret[1], name, slen);
   GNUNET_RPC_parameters_serialize (values, &((char *) &ret[1])[slen]);

Modified: GNUnet/src/applications/stats/sqstats.c
===================================================================
--- GNUnet/src/applications/stats/sqstats.c     2008-02-22 19:48:54 UTC (rev 
6414)
+++ GNUnet/src/applications/stats/sqstats.c     2008-02-23 03:35:38 UTC (rev 
6415)
@@ -79,7 +79,6 @@
       data->stat_block[5]++;
       break;
     case GNUNET_ECRS_BLOCKTYPE_ONDEMAND:
-    case GNUNET_ECRS_BLOCKTYPE_ONDEMAND_OLD:
       data->stat_block[6]++;
       break;
     default:

Modified: GNUnet/src/include/gnunet_protocols.h
===================================================================
--- GNUnet/src/include/gnunet_protocols.h       2008-02-22 19:48:54 UTC (rev 
6414)
+++ GNUnet/src/include/gnunet_protocols.h       2008-02-23 03:35:38 UTC (rev 
6415)
@@ -456,12 +456,7 @@
  */
 #define GNUNET_ECRS_BLOCKTYPE_RESERVED 0xFFFFFFFE
 
-/**
- * Type of OLD OnDemand encoded blocks.
- */
-#define GNUNET_ECRS_BLOCKTYPE_ONDEMAND_OLD 0xFFFFFFFF
 
-
 /* ************* priorities for poll-content ************ */
 
 /* note that the absolute values do not matter;

Modified: GNUnet/src/transports/common.c
===================================================================
--- GNUnet/src/transports/common.c      2008-02-22 19:48:54 UTC (rev 6414)
+++ GNUnet/src/transports/common.c      2008-02-23 03:35:38 UTC (rev 6415)
@@ -380,21 +380,16 @@
       if (0 != memcmp (&haddr->ipv4,
                        &last_addrv4, sizeof (GNUNET_IPv4Address)))
         {
-         struct in_addr in4;
-         char dst[INET_ADDRSTRLEN];
-         
-         memcpy(&in4,
-                &haddr->ipv4,
-                sizeof(struct in_addr));
+          struct in_addr in4;
+          char dst[INET_ADDRSTRLEN];
+
+          memcpy (&in4, &haddr->ipv4, sizeof (struct in_addr));
           GNUNET_GE_LOG (coreAPI->ectx,
                          GNUNET_GE_DEBUG | GNUNET_GE_USER | GNUNET_GE_BULK,
                          "%s uses %s address %s.\n",
                          MY_TRANSPORT_NAME,
-                        "IPv4",
-                        inet_ntop(AF_INET,
-                                  &in4,
-                                  dst,
-                                  INET_ADDRSTRLEN));
+                         "IPv4",
+                         inet_ntop (AF_INET, &in4, dst, INET_ADDRSTRLEN));
           last_addrv4 = haddr->ipv4;
         }
       available |= VERSION_AVAILABLE_IPV4;
@@ -406,21 +401,16 @@
       if (0 != memcmp (&haddr->ipv6,
                        &last_addrv6, sizeof (GNUNET_IPv6Address)))
         {
-         struct in6_addr in6;
-         char dst[INET6_ADDRSTRLEN];
-         
-         memcpy(&in6,
-                &haddr->ipv6,
-                sizeof(struct in6_addr));
+          struct in6_addr in6;
+          char dst[INET6_ADDRSTRLEN];
+
+          memcpy (&in6, &haddr->ipv6, sizeof (struct in6_addr));
           GNUNET_GE_LOG (coreAPI->ectx,
                          GNUNET_GE_DEBUG | GNUNET_GE_USER | GNUNET_GE_BULK,
                          "%s uses %s address %s.\n",
                          MY_TRANSPORT_NAME,
-                        "IPv6",
-                        inet_ntop(AF_INET6,
-                                  &in6,
-                                  dst,
-                                  INET6_ADDRSTRLEN));
+                         "IPv6",
+                         inet_ntop (AF_INET6, &in6, dst, INET6_ADDRSTRLEN));
           last_addrv6 = haddr->ipv6;
         }
       available |= VERSION_AVAILABLE_IPV6;





reply via email to

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