[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r2006 - in GNUnet/src/applications: sqstore_mysql sqstore_s
From: |
durner |
Subject: |
[GNUnet-SVN] r2006 - in GNUnet/src/applications: sqstore_mysql sqstore_sqlite |
Date: |
Sun, 28 Aug 2005 11:13:03 -0700 (PDT) |
Author: durner
Date: 2005-08-28 11:12:59 -0700 (Sun, 28 Aug 2005)
New Revision: 2006
Modified:
GNUnet/src/applications/sqstore_mysql/mysql.c
GNUnet/src/applications/sqstore_sqlite/sqlite.c
Log:
fix statistics
Modified: GNUnet/src/applications/sqstore_mysql/mysql.c
===================================================================
--- GNUnet/src/applications/sqstore_mysql/mysql.c 2005-08-28 14:32:20 UTC
(rev 2005)
+++ GNUnet/src/applications/sqstore_mysql/mysql.c 2005-08-28 18:12:59 UTC
(rev 2006)
@@ -136,6 +136,7 @@
#include "platform.h"
#include "gnunet_util.h"
#include "gnunet_sqstore_service.h"
+#include "gnunet_stats_service.h"
#include <mysql/mysql.h>
#define DEBUG_MYSQL NO
@@ -155,6 +156,9 @@
*/
#define LOG_MYSQL(level, cmd, dbh) do { LOG(level, _("`%s' failed at %s:%d
with error: %s\n"), cmd, __FILE__, __LINE__, mysql_error((dbh)->dbf)); }
while(0);
+static Stats_ServiceAPI * stats;
+static CoreAPIForApplication * coreAPI;
+static unsigned int stat_size;
@@ -1135,6 +1139,10 @@
MUTEX_UNLOCK(&dbh->DATABASE_Lock_);
bytesUsed = rowsInTable * avgRowLen;
+
+ if (stats)
+ stats->set(stat_size, bytesUsed);
+
return bytesUsed;
}
@@ -1161,6 +1169,12 @@
size_t nX;
char *home_dir;
+ coreAPI = capi;
+ stats = coreAPI->requestService("stats");
+ if (stats)
+ stat_size
+ = stats->create(gettext_noop("# Bytes in datastore"));
+
/* verify that .my.cnf can be found */
#ifndef WINDOWS
pw = getpwuid(getuid());
@@ -1290,6 +1304,9 @@
FREE(dbh->cnffile);
FREE(dbh);
dbh = NULL;
+
+ if (stats != NULL)
+ coreAPI->releaseService(stats);
}
/* end of mysql.c */
Modified: GNUnet/src/applications/sqstore_sqlite/sqlite.c
===================================================================
--- GNUnet/src/applications/sqstore_sqlite/sqlite.c 2005-08-28 14:32:20 UTC
(rev 2005)
+++ GNUnet/src/applications/sqstore_sqlite/sqlite.c 2005-08-28 18:12:59 UTC
(rev 2006)
@@ -117,7 +117,7 @@
MUTEX_LOCK(&dbh->DATABASE_Lock_);
ret = dbh->payload;
if (stats)
- stats->change(stat_size, ret);
+ stats->set(stat_size, ret);
MUTEX_UNLOCK(&dbh->DATABASE_Lock_);
return ret;
}
@@ -656,7 +656,7 @@
dbh->lastSync++;
/* row length = hash length + block length + numbers + column count +
estimated index size + 1 */
dbh->payload = dbh->payload + contentSize + sizeof(HashCode512) +
getIntSize(size) + getIntSize(type) +
- getIntSize(prio) + getIntSize(anon) + getIntSize(expir) + 7 + 90 + 1;
+ getIntSize(prio) + getIntSize(anon) + getIntSize(expir) + 7 + 245 + 1;
MUTEX_UNLOCK(&dbh->DATABASE_Lock_);
#if DEBUG_SQLITE
@@ -708,7 +708,7 @@
rowLen = sqlite3_column_int(dbh->exists, 0) +
sqlite3_column_int(dbh->exists, 1) +
sqlite3_column_int(dbh->exists, 2) + sqlite3_column_int(dbh->exists, 3)
+
sqlite3_column_int(dbh->exists, 4) + sqlite3_column_int(dbh->exists, 5)
+
- sqlite3_column_int(dbh->exists, 6) + 7 + 90 + 1;
+ sqlite3_column_int(dbh->exists, 6) + 7 + 245 + 1;
if (dbh->payload > rowLen)
dbh->payload -= rowLen;
@@ -759,7 +759,7 @@
/* row length = hash length + block length + numbers + column count +
estimated index size + 1 */
dbh->payload = dbh->payload - sizeof(HashCode512) - contentSize
- getIntSize(size) - getIntSize(type) - getIntSize(prio)
- - getIntSize(anon) - getIntSize(expir) - 7 - 90 - 1;
+ - getIntSize(anon) - getIntSize(expir) - 7 - 245 - 1;
} else {
LOG_SQLITE(LOG_ERROR, "sqlite3_prepare");
}
@@ -960,7 +960,7 @@
stats = coreAPI->requestService("stats");
if (stats)
stat_size
- = stats->create(gettext_noop("# bytes in datastore"));
+ = stats->create(gettext_noop("# Bytes in datastore"));
api.getSize = &getSize;
api.put = &put;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r2006 - in GNUnet/src/applications: sqstore_mysql sqstore_sqlite,
durner <=