GNUnet  0.11.x
Data Structures | Functions
gnunet-service-messenger_message_store.c File Reference

GNUnet MESSENGER service. More...

#include "gnunet-service-messenger_message_store.h"
#include "messenger_api_message.h"
Include dependency graph for gnunet-service-messenger_message_store.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_MESSENGER_MessageEntryStorage
 
struct  GNUNET_MESSENGER_MessageLinkStorage
 
struct  GNUNET_MESSENGER_ClosureMessageSave
 

Functions

void init_message_store (struct GNUNET_MESSENGER_MessageStore *store)
 Initializes a message store as fully empty. More...
 
static int iterate_destroy_entries (void *cls, const struct GNUNET_HashCode *key, void *value)
 
static int iterate_destroy_messages (void *cls, const struct GNUNET_HashCode *key, void *value)
 
static int iterate_destroy_links (void *cls, const struct GNUNET_HashCode *key, void *value)
 
void clear_message_store (struct GNUNET_MESSENGER_MessageStore *store)
 Clears a message store, wipes its content and deallocates its memory. More...
 
static void load_message_store_entries (struct GNUNET_MESSENGER_MessageStore *store, const char *filename)
 
static void load_message_store_links (struct GNUNET_MESSENGER_MessageStore *store, const char *filename)
 
void load_message_store (struct GNUNET_MESSENGER_MessageStore *store, const char *directory)
 Loads messages from a directory into a message store. More...
 
static int iterate_save_entries (void *cls, const struct GNUNET_HashCode *key, void *value)
 
static int iterate_save_messages (void *cls, const struct GNUNET_HashCode *key, void *value)
 
static int iterate_save_links (void *cls, const struct GNUNET_HashCode *key, void *value)
 
void save_message_store (struct GNUNET_MESSENGER_MessageStore *store, const char *directory)
 Saves messages from a message store into a directory. More...
 
int contains_store_message (const struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash)
 Checks if a message matching a given hash is stored in a message store. More...
 
const struct GNUNET_MESSENGER_Messageget_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash)
 Returns the message from a message store matching a given hash. More...
 
const struct GNUNET_MESSENGER_MessageLinkget_store_message_link (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash, int deleted_only)
 Returns the message link from a message store matching a given hash. More...
 
int put_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_Message *message)
 Stores a message into the message store. More...
 
static void add_link (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_Message *message)
 
int delete_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash)
 Deletes a message in the message store. More...
 

Detailed Description

GNUnet MESSENGER service.

Author
Tobias Frisch

Definition in file gnunet-service-messenger_message_store.c.

Function Documentation

◆ init_message_store()

void init_message_store ( struct GNUNET_MESSENGER_MessageStore store)

Initializes a message store as fully empty.

Parameters
[out]storeMessage store

Definition at line 30 of file gnunet-service-messenger_message_store.c.

References GNUNET_MESSENGER_MessageStore::entries, GNUNET_assert, GNUNET_CONTAINER_multihashmap_create(), GNUNET_NO, GNUNET_MESSENGER_MessageStore::links, GNUNET_MESSENGER_MessageStore::messages, GNUNET_MESSENGER_MessageStore::rewrite_entries, GNUNET_MESSENGER_MessageStore::storage_messages, and GNUNET_MESSENGER_MessageStore::write_links.

Referenced by create_room().

