From 5ef6c24b21b66b65d6d0703863c2b2e90477901e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= Date: Wed, 1 Dec 2010 09:28:22 +0300 Subject: [PATCH] W32 datacache fixes * Fix datacache sqlite plugin to unlink the temporary storage file AFTER it is closed (contrary to POSIX, it is not possible to unlink opened files on W32) * Fix datacache testcases to mind the .exe extension when extracting the plugin name from argv[0] --- src/datacache/perf_datacache.c | 9 ++++++++- src/datacache/plugin_datacache_sqlite.c | 9 +++++++++ src/datacache/test_datacache.c | 9 ++++++++- src/datacache/test_datacache_quota.c | 10 +++++++++- 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/datacache/perf_datacache.c b/src/datacache/perf_datacache.c index f325740..ff60a58 100644 --- a/src/datacache/perf_datacache.c +++ b/src/datacache/perf_datacache.c @@ -131,7 +131,7 @@ FAILURE: int main (int argc, char *argv[]) { - const char *pos; + char *pos; char cfg_name[128]; char *const xargv[] = { "perf-datacache", @@ -157,10 +157,17 @@ main (int argc, char *argv[]) plugin_name = argv[0]; while (NULL != (pos = strstr(plugin_name, "_"))) plugin_name = pos+1; + if (NULL != (pos = strstr(plugin_name, "."))) + pos[0] = 0; + else + pos = (char *) plugin_name; + GNUNET_snprintf (cfg_name, sizeof (cfg_name), "perf_datacache_data_%s.conf", plugin_name); + if (pos != plugin_name) + pos[0] = '.'; GNUNET_PROGRAM_run ((sizeof (xargv) / sizeof (char *)) - 1, xargv, "perf-datacache", "nohelp", options, &run, NULL); diff --git a/src/datacache/plugin_datacache_sqlite.c b/src/datacache/plugin_datacache_sqlite.c index b5d0ea7..e3f0dcb 100644 --- a/src/datacache/plugin_datacache_sqlite.c +++ b/src/datacache/plugin_datacache_sqlite.c @@ -424,12 +424,21 @@ libgnunet_plugin_datacache_sqlite_done (void *cls) struct GNUNET_DATACACHE_PluginFunctions *api = cls; struct Plugin *plugin = api->cls; +#if !WINDOWS || defined(__CYGWIN__) if (0 != UNLINK (plugin->fn)) GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", plugin->fn); GNUNET_free (plugin->fn); +#endif sqlite3_close (plugin->dbh); +#if WINDOWS && !defined(__CYGWIN__) + if (0 != UNLINK (plugin->fn)) + GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, + "unlink", + plugin->fn); + GNUNET_free (plugin->fn); +#endif GNUNET_free (plugin); GNUNET_free (api); return NULL; diff --git a/src/datacache/test_datacache.c b/src/datacache/test_datacache.c index b626ce6..7d55ef8 100644 --- a/src/datacache/test_datacache.c +++ b/src/datacache/test_datacache.c @@ -130,7 +130,7 @@ FAILURE: int main (int argc, char *argv[]) { - const char *pos; + char *pos; char cfg_name[128]; char *const xargv[] = { "test-datacache", @@ -156,10 +156,17 @@ main (int argc, char *argv[]) plugin_name = argv[0]; while (NULL != (pos = strstr(plugin_name, "_"))) plugin_name = pos+1; + if (NULL != (pos = strstr(plugin_name, "."))) + pos[0] = 0; + else + pos = (char *) plugin_name; + GNUNET_snprintf (cfg_name, sizeof (cfg_name), "test_datacache_data_%s.conf", plugin_name); + if (pos != plugin_name) + pos[0] = '.'; GNUNET_PROGRAM_run ((sizeof (xargv) / sizeof (char *)) - 1, xargv, "test-datacache", "nohelp", options, &run, NULL); diff --git a/src/datacache/test_datacache_quota.c b/src/datacache/test_datacache_quota.c index 77ad638..d956ac3 100644 --- a/src/datacache/test_datacache_quota.c +++ b/src/datacache/test_datacache_quota.c @@ -121,7 +121,7 @@ FAILURE: int main (int argc, char *argv[]) { - const char *pos; + char *pos; char cfg_name[128]; char *const xargv[] = { "test-datacache-quota", @@ -143,14 +143,22 @@ main (int argc, char *argv[]) "WARNING", #endif NULL); + /* determine name of plugin to use */ plugin_name = argv[0]; while (NULL != (pos = strstr(plugin_name, "_"))) plugin_name = pos+1; + if (NULL != (pos = strstr(plugin_name, "."))) + pos[0] = 0; + else + pos = (char *) plugin_name; + GNUNET_snprintf (cfg_name, sizeof (cfg_name), "test_datacache_data_%s.conf", plugin_name); + if (pos != plugin_name) + pos[0] = '.'; GNUNET_PROGRAM_run ((sizeof (xargv) / sizeof (char *)) - 1, xargv, "test-datacache-quota", "nohelp", options, &run, NULL); -- 1.7.3.1.msysgit.0