fix quota calculations
authorChristian Grothoff <christian@grothoff.org>
Tue, 18 May 2010 07:05:20 +0000 (07:05 +0000)
committerChristian Grothoff <christian@grothoff.org>
Tue, 18 May 2010 07:05:20 +0000 (07:05 +0000)
src/datastore/plugin_datastore_sqlite.c

index 1576cef00694e3ff5958d4ea4e87edddf85e58e2..6e20a74914d8606bcde938b51110475440e3ba1e 100644 (file)
@@ -1613,11 +1613,17 @@ process_stat_done (void *cls,
   struct Plugin *plugin = cls;
   sqlite3_stmt *stmt;
   uint64_t pages;
-  uint64_t free_pages;
+  uint64_t page_size;
 
   plugin->stat_get = NULL;
   if (plugin->stats_worked == GNUNET_NO)
     {
+      CHECK (SQLITE_OK ==
+            sq_prepare (plugin->dbh,
+                        "VACUUM;",
+                        &stmt));
+      sqlite3_step (stmt);
+      sqlite3_finalize (stmt);
       CHECK (SQLITE_OK ==
             sq_prepare (plugin->dbh,
                         "PRAGMA page_count",
@@ -1630,17 +1636,17 @@ process_stat_done (void *cls,
       sqlite3_finalize (stmt);
       CHECK (SQLITE_OK ==
             sq_prepare (plugin->dbh,
-                        "PRAGMA freelist_count",
+                        "PRAGMA page_size",
                         &stmt));
       CHECK (SQLITE_ROW ==
             sqlite3_step (stmt));
-      free_pages = sqlite3_column_int64 (stmt, 0);
+      page_size = sqlite3_column_int64 (stmt, 0);
       sqlite3_finalize (stmt);
       GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                 _("Using sqlite page utilization to estimate payload (%llu pages total, %llu free)\n"),
+                 _("Using sqlite page utilization to estimate payload (%llu pages of size %llu bytes)\n"),
                  (unsigned long long) pages,
-                 (unsigned long long) free_pages);
-      plugin->payload = (pages - free_pages) * 4092LL;
+                 (unsigned long long) page_size);
+      plugin->payload = pages * page_size;
     }
 }