aboutsummaryrefslogtreecommitdiff
path: root/src/datastore
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-12-18 16:54:52 +0000
committerChristian Grothoff <christian@grothoff.org>2011-12-18 16:54:52 +0000
commit6ccb7418e621ffc04251ae9b08256e6555917833 (patch)
tree8eed5ab26ea89bb95851f6e961f59cc6eff271d7 /src/datastore
parentd964273f5167433a465742cc54a4aa16945924fa (diff)
downloadgnunet-6ccb7418e621ffc04251ae9b08256e6555917833.tar.gz
gnunet-6ccb7418e621ffc04251ae9b08256e6555917833.zip
-use plugin-specific bloomfilter file name
Diffstat (limited to 'src/datastore')
-rw-r--r--src/datastore/gnunet-service-datastore.c67
1 files changed, 38 insertions, 29 deletions
diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c
index 0f2e0c209..e6f822c59 100644
--- a/src/datastore/gnunet-service-datastore.c
+++ b/src/datastore/gnunet-service-datastore.c
@@ -152,6 +152,11 @@ static unsigned long long quota;
152static int do_drop; 152static int do_drop;
153 153
154/** 154/**
155 * Name of our plugin.
156 */
157static char *plugin_name;
158
159/**
155 * How much space are we using for the cache? (space available for 160 * How much space are we using for the cache? (space available for
156 * insertions that will be instantly reclaimed by discarding less 161 * insertions that will be instantly reclaimed by discarding less
157 * important content --- or possibly whatever we just inserted into 162 * important content --- or possibly whatever we just inserted into
@@ -1288,34 +1293,21 @@ load_plugin ()
1288{ 1293{
1289 struct DatastorePlugin *ret; 1294 struct DatastorePlugin *ret;
1290 char *libname; 1295 char *libname;
1291 char *name;
1292 1296
1293 if (GNUNET_OK !=
1294 GNUNET_CONFIGURATION_get_value_string (cfg, "DATASTORE", "DATABASE",
1295 &name))
1296 {
1297 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1298 _("No `%s' specified for `%s' in configuration!\n"), "DATABASE",
1299 "DATASTORE");
1300 return NULL;
1301 }
1302 GNUNET_asprintf (&quota_stat_name,
1303 _("# bytes used in file-sharing datastore `%s'"),
1304 name);
1305 ret = GNUNET_malloc (sizeof (struct DatastorePlugin)); 1297 ret = GNUNET_malloc (sizeof (struct DatastorePlugin));
1306 ret->env.cfg = cfg; 1298 ret->env.cfg = cfg;
1307 ret->env.duc = &disk_utilization_change_cb; 1299 ret->env.duc = &disk_utilization_change_cb;
1308 ret->env.cls = NULL; 1300 ret->env.cls = NULL;
1309 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Loading `%s' datastore plugin\n"), 1301 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Loading `%s' datastore plugin\n"),
1310 name); 1302 plugin_name);
1311 GNUNET_asprintf (&libname, "libgnunet_plugin_datastore_%s", name); 1303 GNUNET_asprintf (&libname, "libgnunet_plugin_datastore_%s", plugin_name);
1312 ret->short_name = name; 1304 ret->short_name = GNUNET_strdup (plugin_name);
1313 ret->lib_name = libname; 1305 ret->lib_name = libname;
1314 ret->api = GNUNET_PLUGIN_load (libname, &ret->env); 1306 ret->api = GNUNET_PLUGIN_load (libname, &ret->env);
1315 if (ret->api == NULL) 1307 if (ret->api == NULL)
1316 { 1308 {
1317 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1309 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1318 _("Failed to load datastore plugin for `%s'\n"), name); 1310 _("Failed to load datastore plugin for `%s'\n"), plugin_name);
1319 GNUNET_free (ret->short_name); 1311 GNUNET_free (ret->short_name);
1320 GNUNET_free (libname); 1312 GNUNET_free (libname);
1321 GNUNET_free (ret); 1313 GNUNET_free (ret);
@@ -1375,6 +1367,8 @@ unload_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1375 GNUNET_STATISTICS_destroy (stats, GNUNET_YES); 1367 GNUNET_STATISTICS_destroy (stats, GNUNET_YES);
1376 stats = NULL; 1368 stats = NULL;
1377 } 1369 }
1370 GNUNET_free_non_null (plugin_name);
1371 plugin_name = NULL;
1378} 1372}
1379 1373
1380 1374
@@ -1501,12 +1495,25 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
1501 sizeof (struct GNUNET_MessageHeader)}, 1495 sizeof (struct GNUNET_MessageHeader)},
1502 {NULL, NULL, 0, 0} 1496 {NULL, NULL, 0, 0}
1503 }; 1497 };
1504 char *fn; 1498 char *fn;
1499 char *pfn;
1505 unsigned int bf_size; 1500 unsigned int bf_size;
1506 int refresh_bf; 1501 int refresh_bf;
1507 1502
1508 cfg = c; 1503 cfg = c;
1509 if (GNUNET_OK != 1504 if (GNUNET_OK !=
1505 GNUNET_CONFIGURATION_get_value_string (cfg, "DATASTORE", "DATABASE",
1506 &plugin_name))
1507 {
1508 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1509 _("No `%s' specified for `%s' in configuration!\n"), "DATABASE",
1510 "DATASTORE");
1511 return;
1512 }
1513 GNUNET_asprintf (&quota_stat_name,
1514 _("# bytes used in file-sharing datastore `%s'"),
1515 plugin_name);
1516 if (GNUNET_OK !=
1510 GNUNET_CONFIGURATION_get_value_size (cfg, "DATASTORE", "QUOTA", &quota)) 1517 GNUNET_CONFIGURATION_get_value_size (cfg, "DATASTORE", "QUOTA", &quota))
1511 { 1518 {
1512 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1519 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -1537,36 +1544,37 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
1537 } 1544 }
1538 if (fn != NULL) 1545 if (fn != NULL)
1539 { 1546 {
1540 if (GNUNET_YES == GNUNET_DISK_file_test (fn)) 1547 GNUNET_asprintf (&pfn, "%s.%s\n", fn, plugin_name);
1548 if (GNUNET_YES == GNUNET_DISK_file_test (pfn))
1541 { 1549 {
1542 filter = GNUNET_CONTAINER_bloomfilter_load (fn, bf_size, 5); /* approx. 3% false positives at max use */ 1550 filter = GNUNET_CONTAINER_bloomfilter_load (pfn, bf_size, 5); /* approx. 3% false positives at max use */
1543 if (NULL == filter) 1551 if (NULL == filter)
1544 { 1552 {
1545 /* file exists but not valid, remove and try again, but refresh */ 1553 /* file exists but not valid, remove and try again, but refresh */
1546 if (0 != UNLINK (fn)) 1554 if (0 != UNLINK (pfn))
1547 { 1555 {
1548 /* failed to remove, run without file */ 1556 /* failed to remove, run without file */
1549 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1557 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1550 _("Failed to remove bogus bloomfilter file `%s'\n"), 1558 _("Failed to remove bogus bloomfilter file `%s'\n"),
1551 fn); 1559 pfn);
1552 GNUNET_free (fn); 1560 GNUNET_free (pfn);
1553 fn = NULL; 1561 pfn = NULL;
1554 filter = GNUNET_CONTAINER_bloomfilter_load (NULL, bf_size, 5); /* approx. 3% false positives at max use */ 1562 filter = GNUNET_CONTAINER_bloomfilter_load (NULL, bf_size, 5); /* approx. 3% false positives at max use */
1555 refresh_bf = GNUNET_YES; 1563 refresh_bf = GNUNET_YES;
1556 } 1564 }
1557 else 1565 else
1558 { 1566 {
1559 /* try again after remove */ 1567 /* try again after remove */
1560 filter = GNUNET_CONTAINER_bloomfilter_load (fn, bf_size, 5); /* approx. 3% false positives at max use */ 1568 filter = GNUNET_CONTAINER_bloomfilter_load (pfn, bf_size, 5); /* approx. 3% false positives at max use */
1561 refresh_bf = GNUNET_YES; 1569 refresh_bf = GNUNET_YES;
1562 if (NULL == filter) 1570 if (NULL == filter)
1563 { 1571 {
1564 /* failed yet again, give up on using file */ 1572 /* failed yet again, give up on using file */
1565 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1573 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1566 _("Failed to remove bogus bloomfilter file `%s'\n"), 1574 _("Failed to remove bogus bloomfilter file `%s'\n"),
1567 fn); 1575 pfn);
1568 GNUNET_free (fn); 1576 GNUNET_free (pfn);
1569 fn = NULL; 1577 pfn = NULL;
1570 filter = GNUNET_CONTAINER_bloomfilter_load (NULL, bf_size, 5); /* approx. 3% false positives at max use */ 1578 filter = GNUNET_CONTAINER_bloomfilter_load (NULL, bf_size, 5); /* approx. 3% false positives at max use */
1571 } 1579 }
1572 } 1580 }
@@ -1579,9 +1587,10 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
1579 } 1587 }
1580 else 1588 else
1581 { 1589 {
1582 filter = GNUNET_CONTAINER_bloomfilter_load (fn, bf_size, 5); /* approx. 3% false positives at max use */ 1590 filter = GNUNET_CONTAINER_bloomfilter_load (pfn, bf_size, 5); /* approx. 3% false positives at max use */
1583 refresh_bf = GNUNET_YES; 1591 refresh_bf = GNUNET_YES;
1584 } 1592 }
1593 GNUNET_free (pfn);
1585 } 1594 }
1586 else 1595 else
1587 { 1596 {