31 {
32  GNUNET_assert(store);
33 
34  store->storage_messages = NULL;
35 
39 
40  store->rewrite_entries = GNUNET_NO;
41  store->write_links = GNUNET_NO;
42 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_DISK_FileHandle * storage_messages
struct GNUNET_CONTAINER_MultiHashMap * messages
struct GNUNET_CONTAINER_MultiHashMap * links
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
struct GNUNET_CONTAINER_MultiHashMap * entries
Here is the call graph for this function:
Here is the caller graph for this function:

◆ iterate_destroy_entries()

static int iterate_destroy_entries ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Definition at line 45 of file gnunet-service-messenger_message_store.c.

References GNUNET_free, GNUNET_YES, and value.

Referenced by clear_message_store().

46 {
47  struct GNUNET_MESSENGER_MessageEntry *entry = value;
48 
49  GNUNET_free(entry);
50 
51  return GNUNET_YES;
52 }
static char * value
Value of the record to add/remove.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function:

◆ iterate_destroy_messages()

static int iterate_destroy_messages ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Definition at line 55 of file gnunet-service-messenger_message_store.c.

References destroy_message(), GNUNET_YES, and value.

Referenced by clear_message_store().

56 {
57  struct GNUNET_MESSENGER_Message *message = value;
58 
59  destroy_message (message);
60 
61  return GNUNET_YES;
62 }
void destroy_message(struct GNUNET_MESSENGER_Message *message)
Destroys a message and frees its memory fully.
static char * value
Value of the record to add/remove.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ iterate_destroy_links()

static int iterate_destroy_links ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Definition at line 65 of file gnunet-service-messenger_message_store.c.

References GNUNET_free, GNUNET_YES, and value.

Referenced by clear_message_store().

66 {
67  struct GNUNET_HashCode *previous = value;
68 
69  GNUNET_free(previous);
70 
71  return GNUNET_YES;
72 }
static char * value
Value of the record to add/remove.
A 512-bit hashcode.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function:

◆ clear_message_store()

void clear_message_store ( struct GNUNET_MESSENGER_MessageStore store)

Clears a message store, wipes its content and deallocates its memory.

Parameters

Definition at line 75 of file gnunet-service-messenger_message_store.c.

References GNUNET_MESSENGER_MessageStore::entries, GNUNET_assert, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_DISK_file_close(), iterate_destroy_entries(), iterate_destroy_links(), iterate_destroy_messages(), GNUNET_MESSENGER_MessageStore::links, GNUNET_MESSENGER_MessageStore::messages, and GNUNET_MESSENGER_MessageStore::storage_messages.

Referenced by destroy_room().

76 {
77  GNUNET_assert(store);
78 
79  if (store->storage_messages)
80  {
82 
83  store->storage_messages = NULL;
84  }
85 
89 
93 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1126
struct GNUNET_DISK_FileHandle * storage_messages
struct GNUNET_CONTAINER_MultiHashMap * messages
struct GNUNET_CONTAINER_MultiHashMap * links
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
static int iterate_destroy_messages(void *cls, const struct GNUNET_HashCode *key, void *value)
static int iterate_destroy_links(void *cls, const struct GNUNET_HashCode *key, void *value)
static int iterate_destroy_entries(void *cls, const struct GNUNET_HashCode *key, void *value)
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
struct GNUNET_CONTAINER_MultiHashMap * entries
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_message_store_entries()

static void load_message_store_entries ( struct GNUNET_MESSENGER_MessageStore store,
const char *  filename 
)
static

Definition at line 102 of file gnunet-service-messenger_message_store.c.

References GNUNET_MESSENGER_MessageStore::entries, entries, GNUNET_MESSENGER_MessageEntryStorage::entry, GNUNET_CONTAINER_multihashmap_contains(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_DISK_file_close(), GNUNET_DISK_file_open(), GNUNET_DISK_file_read(), GNUNET_DISK_OPEN_READ, GNUNET_DISK_PERM_USER_READ, GNUNET_free, GNUNET_memcpy, GNUNET_new, GNUNET_OK, GNUNET_YES, GNUNET_MESSENGER_MessageEntryStorage::hash, and GNUNET_MESSENGER_MessageStore::rewrite_entries.

Referenced by load_message_store().

103 {
105 
107 
108  if (!entries)
109  return;
110 
112  struct GNUNET_MESSENGER_MessageEntry *entry;
113 
114  do
115  {
117 
118  if (GNUNET_DISK_file_read (entries, &storage, sizeof(storage)) == sizeof(storage))
119  {
120  GNUNET_memcpy(entry, &(storage.entry), sizeof(*entry));
121 
122  if ((GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains (store->entries, &(storage.hash))) ||
123  (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (store->entries, &(storage.hash), entry,
125  {
126  store->rewrite_entries = GNUNET_YES;
127  GNUNET_free(entry);
128  }
129  }
130  else
131  {
132  GNUNET_free(entry);
133 
134  entry = NULL;
135  }
136  }
137  while (entry);
138 
139  GNUNET_DISK_file_close (entries);
140 }
Open the file for reading.
ssize_t GNUNET_DISK_file_read(const struct GNUNET_DISK_FileHandle *h, void *result, size_t len)
Read the contents of a binary file into a buffer.
Definition: disk.c:602
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1126
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
int GNUNET_CONTAINER_multihashmap_contains(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Check if the map contains any value under the given key (including values that are NULL)...
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_...
struct ListEntry * entries
List of peers in the list.
static char * filename
GNUNET_DISK_AccessPermissions
File access permissions, UNIX-style.
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
Definition: disk.c:1055
Handle used to access files (and pipes).
struct GNUNET_CONTAINER_MultiHashMap * entries
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_message_store_links()

static void load_message_store_links ( struct GNUNET_MESSENGER_MessageStore store,
const char *  filename 
)
static

Definition at line 149 of file gnunet-service-messenger_message_store.c.

References entries, GNUNET_MESSENGER_MessageLink::first, GNUNET_CONTAINER_multihashmap_contains(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_DISK_file_close(), GNUNET_DISK_file_open(), GNUNET_DISK_file_read(), GNUNET_DISK_OPEN_READ, GNUNET_DISK_PERM_USER_READ, GNUNET_free, GNUNET_memcpy, GNUNET_new, GNUNET_OK, GNUNET_YES, GNUNET_MESSENGER_MessageLinkStorage::hash, GNUNET_MESSENGER_MessageLinkStorage::link, GNUNET_MESSENGER_MessageStore::links, GNUNET_MESSENGER_MessageLink::multiple, and GNUNET_MESSENGER_MessageLink::second.

Referenced by load_message_store().

150 {
152 
154 
155  if (!entries)
156  return;
157 
159  struct GNUNET_MESSENGER_MessageLink *link = NULL;
160 
161  memset(&storage, 0, sizeof(storage));
162 
163  do
164  {
165  if ((sizeof(storage.hash) != GNUNET_DISK_file_read (entries, &(storage.hash), sizeof(storage.hash))) ||
166  (sizeof(storage.link.multiple) != GNUNET_DISK_file_read (entries, &(storage.link.multiple), sizeof(storage.link.multiple))) ||
167  (sizeof(storage.link.first) != GNUNET_DISK_file_read (entries, &(storage.link.first), sizeof(storage.link.first))) ||
168  ((GNUNET_YES == storage.link.multiple) &&
169  (sizeof(storage.link.second) != GNUNET_DISK_file_read (entries, &(storage.link.second), sizeof(storage.link.second)))))
170  break;
171 
173 
174  GNUNET_memcpy(link, &(storage.link), sizeof(*link));
175 
176  if ((GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains (store->links, &(storage.hash))) ||
177  (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (store->links, &(storage.hash), link,
179  break;
180  }
181  while (link);
182 
183  if (link)
184  GNUNET_free(link);
185 
186  GNUNET_DISK_file_close (entries);
187 }
Open the file for reading.
ssize_t GNUNET_DISK_file_read(const struct GNUNET_DISK_FileHandle *h, void *result, size_t len)
Read the contents of a binary file into a buffer.
Definition: disk.c:602
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1126
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
int GNUNET_CONTAINER_multihashmap_contains(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Check if the map contains any value under the given key (including values that are NULL)...
struct GNUNET_CONTAINER_MultiHashMap * links
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_...
struct ListEntry * entries
List of peers in the list.
static char * filename
GNUNET_DISK_AccessPermissions
File access permissions, UNIX-style.
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
Definition: disk.c:1055
Handle used to access files (and pipes).
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_message_store()

void load_message_store ( struct GNUNET_MESSENGER_MessageStore store,
const char *  directory 
)

Loads messages from a directory into a message store.

Parameters
[out]storeMessage store
[in]directoryPath to a directory

Definition at line 190 of file gnunet-service-messenger_message_store.c.

References filename, GNUNET_asprintf(), GNUNET_assert, GNUNET_DISK_file_close(), GNUNET_DISK_file_open(), GNUNET_DISK_file_test(), GNUNET_DISK_OPEN_READWRITE, GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_free, GNUNET_YES, load_message_store_entries(), load_message_store_links(), and GNUNET_MESSENGER_MessageStore::storage_messages.

Referenced by load_room().

191 {
192  GNUNET_assert((store) && (directory));
193 
195 
196  if (store->storage_messages)
198 
199  char *filename;
200  GNUNET_asprintf (&filename, "%s%s", directory, "messages.store");
201 
202  if (GNUNET_YES == GNUNET_DISK_file_test (filename))
203  store->storage_messages = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READWRITE, permission);
204  else
205  store->storage_messages = NULL;
206 
207  GNUNET_free(filename);
208 
209  if (!store->storage_messages)
210  return;
211 
212  GNUNET_asprintf (&filename, "%s%s", directory, "entries.store");
213 
214  if (GNUNET_YES == GNUNET_DISK_file_test (filename))
215  load_message_store_entries(store, filename);
216 
217  GNUNET_free(filename);
218 
219  GNUNET_asprintf (&filename, "%s%s", directory, "links.store");
220 
221  if (GNUNET_YES == GNUNET_DISK_file_test (filename))
222  load_message_store_links(store, filename);
223 
224  GNUNET_free(filename);
225 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1126
struct GNUNET_DISK_FileHandle * storage_messages
static char * filename
GNUNET_DISK_AccessPermissions
File access permissions, UNIX-style.
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
static void load_message_store_links(struct GNUNET_MESSENGER_MessageStore *store, const char *filename)
Open the file for both reading and writing.
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
Definition: disk.c:1055
enum GNUNET_GenericReturnValue GNUNET_DISK_file_test(const char *fil)
Check that fil corresponds to a filename (of a file that exists and that is not a directory)...
Definition: disk.c:437
static void load_message_store_entries(struct GNUNET_MESSENGER_MessageStore *store, const char *filename)
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ iterate_save_entries()

static int iterate_save_entries ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Definition at line 235 of file gnunet-service-messenger_message_store.c.

References GNUNET_MESSENGER_MessageEntryStorage::entry, GNUNET_DISK_file_write(), GNUNET_memcpy, GNUNET_YES, GNUNET_MESSENGER_MessageEntryStorage::hash, save(), GNUNET_MESSENGER_ClosureMessageSave::storage, and value.

Referenced by save_message_store().

236 {
238  struct GNUNET_MESSENGER_MessageEntry *entry = value;
239 
241 
242  GNUNET_memcpy(&(storage.hash), key, sizeof(storage.hash));
243  GNUNET_memcpy(&(storage.entry), entry, sizeof(*entry));
244 
245  GNUNET_DISK_file_write (save->storage, &storage, sizeof(storage));
246 
247  return GNUNET_YES;
248 }
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
static void save()
Write persistent statistics to disk.
static char * value
Value of the record to add/remove.
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
Definition: disk.c:666
Here is the call graph for this function:
Here is the caller graph for this function:

◆ iterate_save_messages()

static int iterate_save_messages ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Definition at line 251 of file gnunet-service-messenger_message_store.c.

References encode_message(), GNUNET_MESSENGER_MessageStore::entries, GNUNET_MESSENGER_MessageEntryStorage::entry, get_message_size(), GNUNET_CONTAINER_multihashmap_contains(), GNUNET_DISK_file_seek(), GNUNET_DISK_file_write(), GNUNET_DISK_SEEK_END, GNUNET_free, GNUNET_malloc, GNUNET_memcpy, GNUNET_NO, GNUNET_SYSERR, GNUNET_YES, GNUNET_MESSENGER_MessageEntryStorage::hash, GNUNET_MESSENGER_MessageEntry::length, GNUNET_MESSENGER_MessageEntry::offset, save(), GNUNET_MESSENGER_ClosureMessageSave::storage, GNUNET_MESSENGER_MessageStore::storage_messages, GNUNET_MESSENGER_ClosureMessageSave::store, and value.

Referenced by save_message_store().

252 {
254 
256  return GNUNET_YES;
257 
258  struct GNUNET_MESSENGER_Message *message = value;
260 
261  GNUNET_memcpy(&(storage.hash), key, sizeof(storage.hash));
262 
263  storage.entry.length = get_message_size (message, GNUNET_YES);
264  storage.entry.offset = GNUNET_DISK_file_seek (save->store->storage_messages, 0, GNUNET_DISK_SEEK_END);
265 
266  if ((GNUNET_SYSERR == storage.entry.offset) || (sizeof(storage)
267  != GNUNET_DISK_file_write (save->storage, &storage, sizeof(storage))))
268  return GNUNET_YES;
269 
270  char *buffer = GNUNET_malloc(storage.entry.length);
271 
272  encode_message (message, storage.entry.length, buffer, GNUNET_YES);
273 
274  GNUNET_DISK_file_write (save->store->storage_messages, buffer, storage.entry.length);
275 
276  GNUNET_free(buffer);
277 
278  return GNUNET_YES;
279 }
struct GNUNET_DISK_FileHandle * storage_messages
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
void encode_message(const struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer, int include_signature)
Encodes a given message into a buffer of a maximal length in bytes.
int GNUNET_CONTAINER_multihashmap_contains(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Check if the map contains any value under the given key (including values that are NULL)...
off_t GNUNET_DISK_file_seek(const struct GNUNET_DISK_FileHandle *h, off_t offset, enum GNUNET_DISK_Seek whence)
Move the read/write pointer in a file.
Definition: disk.c:206
static void save()
Write persistent statistics to disk.
static char * value
Value of the record to add/remove.
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
Definition: disk.c:666
Seek an absolute position from the end of the file.
#define GNUNET_malloc(size)
Wrapper around malloc.
struct GNUNET_CONTAINER_MultiHashMap * entries
#define GNUNET_free(ptr)
Wrapper around free.
uint16_t get_message_size(const struct GNUNET_MESSENGER_Message *message, int include_signature)
Returns the exact size in bytes to encode a given message.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ iterate_save_links()

static int iterate_save_links ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Definition at line 282 of file gnunet-service-messenger_message_store.c.

References GNUNET_MESSENGER_MessageLink::first, GNUNET_DISK_file_write(), GNUNET_YES, GNUNET_MESSENGER_MessageLink::multiple, save(), GNUNET_MESSENGER_MessageLink::second, GNUNET_MESSENGER_ClosureMessageSave::storage, and value.

Referenced by save_message_store().

283 {
285  struct GNUNET_MESSENGER_MessageLink *link = value;
286 
287  GNUNET_DISK_file_write (save->storage, key, sizeof(*key));
288  GNUNET_DISK_file_write (save->storage, &(link->multiple), sizeof(link->multiple));
289  GNUNET_DISK_file_write (save->storage, &(link->first), sizeof(link->first));
290 
291  if (GNUNET_YES == link->multiple)
292  GNUNET_DISK_file_write (save->storage, &(link->second), sizeof(link->second));
293 
294  return GNUNET_YES;
295 }
static void save()
Write persistent statistics to disk.
static char * value
Value of the record to add/remove.
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
Definition: disk.c:666
Here is the call graph for this function:
Here is the caller graph for this function:

◆ save_message_store()

void save_message_store ( struct GNUNET_MESSENGER_MessageStore store,
const char *  directory 
)

Saves messages from a message store into a directory.

Parameters
[in]storeMessage store
[in]directoryPath to a directory

Definition at line 298 of file gnunet-service-messenger_message_store.c.

References GNUNET_MESSENGER_MessageStore::entries, filename, GNUNET_asprintf(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_DISK_file_close(), GNUNET_DISK_file_open(), GNUNET_DISK_file_seek(), GNUNET_DISK_file_sync(), GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_OPEN_READWRITE, GNUNET_DISK_OPEN_WRITE, GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_DISK_SEEK_END, GNUNET_DISK_SEEK_SET, GNUNET_free, GNUNET_NO, GNUNET_SYSERR, GNUNET_YES, iterate_save_entries(), iterate_save_links(), iterate_save_messages(), GNUNET_MESSENGER_MessageStore::links, GNUNET_MESSENGER_MessageStore::messages, GNUNET_MESSENGER_MessageStore::rewrite_entries, GNUNET_MESSENGER_ClosureMessageSave::storage, GNUNET_MESSENGER_MessageStore::storage_messages, GNUNET_MESSENGER_ClosureMessageSave::store, and GNUNET_MESSENGER_MessageStore::write_links.

Referenced by save_room().

299 {
300  GNUNET_assert((store) && (directory));
301 
303 
305 
306  char *filename;
307 
308  if (GNUNET_YES != store->write_links)
309  goto save_entries;
310 
311  GNUNET_asprintf (&filename, "%s%s", directory, "links.store");
312 
313  save.store = store;
314  save.storage = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, permission);
315 
316  GNUNET_free(filename);
317 
318  if (!save.storage)
319  goto save_entries;
320 
322  goto close_links;
323 
325  store->write_links = GNUNET_NO;
326 
327 close_links:
328  GNUNET_DISK_file_close (save.storage);
329 
330 save_entries:
331  GNUNET_asprintf (&filename, "%s%s", directory, "entries.store");
332 
333  save.store = store;
334  save.storage = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, permission);
335 
336  GNUNET_free(filename);
337 
338  if (!save.storage)
339  return;
340 
341  if (GNUNET_YES == store->rewrite_entries)
342  {
344  goto close_entries;
345 
347  store->rewrite_entries = GNUNET_NO;
348  }
350  goto close_entries;
351 
352  if (store->storage_messages)
354 
355  GNUNET_asprintf (&filename, "%s%s", directory, "messages.store");
356 
358  permission);
359 
360  GNUNET_free(filename);
361 
362  if (store->storage_messages)
363  {
365 
367  GNUNET_DISK_file_sync (save.storage);
368  }
369 
370 close_entries:
371  GNUNET_DISK_file_close (save.storage);
372 }
Create file if it doesn't exist.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1126
struct GNUNET_DISK_FileHandle * storage_messages
struct GNUNET_CONTAINER_MultiHashMap * messages
off_t GNUNET_DISK_file_seek(const struct GNUNET_DISK_FileHandle *h, off_t offset, enum GNUNET_DISK_Seek whence)
Move the read/write pointer in a file.
Definition: disk.c:206
static void save()
Write persistent statistics to disk.
struct GNUNET_CONTAINER_MultiHashMap * links
static int iterate_save_messages(void *cls, const struct GNUNET_HashCode *key, void *value)
static int iterate_save_entries(void *cls, const struct GNUNET_HashCode *key, void *value)
static int iterate_save_links(void *cls, const struct GNUNET_HashCode *key, void *value)
static char * filename
GNUNET_DISK_AccessPermissions
File access permissions, UNIX-style.
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
Seek an absolute position from the end of the file.
Open the file for writing.
Seek an absolute position (from the start of the file).
enum GNUNET_GenericReturnValue GNUNET_DISK_file_sync(const struct GNUNET_DISK_FileHandle *h)
Write file changes to disk.
Definition: disk.c:1245
Open the file for both reading and writing.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
Definition: disk.c:1055
struct GNUNET_CONTAINER_MultiHashMap * entries
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ contains_store_message()

int contains_store_message ( const struct GNUNET_MESSENGER_MessageStore store,
const struct GNUNET_HashCode hash 
)

Checks if a message matching a given hash is stored in a message store.

The function returns GNUNET_YES if a match is found, GNUNET_NO otherwise.

The message has not to be loaded from disk into memory for this check!

Parameters
[in]storeMessage store
[in]hashHash of message
Returns
GNUNET_YES on match, otherwise GNUNET_NO

Definition at line 375 of file gnunet-service-messenger_message_store.c.

References GNUNET_MESSENGER_MessageStore::entries, GNUNET_assert, GNUNET_CONTAINER_multihashmap_contains(), GNUNET_YES, and GNUNET_MESSENGER_MessageStore::messages.

376 {
377  GNUNET_assert((store) && (hash));
378 
380  return GNUNET_YES;
381 
382  return GNUNET_CONTAINER_multihashmap_contains (store->entries, hash);
383 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_CONTAINER_MultiHashMap * messages
int GNUNET_CONTAINER_multihashmap_contains(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Check if the map contains any value under the given key (including values that are NULL)...
struct GNUNET_CONTAINER_MultiHashMap * entries
Here is the call graph for this function:

◆ get_store_message()

const struct GNUNET_MESSENGER_Message* get_store_message ( struct GNUNET_MESSENGER_MessageStore store,
const struct GNUNET_HashCode hash 
)

Returns the message from a message store matching a given hash.

If no matching message is found, NULL gets returned.

This function requires the message to be loaded into memory!

See also
contains_store_message()
Parameters

Definition at line 386 of file gnunet-service-messenger_message_store.c.

References create_message(), decode_message(), destroy_message(), GNUNET_MESSENGER_MessageStore::entries, get_message_kind_size(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_CRYPTO_hash_cmp(), GNUNET_DISK_file_read(), GNUNET_DISK_file_seek(), GNUNET_DISK_SEEK_SET, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_malloc, GNUNET_MESSENGER_KIND_UNKNOWN, GNUNET_OK, GNUNET_YES, hash_message(), GNUNET_MESSENGER_MessageEntry::length, GNUNET_MESSENGER_MessageStore::messages, GNUNET_MESSENGER_MessageEntry::offset, GNUNET_MESSENGER_MessageStore::rewrite_entries, and GNUNET_MESSENGER_MessageStore::storage_messages.

Referenced by callback_verify_room_message(), check_room_peer_status(), delete_room_message(), delete_store_message(), forward_about_members(), get_store_message_link(), handle_room_messages(), notify_about_members(), request_room_message_step(), update_room_message(), and update_tunnel_last_message().

387 {
388  GNUNET_assert((store) && (hash));
389 
391 
392  if (message)
393  return message;
394 
395  if (!store->storage_messages)
396  return NULL;
397 
398  const struct GNUNET_MESSENGER_MessageEntry *entry = GNUNET_CONTAINER_multihashmap_get (store->entries, hash);
399 
400  if (!entry)
401  return NULL;
402 
404  return message;
405 
406  char *buffer = GNUNET_malloc(entry->length);
407 
408  if (!buffer)
409  return NULL;
410 
411  if ((GNUNET_DISK_file_read (store->storage_messages, buffer, entry->length) != entry->length) ||
413  goto free_buffer;
414 
416 
417  const int decoding = decode_message (message, entry->length, buffer, GNUNET_YES, NULL);
418 
419  struct GNUNET_HashCode check;
420  hash_message (message, entry->length, buffer, &check);
421 
422  if ((GNUNET_YES != decoding) || (GNUNET_CRYPTO_hash_cmp (hash, &check) != 0))
423  {
424  if (GNUNET_YES != GNUNET_CONTAINER_multihashmap_remove (store->entries, hash, entry))
425  GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Corrupted entry could not be removed from store: %s\n",
426  GNUNET_h2s(hash));
427 
428  store->rewrite_entries = GNUNET_YES;
429 
430  goto free_message;
431  }
432 
433  if (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put (store->messages, hash, message,
435  goto free_buffer;
436 
437 free_message: destroy_message (message);
438  message = NULL;
439 
440 free_buffer:
441  GNUNET_free(buffer);
442 
443  return message;
444 }
void destroy_message(struct GNUNET_MESSENGER_Message *message)
Destroys a message and frees its memory fully.
ssize_t GNUNET_DISK_file_read(const struct GNUNET_DISK_FileHandle *h, void *result, size_t len)
Read the contents of a binary file into a buffer.
Definition: disk.c:602
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
int decode_message(struct GNUNET_MESSENGER_Message *message, uint16_t length, const char *buffer, int include_signature, uint16_t *padding)
Decodes a message from a given buffer of a maximal length in bytes.
struct GNUNET_DISK_FileHandle * storage_messages
struct GNUNET_CONTAINER_MultiHashMap * messages
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
off_t GNUNET_DISK_file_seek(const struct GNUNET_DISK_FileHandle *h, off_t offset, enum GNUNET_DISK_Seek whence)
Move the read/write pointer in a file.
Definition: disk.c:206
struct GNUNET_MESSENGER_Message * create_message(enum GNUNET_MESSENGER_MessageKind kind)
Creates and allocates a new message with a specific kind.
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_...
uint16_t get_message_kind_size(enum GNUNET_MESSENGER_MessageKind kind)
Returns the minimal size in bytes to encode a message of a specific kind.
int GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
A 512-bit hashcode.
void hash_message(const struct GNUNET_MESSENGER_Message *message, uint16_t length, const char *buffer, struct GNUNET_HashCode *hash)
Calculates a hash of a given buffer with a length in bytes from a message.
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
Seek an absolute position (from the start of the file).
int GNUNET_CRYPTO_hash_cmp(const struct GNUNET_HashCode *h1, const struct GNUNET_HashCode *h2)
Compare function for HashCodes, producing a total ordering of all hashcodes.
Definition: crypto_hash.c:201
#define GNUNET_log(kind,...)
#define GNUNET_malloc(size)
Wrapper around malloc.
struct GNUNET_CONTAINER_MultiHashMap * entries
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_store_message_link()

const struct GNUNET_MESSENGER_MessageLink* get_store_message_link ( struct GNUNET_MESSENGER_MessageStore store,
const struct GNUNET_HashCode hash,
int  deleted_only 
)

Returns the message link from a message store matching a given hash.

If the flag is set to GNUNET_YES, only links from deleted messages will be returned or NULL.

Otherwise message links will also returned for messages found in the store under the given hash. The link which will be returned copies link information from the message for temporary usage.

Parameters

Definition at line 447 of file gnunet-service-messenger_message_store.c.

References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_MessageLink::first, get_store_message(), GNUNET_CONTAINER_multihashmap_get(), GNUNET_memcpy, GNUNET_MESSENGER_KIND_MERGE, GNUNET_NO, GNUNET_YES, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_MessageStore::links, GNUNET_MESSENGER_MessageBody::merge, GNUNET_MESSENGER_MessageLink::multiple, GNUNET_MESSENGER_MessageMerge::previous, GNUNET_MESSENGER_MessageHeader::previous, and GNUNET_MESSENGER_MessageLink::second.

Referenced by check_member_session_completion(), and request_room_message_step().

449 {
450  if (deleted_only)
451  goto get_link;
452 
453  const struct GNUNET_MESSENGER_Message *message = get_store_message(store, hash);
454 
455  if (!message)
456  goto get_link;
457 
458  static struct GNUNET_MESSENGER_MessageLink link;
459 
460  GNUNET_memcpy(&(link.first), &(message->header.previous), sizeof(link.first));
461 
462  link.multiple = GNUNET_MESSENGER_KIND_MERGE == message->header.kind? GNUNET_YES : GNUNET_NO;
463 
464  if (GNUNET_YES == link.multiple)
465  GNUNET_memcpy(&(link.second), &(message->body.merge.previous), sizeof(link.second));
466  else
467  GNUNET_memcpy(&(link.second), &(message->header.previous), sizeof(link.second));
468 
469  return &link;
470 
471 get_link:
472  return GNUNET_CONTAINER_multihashmap_get (store->links, hash);
473 }
struct GNUNET_MESSENGER_MessageHeader header
Header.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
struct GNUNET_CONTAINER_MultiHashMap * links
struct GNUNET_HashCode previous
The hash of a second previous message.
struct GNUNET_MESSENGER_MessageBody body
Body.
struct GNUNET_MESSENGER_MessageMerge merge
const struct GNUNET_MESSENGER_Message * get_store_message(struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash)
Returns the message from a message store matching a given hash.
struct GNUNET_HashCode previous
The hash of the previous message from the senders perspective.
enum GNUNET_MESSENGER_MessageKind kind
The kind of the message.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ put_store_message()

int put_store_message ( struct GNUNET_MESSENGER_MessageStore store,
const struct GNUNET_HashCode hash,
struct GNUNET_MESSENGER_Message message 
)

Stores a message into the message store.

The result indicates if the operation was successful.

Parameters

Definition at line 476 of file gnunet-service-messenger_message_store.c.

References GNUNET_assert, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, and GNUNET_MESSENGER_MessageStore::messages.

Referenced by update_room_message().

478 {
479  GNUNET_assert((store) && (hash) && (message));
480 
481  return GNUNET_CONTAINER_multihashmap_put (store->messages, hash, message,
483 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_CONTAINER_MultiHashMap * messages
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_...
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_link()

static void add_link ( struct GNUNET_MESSENGER_MessageStore store,
const struct GNUNET_HashCode hash,
const struct GNUNET_MESSENGER_Message message 
)
static

Definition at line 486 of file gnunet-service-messenger_message_store.c.

References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_MessageLink::first, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_free, GNUNET_memcpy, GNUNET_MESSENGER_KIND_MERGE, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_YES, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_MessageStore::links, GNUNET_MESSENGER_MessageBody::merge, GNUNET_MESSENGER_MessageLink::multiple, GNUNET_MESSENGER_MessageMerge::previous, GNUNET_MESSENGER_MessageHeader::previous, and GNUNET_MESSENGER_MessageLink::second.

Referenced by delete_store_message().

488 {
490 
491  GNUNET_memcpy(&(link->first), &(message->header.previous), sizeof(link->first));
492 
494 
495  if (GNUNET_YES == link->multiple)
496  GNUNET_memcpy(&(link->second), &(message->body.merge.previous), sizeof(link->second));
497  else
498  GNUNET_memcpy(&(link->second), &(message->header.previous), sizeof(link->second));
499 
500  if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put(store->links, hash, link,
502  GNUNET_free(link);
503 }
struct GNUNET_MESSENGER_MessageHeader header
Header.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_CONTAINER_MultiHashMap * links
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_...
struct GNUNET_HashCode previous
The hash of a second previous message.
struct GNUNET_MESSENGER_MessageBody body
Body.
struct GNUNET_MESSENGER_MessageMerge merge
struct GNUNET_HashCode previous
The hash of the previous message from the senders perspective.
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
#define GNUNET_free(ptr)
Wrapper around free.
enum GNUNET_MESSENGER_MessageKind kind
The kind of the message.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ delete_store_message()

int delete_store_message ( struct GNUNET_MESSENGER_MessageStore store,
const struct GNUNET_HashCode hash 
)

Deletes a message in the message store.

It will be removed from disk space and memory. The result indicates if the operation was successful.

Parameters

Definition at line 506 of file gnunet-service-messenger_message_store.c.

References add_link(), GNUNET_MESSENGER_MessageStore::entries, get_store_message(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_CONTAINER_multihashmap_remove_all(), GNUNET_CRYPTO_zero_keys(), GNUNET_DISK_file_seek(), GNUNET_DISK_file_sync(), GNUNET_DISK_file_write(), GNUNET_DISK_SEEK_SET, GNUNET_free, GNUNET_malloc, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, GNUNET_MESSENGER_MessageEntry::length, GNUNET_MESSENGER_MessageStore::messages, GNUNET_MESSENGER_MessageEntry::offset, GNUNET_MESSENGER_MessageStore::rewrite_entries, and GNUNET_MESSENGER_MessageStore::storage_messages.

Referenced by callback_room_deletion().

507 {
508  GNUNET_assert((store) && (hash));
509 
510  const struct GNUNET_MESSENGER_MessageEntry *entry = GNUNET_CONTAINER_multihashmap_get (store->entries, hash);
511 
512  if (!entry)
513  goto clear_memory;
514 
515  const struct GNUNET_MESSENGER_Message *message = get_store_message(store, hash);
516 
517  if (message)
518  add_link (store, hash, message);
519 
520  if (!store->storage_messages)
521  goto clear_entry;
522 
524  return GNUNET_SYSERR;
525 
526  char *clear_buffer = GNUNET_malloc(entry->length);
527 
528  if (!clear_buffer)
529  return GNUNET_SYSERR;
530 
531  GNUNET_CRYPTO_zero_keys (clear_buffer, entry->length);
532 
533  if ((entry->length != GNUNET_DISK_file_write (store->storage_messages, clear_buffer, entry->length)) || (GNUNET_OK
535  {
536  GNUNET_free(clear_buffer);
537  return GNUNET_SYSERR;
538  }
539 
540  GNUNET_free(clear_buffer);
541 
542 clear_entry:
543  if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove (store->entries, hash, entry))
544  store->rewrite_entries = GNUNET_YES;
545 
546 clear_memory:
548  return GNUNET_OK;
549 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_DISK_FileHandle * storage_messages
struct GNUNET_CONTAINER_MultiHashMap * messages
int GNUNET_CONTAINER_multihashmap_remove_all(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Remove all entries for the given key from the map.
off_t GNUNET_DISK_file_seek(const struct GNUNET_DISK_FileHandle *h, off_t offset, enum GNUNET_DISK_Seek whence)
Move the read/write pointer in a file.
Definition: disk.c:206
void GNUNET_CRYPTO_zero_keys(void *buffer, size_t length)
Zero out buffer, securely against compiler optimizations.
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
static void add_link(struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_Message *message)
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
Definition: disk.c:666
int GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
const struct GNUNET_MESSENGER_Message * get_store_message(struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash)
Returns the message from a message store matching a given hash.
Seek an absolute position (from the start of the file).
enum GNUNET_GenericReturnValue GNUNET_DISK_file_sync(const struct GNUNET_DISK_FileHandle *h)
Write file changes to disk.
Definition: disk.c:1245
#define GNUNET_malloc(size)
Wrapper around malloc.
struct GNUNET_CONTAINER_MultiHashMap * entries
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function: