[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r3630 - in GNUnet: . src/applications/sqstore_sqlite src/se
From: |
grothoff |
Subject: |
[GNUnet-SVN] r3630 - in GNUnet: . src/applications/sqstore_sqlite src/server |
Date: |
Fri, 3 Nov 2006 10:54:31 -0800 (PST) |
Author: grothoff
Date: 2006-11-03 10:54:27 -0800 (Fri, 03 Nov 2006)
New Revision: 3630
Modified:
GNUnet/src/applications/sqstore_sqlite/sqlite.c
GNUnet/src/server/startup.c
GNUnet/todo
Log:
create sqlite indices in gnunet-update
Modified: GNUnet/src/applications/sqstore_sqlite/sqlite.c
===================================================================
--- GNUnet/src/applications/sqstore_sqlite/sqlite.c 2006-11-03 17:42:45 UTC
(rev 3629)
+++ GNUnet/src/applications/sqstore_sqlite/sqlite.c 2006-11-03 18:54:27 UTC
(rev 3630)
@@ -132,10 +132,39 @@
(const char**) &dummy);
}
-// #define CHECK(a) GE_BREAK(ectx, a)
+#if 1
+#define CHECK(a) GE_BREAK(ectx, a)
+#define ENULL NULL
+#else
#define ENULL &e
+#define ENULL_DEFINED 1
#define CHECK(a) if (! a) { fprintf(stderr, "%s\n", e); sqlite3_free(e); }
+#endif
+static void createIndices(sqlite3 * dbh) {
+ /* create indices */
+ CHECK(SQLITE_OK ==
+ sqlite3_exec(dbh,
+ "CREATE INDEX idx_hash ON gn070 (hash)",
+ NULL, NULL, ENULL));
+ CHECK(SQLITE_OK ==
+ sqlite3_exec(dbh,
+ "CREATE INDEX idx_prio ON gn070 (prio)",
+ NULL, NULL, ENULL));
+ CHECK(SQLITE_OK ==
+ sqlite3_exec(dbh,
+ "CREATE INDEX idx_expire ON gn070 (expire)",
+ NULL, NULL, ENULL));
+ CHECK(SQLITE_OK ==
+ sqlite3_exec(dbh,
+ "CREATE INDEX idx_comb1 ON gn070 (prio,expire,hash)",
+ NULL, NULL, ENULL));
+ CHECK(SQLITE_OK ==
+ sqlite3_exec(dbh,
+ "CREATE INDEX idx_comb2 ON gn070 (expire,prio,hash)",
+ NULL, NULL, ENULL));
+}
+
/**
* @brief Get a database handle for this thread.
* @note SQLite handles may no be shared between threads - see
@@ -147,7 +176,9 @@
unsigned int idx;
sqliteHandle * ret;
sqlite3_stmt * stmt;
+#if ENULL_DEFINED
char * e;
+#endif
/* Is the DB already open? */
for (idx = 0; idx < db->handle_count; idx++)
@@ -202,27 +233,7 @@
FREE(ret);
return NULL;
}
- /* create indices */
- CHECK(SQLITE_OK ==
- sqlite3_exec(ret->dbh,
- "CREATE INDEX idx_hash ON gn070 (hash)",
- NULL, NULL, ENULL));
- CHECK(SQLITE_OK ==
- sqlite3_exec(ret->dbh,
- "CREATE INDEX idx_prio ON gn070 (prio)",
- NULL, NULL, ENULL));
- CHECK(SQLITE_OK ==
- sqlite3_exec(ret->dbh,
- "CREATE INDEX idx_expire ON gn070 (expire)",
- NULL, NULL, ENULL));
- CHECK(SQLITE_OK ==
- sqlite3_exec(ret->dbh,
- "CREATE INDEX idx_comb1 ON gn070 (prio,expire,hash)",
- NULL, NULL, ENULL));
- CHECK(SQLITE_OK ==
- sqlite3_exec(ret->dbh,
- "CREATE INDEX idx_comb2 ON gn070 (expire,prio,hash)",
- NULL, NULL, ENULL));
+ createIndices(ret->dbh);
}
sqlite3_finalize(stmt);
@@ -1136,7 +1147,8 @@
provide_module_sqstore_sqlite(CoreAPIForApplication * capi) {
static SQstore_ServiceAPI api;
- char *dir, *afsdir;
+ char *dir;
+ char *afsdir;
size_t nX;
sqliteHandle *dbh;
@@ -1226,6 +1238,65 @@
"SQLite: database shutdown\n");
#endif
coreAPI = NULL;
+ MUTEX_DESTROY(db->DATABASE_Lock_);
+ FREE(db->fn);
+ FREE(db);
+ db = NULL;
}
+
+
+/**
+ * Update sqlite database module.
+ *
+ * Currently only makes sure that the sqlite indices are created.
+ */
+void update_module_sqstore_sqlite(UpdateAPI * uapi) {
+ sqliteHandle *dbh;
+ char *dir;
+ char *afsdir;
+ size_t nX;
+
+ db = MALLOC(sizeof(sqliteDatabase));
+ memset(db,
+ 0,
+ sizeof(sqliteDatabase));
+ db->payload = 0;
+ db->lastSync = 0;
+ afsdir = NULL;
+ GC_get_configuration_value_filename(uapi->cfg,
+ "FS",
+ "DIR",
+ VAR_DAEMON_DIRECTORY "/data/fs/",
+ &afsdir);
+ dir = MALLOC(strlen(afsdir) + 8 + 2); /* 8 = "content/" */
+ strcpy(dir, afsdir);
+ strcat(dir, "/content/");
+ FREE(afsdir);
+ if (OK != disk_directory_create(ectx,
+ dir)) {
+ FREE(dir);
+ FREE(db);
+ return;
+ }
+ nX = strlen(dir) + 6 + 4 + 256; /* 6 = "gnunet", 4 = ".dat" */
+ db->fn = MALLOC(strlen(dir) + 6 + 4 + 256);
+ SNPRINTF(db->fn, nX, "%s/gnunet.dat", dir);
+ FREE(dir);
+ db->DATABASE_Lock_ = MUTEX_CREATE(NO);
+ dbh = getDBHandle();
+ if (dbh == NULL) {
+ MUTEX_DESTROY(db->DATABASE_Lock_);
+ FREE(db->fn);
+ FREE(db);
+ return;
+ }
+ createIndices(dbh->dbh);
+
+ MUTEX_DESTROY(db->DATABASE_Lock_);
+ FREE(db->fn);
+ FREE(db);
+ db = NULL;
+}
+
/* end of sqlite.c */
Modified: GNUnet/src/server/startup.c
===================================================================
--- GNUnet/src/server/startup.c 2006-11-03 17:42:45 UTC (rev 3629)
+++ GNUnet/src/server/startup.c 2006-11-03 18:54:27 UTC (rev 3630)
@@ -87,6 +87,7 @@
GE_WARNING | GE_ADMIN | GE_BULK,
"fopen",
pif);
+ FREE(pif);
return;
}
if (0 > FPRINTF(pidfd,
Modified: GNUnet/todo
===================================================================
--- GNUnet/todo 2006-11-03 17:42:45 UTC (rev 3629)
+++ GNUnet/todo 2006-11-03 18:54:27 UTC (rev 3630)
@@ -12,18 +12,14 @@
-0.7.1 [10'06] (aka "stabilization")
+0.7.1 [11'06] (aka "stabilization")
+- fix critical known bugs (see Mantis for updates):
+ * Windows installer, uninstall: Remove account [Nils, RC]
+ * file/socket leak (#955) - possibly fixed
- finish util refactoring: [RCpre0]
* logger configuration:
+ util/boot code to parse configuration
-- and improve scm code as well!
- * error handling: [RCpre1]
- + tcpio
- + fs/module
- + fs/fslib
- + fs/ecrs
- + fs/fsui
- * FSUI/ECRS/fslib hang if fs module not loaded by gnunetd (!) [pre0]
* gnunet-setup: [RCpre0]
+ Scheme (scm) specification of entire configuration;
check options used in modules:
@@ -48,10 +44,13 @@
- topology_f2f
- kvstore
+ ncurses wizard
-- fix critical known bugs (see Mantis for updates):
- * adding missing sqlite indices during gnunet-update
- * Windows installer, uninstall: Remove account [Nils, RC]
- * file/socket leak (#955) - possibly fixed
+ * error handling: [RCpre1]
+ + tcpio
+ + fs/module
+ + fs/fslib
+ + fs/ecrs
+ + fs/fsui
+- update documentation [RCpre2]
- More testcases: [RCpre3]
* advertising
* ecrs_core
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r3630 - in GNUnet: . src/applications/sqstore_sqlite src/server,
grothoff <=