diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2015-12-15 14:00:51 +0000 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2015-12-15 14:00:51 +0000 |
commit | d1206bc476560bff4a57d5a9cc01bfcfbddc29bc (patch) | |
tree | b6646afdc8962fdae2250328ad7ae892e5784ad8 /src | |
parent | 08216bba64ab8da19dfaf8ff2d0d52dc3bdfd7b1 (diff) |
- update flat plugin to namestore flat plugin status. Add config filename.
Diffstat (limited to 'src')
-rw-r--r-- | src/namecache/namecache.conf.in | 3 | ||||
-rw-r--r-- | src/namecache/plugin_namecache_flat.c | 53 |
2 files changed, 32 insertions, 24 deletions
diff --git a/src/namecache/namecache.conf.in b/src/namecache/namecache.conf.in index 31cd22ec7d..f70fa487e4 100644 --- a/src/namecache/namecache.conf.in +++ b/src/namecache/namecache.conf.in @@ -14,6 +14,9 @@ DATABASE = sqlite [namecache-sqlite] FILENAME = $GNUNET_DATA_HOME/namecache/sqlite.db +[namecache-flat] +FILENAME = $GNUNET_DATA_HOME/namecache/flat.db + [namecache-postgres] CONFIG = connect_timeout=10; dbname=gnunet TEMPORARY_TABLE = NO diff --git a/src/namecache/plugin_namecache_flat.c b/src/namecache/plugin_namecache_flat.c index 85bb69237d..d537ea74f7 100644 --- a/src/namecache/plugin_namecache_flat.c +++ b/src/namecache/plugin_namecache_flat.c @@ -148,27 +148,32 @@ database_setup (struct Plugin *plugin) } GNUNET_DISK_file_close (fh); - - line = strtok ("\n", buffer); - while (line != NULL) { - query = strtok (",", line); - block = strtok (NULL, line); - line = strtok ("\n", buffer); - entry = GNUNET_malloc (sizeof (struct FlatFileEntry)); - GNUNET_CRYPTO_hash_from_string (query, - &entry->query); - GNUNET_STRINGS_base64_decode (block, - strlen (block), - &block_buffer); - entry->block = (struct GNUNET_GNSRECORD_Block *) block_buffer; - if (GNUNET_OK != - GNUNET_CONTAINER_multihashmap_put (plugin->hm, - &entry->query, - entry, - GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) - { - GNUNET_free (entry); - GNUNET_break (0); + if (0 < size) { + line = strtok (buffer, "\n"); + while (line != NULL) { + query = strtok (line, ","); + if (NULL == query) + break; + block = strtok (NULL, ","); + if (NULL == block) + break; + line = strtok (NULL, "\n"); + entry = GNUNET_malloc (sizeof (struct FlatFileEntry)); + GNUNET_CRYPTO_hash_from_string (query, + &entry->query); + GNUNET_STRINGS_base64_decode (block, + strlen (block), + &block_buffer); + entry->block = (struct GNUNET_GNSRECORD_Block *) block_buffer; + if (GNUNET_OK != + GNUNET_CONTAINER_multihashmap_put (plugin->hm, + &entry->query, + entry, + GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) + { + GNUNET_free (entry); + GNUNET_break (0); + } } } GNUNET_free (buffer); @@ -295,7 +300,7 @@ namecache_expire_blocks (struct Plugin *plugin) */ static int namecache_cache_block (void *cls, - const struct GNUNET_GNSRECORD_Block *block) + const struct GNUNET_GNSRECORD_Block *block) { struct Plugin *plugin = cls; struct GNUNET_HashCode query; @@ -391,7 +396,7 @@ libgnunet_plugin_namecache_flat_init (void *cls) api->cache_block = &namecache_cache_block; api->lookup_block = &namecache_lookup_block; GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("flat plugin running\n")); + _("flat plugin running\n")); return api; } @@ -412,7 +417,7 @@ libgnunet_plugin_namecache_flat_done (void *cls) plugin->cfg = NULL; GNUNET_free (api); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "flat plugin is finished\n"); + "flat plugin is finished\n"); return NULL; } |