View Issue Details

IDProjectCategoryView StatusLast Update
0001627GNUnetdatacache librarypublic2010-12-23 23:50
ReporterLRN Assigned ToLRN  
PrioritynormalSeveritytrivialReproducibilityalways
Status closedResolutionfixed 
Target VersionGit master 
Summary0001627: W32 datacache problems and fixes
DescriptionI've found two problems in datacache while running the tests.

1) Datacache testcases will use argv[0] to obtain plugin_name, which is later used to form the name of the config file to use. Obviously, there's no test_datacache_data_sqlite.exe.conf ...

2) Datacache sqlite plugin unlinks the temporary storage file before calling sqlite3_close(). W32 doesn't allow unlinking of opened files, i had to fix that as well.

Patch attached.
TagsNo tags attached.
Attached Files
0001-W32-datacache-fixes.patch (4,732 bytes)   
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?= <lrn1986@gmail.com>
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

0001-W32-datacache-fixes.patch (4,732 bytes)   

Activities

Christian Grothoff

2010-12-19 19:27

manager   ~0004208

Committed as suggested as SVN 13934.

Issue History

Date Modified Username Field Change
2010-12-01 07:33 LRN New Issue
2010-12-01 07:33 LRN File Added: 0001-W32-datacache-fixes.patch
2010-12-19 19:27 Christian Grothoff Note Added: 0004208
2010-12-19 19:27 Christian Grothoff Status new => resolved
2010-12-19 19:27 Christian Grothoff Resolution open => fixed
2010-12-19 19:27 Christian Grothoff Assigned To => Christian Grothoff
2010-12-19 19:28 Christian Grothoff Assigned To Christian Grothoff => LRN
2010-12-23 23:50 Christian Grothoff Status resolved => closed