projects
/
oweals
/
gnunet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
- opaque mq structs
[oweals/gnunet.git]
/
src
/
fs
/
fs_sharetree.c
diff --git
a/src/fs/fs_sharetree.c
b/src/fs/fs_sharetree.c
index 6c9642b9bda8e9dedac98871671914f211ae0f4b..5e96390ce2c933ef1529f2d14ea5ad43faa70832 100644
(file)
--- a/
src/fs/fs_sharetree.c
+++ b/
src/fs/fs_sharetree.c
@@
-162,7
+162,7
@@
add_to_keyword_counter (void *cls, const char *keyword, int is_mandatory)
{
struct GNUNET_CONTAINER_MultiHashMap *mcm = cls;
struct KeywordCounter *cnt;
{
struct GNUNET_CONTAINER_MultiHashMap *mcm = cls;
struct KeywordCounter *cnt;
- GNUNET_HashCode hc;
+
struct
GNUNET_HashCode hc;
size_t klen;
klen = strlen (keyword) + 1;
size_t klen;
klen = strlen (keyword) + 1;
@@
-206,7
+206,7
@@
add_to_meta_counter (void *cls, const char *plugin_name,
const char *data_mime_type, const char *data, size_t data_len)
{
struct GNUNET_CONTAINER_MultiHashMap *map = cls;
const char *data_mime_type, const char *data, size_t data_len)
{
struct GNUNET_CONTAINER_MultiHashMap *map = cls;
- GNUNET_HashCode key;
+
struct
GNUNET_HashCode key;
struct MetaCounter *cnt;
GNUNET_CRYPTO_hash (data, data_len, &key);
struct MetaCounter *cnt;
GNUNET_CRYPTO_hash (data, data_len, &key);
@@
-243,7
+243,7
@@
remove_high_frequency_keywords (void *cls, const char *keyword, int is_mandatory
{
struct TrimContext *tc = cls;
struct KeywordCounter *counter;
{
struct TrimContext *tc = cls;
struct KeywordCounter *counter;
- GNUNET_HashCode hc;
+
struct
GNUNET_HashCode hc;
size_t klen;
klen = strlen (keyword) + 1;
size_t klen;
klen = strlen (keyword) + 1;
@@
-268,13
+268,18
@@
remove_high_frequency_keywords (void *cls, const char *keyword, int is_mandatory
* @return GNUNET_YES (always)
*/
static int
* @return GNUNET_YES (always)
*/
static int
-migrate_and_drop_keywords (void *cls, const GNUNET_HashCode * key, void *value)
+migrate_and_drop_keywords (void *cls, const
struct
GNUNET_HashCode * key, void *value)
{
struct TrimContext *tc = cls;
struct KeywordCounter *counter = value;
if (counter->count >= tc->move_threshold)
{
struct TrimContext *tc = cls;
struct KeywordCounter *counter = value;
if (counter->count >= tc->move_threshold)
- GNUNET_FS_uri_ksk_add_keyword (tc->pos->ksk_uri, counter->value, GNUNET_NO);
+ {
+ if (NULL == tc->pos->ksk_uri)
+ tc->pos->ksk_uri = GNUNET_FS_uri_ksk_create_from_args (1, &counter->value);
+ else
+ GNUNET_FS_uri_ksk_add_keyword (tc->pos->ksk_uri, counter->value, GNUNET_NO);
+ }
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_remove (tc->keywordcounter,
key,
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_remove (tc->keywordcounter,
key,
@@
-294,18
+299,22
@@
migrate_and_drop_keywords (void *cls, const GNUNET_HashCode * key, void *value)
* @return GNUNET_YES (always)
*/
static int
* @return GNUNET_YES (always)
*/
static int
-migrate_and_drop_metadata (void *cls, const GNUNET_HashCode * key, void *value)
+migrate_and_drop_metadata (void *cls, const
struct
GNUNET_HashCode * key, void *value)
{
struct TrimContext *tc = cls;
struct MetaCounter *counter = value;
if (counter->count >= tc->move_threshold)
{
struct TrimContext *tc = cls;
struct MetaCounter *counter = value;
if (counter->count >= tc->move_threshold)
+ {
+ if (NULL == tc->pos->meta)
+ tc->pos->meta = GNUNET_CONTAINER_meta_data_create ();
GNUNET_CONTAINER_meta_data_insert (tc->pos->meta,
counter->plugin_name,
counter->type,
counter->format,
counter->data_mime_type, counter->data,
counter->data_size);
GNUNET_CONTAINER_meta_data_insert (tc->pos->meta,
counter->plugin_name,
counter->type,
counter->format,
counter->data_mime_type, counter->data,
counter->data_size);
+ }
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_remove (tc->metacounter,
key,
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_remove (tc->metacounter,
key,
@@
-338,13
+347,15
@@
share_tree_trim (struct TrimContext *tc,
}
/* consider adding filename to directory meta data */
}
/* consider adding filename to directory meta data */
- if (tree->is_directory)
+ if (tree->is_directory
== GNUNET_YES
)
{
const char *user = getenv ("USER");
if ( (user == NULL) ||
(0 != strncasecmp (user, tree->short_filename, strlen(user))))
{
/* only use filename if it doesn't match $USER */
{
const char *user = getenv ("USER");
if ( (user == NULL) ||
(0 != strncasecmp (user, tree->short_filename, strlen(user))))
{
/* only use filename if it doesn't match $USER */
+ if (NULL == tree->meta)
+ tree->meta = GNUNET_CONTAINER_meta_data_create ();
GNUNET_CONTAINER_meta_data_insert (tree->meta, "<libgnunetfs>",
EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME,
EXTRACTOR_METAFORMAT_UTF8,
GNUNET_CONTAINER_meta_data_insert (tree->meta, "<libgnunetfs>",
EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME,
EXTRACTOR_METAFORMAT_UTF8,
@@
-359,8
+370,10
@@
share_tree_trim (struct TrimContext *tc,
/* now, count keywords and meta data in children */
for (pos = tree->children_head; NULL != pos; pos = pos->next)
{
/* now, count keywords and meta data in children */
for (pos = tree->children_head; NULL != pos; pos = pos->next)
{
- GNUNET_CONTAINER_meta_data_iterate (pos->meta, &add_to_meta_counter, tc->metacounter);
- GNUNET_FS_uri_ksk_get_keywords (pos->ksk_uri, &add_to_keyword_counter, tc->keywordcounter);
+ if (NULL != pos->meta)
+ GNUNET_CONTAINER_meta_data_iterate (pos->meta, &add_to_meta_counter, tc->metacounter);
+ if (NULL != pos->ksk_uri)
+ GNUNET_FS_uri_ksk_get_keywords (pos->ksk_uri, &add_to_keyword_counter, tc->keywordcounter);
}
/* calculate threshold for moving keywords / meta data */
}
/* calculate threshold for moving keywords / meta data */
@@
-370,7
+383,12
@@
share_tree_trim (struct TrimContext *tc,
for (pos = tree->children_head; NULL != pos; pos = pos->next)
{
tc->pos = pos;
for (pos = tree->children_head; NULL != pos; pos = pos->next)
{
tc->pos = pos;
- GNUNET_FS_uri_ksk_get_keywords (pos->ksk_uri, &remove_high_frequency_keywords, tc);
+ if (NULL != pos->ksk_uri)
+ {
+ struct GNUNET_FS_Uri *ksk_uri_copy = GNUNET_FS_uri_dup (pos->ksk_uri);
+ GNUNET_FS_uri_ksk_get_keywords (ksk_uri_copy, &remove_high_frequency_keywords, tc);
+ GNUNET_FS_uri_destroy (ksk_uri_copy);
+ }
}
/* add high-frequency meta data and keywords to parent */
}
/* add high-frequency meta data and keywords to parent */
@@
-397,8
+415,8
@@
GNUNET_FS_share_tree_trim (struct GNUNET_FS_ShareTreeItem *toplevel)
if (toplevel == NULL)
return;
if (toplevel == NULL)
return;
- tc.keywordcounter = GNUNET_CONTAINER_multihashmap_create (1024);
- tc.metacounter = GNUNET_CONTAINER_multihashmap_create (1024);
+ tc.keywordcounter = GNUNET_CONTAINER_multihashmap_create (1024
, GNUNET_NO
);
+ tc.metacounter = GNUNET_CONTAINER_multihashmap_create (1024
, GNUNET_NO
);
share_tree_trim (&tc, toplevel);
GNUNET_CONTAINER_multihashmap_destroy (tc.keywordcounter);
GNUNET_CONTAINER_multihashmap_destroy (tc.metacounter);
share_tree_trim (&tc, toplevel);
GNUNET_CONTAINER_multihashmap_destroy (tc.keywordcounter);
GNUNET_CONTAINER_multihashmap_destroy (tc.metacounter);