#include "platform.h"
#include "gnunet-service-messenger_operation_store.h"
#include "gnunet-service-messenger_operation.h"
#include "gnunet-service-messenger_room.h"
Go to the source code of this file.
Functions | |
void | init_operation_store (struct GNUNET_MESSENGER_OperationStore *store, struct GNUNET_MESSENGER_SrvRoom *room) |
Initializes an operation store as fully empty with a given room. More... | |
static enum GNUNET_GenericReturnValue | iterate_destroy_operations (void *cls, const struct GNUNET_HashCode *key, void *value) |
void | clear_operation_store (struct GNUNET_MESSENGER_OperationStore *store) |
Clears an operation store, stops all operations and deallocates its memory. More... | |
static enum GNUNET_GenericReturnValue | callback_scan_for_operations (void *cls, const char *filename) |
void | load_operation_store (struct GNUNET_MESSENGER_OperationStore *store, const char *directory) |
Loads operations from a directory into an operation store. More... | |
static enum GNUNET_GenericReturnValue | iterate_save_operations (void *cls, const struct GNUNET_HashCode *key, void *value) |
void | save_operation_store (const struct GNUNET_MESSENGER_OperationStore *store, const char *directory) |
Saves operations from an operation store into a directory. More... | |
enum GNUNET_MESSENGER_OperationType | get_store_operation_type (const struct GNUNET_MESSENGER_OperationStore *store, const struct GNUNET_HashCode *hash) |
Returns the type of the active operation under a given hash in a specific operation store. More... | |
enum GNUNET_GenericReturnValue | use_store_operation (struct GNUNET_MESSENGER_OperationStore *store, const struct GNUNET_HashCode *hash, enum GNUNET_MESSENGER_OperationType type, struct GNUNET_TIME_Relative delay) |
Tries to use an operation under a given hash in a specific operation store. More... | |
void | cancel_store_operation (struct GNUNET_MESSENGER_OperationStore *store, const struct GNUNET_HashCode *hash) |
Stops any active operation under a given hash in a specific operation store. More... | |
void init_operation_store | ( | struct GNUNET_MESSENGER_OperationStore * | store, |
struct GNUNET_MESSENGER_SrvRoom * | room | ||
) |
Initializes an operation store as fully empty with a given room.
[out] | store | Operation store |
[in,out] | room | Room |
Definition at line 33 of file gnunet-service-messenger_operation_store.c.
References GNUNET_assert, GNUNET_CONTAINER_multihashmap_create(), GNUNET_NO, GNUNET_MESSENGER_OperationStore::operations, and GNUNET_MESSENGER_OperationStore::room.
Referenced by create_srv_room().
|
static |
Definition at line 44 of file gnunet-service-messenger_operation_store.c.
References destroy_operation(), GNUNET_assert, GNUNET_YES, op, and value.
Referenced by clear_operation_store().
void clear_operation_store | ( | struct GNUNET_MESSENGER_OperationStore * | store | ) |
Clears an operation store, stops all operations and deallocates its memory.
[in,out] | store | Operation store |
Definition at line 60 of file gnunet-service-messenger_operation_store.c.
References get_srv_room_key(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, iterate_destroy_operations(), GNUNET_MESSENGER_OperationStore::operations, GNUNET_MESSENGER_OperationStore::room, and GNUNET_MESSENGER_Operation::store.
Referenced by destroy_srv_room().
|
static |
Definition at line 74 of file gnunet-service-messenger_operation_store.c.
References destroy_operation(), filename, GNUNET_assert, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_DISK_file_test(), GNUNET_OK, GNUNET_YES, load_operation(), op, GNUNET_MESSENGER_OperationStore::operations, and GNUNET_MESSENGER_Operation::store.
Referenced by load_operation_store().
void load_operation_store | ( | struct GNUNET_MESSENGER_OperationStore * | store, |
const char * | directory | ||
) |
Loads operations from a directory into an operation store.
[out] | store | Operation store |
[in] | directory | Path to a directory |
Definition at line 106 of file gnunet-service-messenger_operation_store.c.
References callback_scan_for_operations(), DIR_SEPARATOR, GNUNET_asprintf(), GNUNET_assert, GNUNET_DISK_directory_scan(), GNUNET_DISK_directory_test(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_OK, GNUNET_YES, and GNUNET_MESSENGER_Operation::store.
Referenced by load_srv_room().
|
static |
Definition at line 127 of file gnunet-service-messenger_operation_store.c.
References GNUNET_asprintf(), GNUNET_assert, GNUNET_free, GNUNET_h2s(), GNUNET_YES, key, op, save_operation(), and value.
Referenced by save_operation_store().
void save_operation_store | ( | const struct GNUNET_MESSENGER_OperationStore * | store, |
const char * | directory | ||
) |
Saves operations from an operation store into a directory.
[in] | store | Operation store |
[in] | directory | Path to a directory |
Definition at line 152 of file gnunet-service-messenger_operation_store.c.
References DIR_SEPARATOR, GNUNET_asprintf(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_DISK_directory_create(), GNUNET_DISK_directory_test(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_YES, iterate_save_operations(), GNUNET_MESSENGER_OperationStore::operations, and GNUNET_MESSENGER_Operation::store.
Referenced by save_srv_room().
enum GNUNET_MESSENGER_OperationType get_store_operation_type | ( | const struct GNUNET_MESSENGER_OperationStore * | store, |
const struct GNUNET_HashCode * | hash | ||
) |
Returns the type of the active operation under a given hash in a specific operation store.
If there is no active operation under the given hash, GNUNET_MESSENGER_OP_UNKNOWN gets returned instead.
[in] | store | Operation store |
[in] | hash | Hash of message |
Definition at line 175 of file gnunet-service-messenger_operation_store.c.
References GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_MESSENGER_OP_UNKNOWN, GNUNET_MESSENGER_Operation::hash, op, GNUNET_MESSENGER_OperationStore::operations, and GNUNET_MESSENGER_Operation::store.
Referenced by idle_request_room_messages(), update_room_message(), and update_tunnel_last_message().
enum GNUNET_GenericReturnValue use_store_operation | ( | struct GNUNET_MESSENGER_OperationStore * | store, |
const struct GNUNET_HashCode * | hash, | ||
enum GNUNET_MESSENGER_OperationType | type, | ||
struct GNUNET_TIME_Relative | delay | ||
) |
Tries to use an operation under a given hash in a specific operation store.
The operation will use the selected type if successful. The operation will be delayed by a given delay.
If the selected type is GNUNET_MESSENGER_OP_DELETE any active operation under the given hash will be stopped and replaced.
If the new operation could be started successfully the method returns GNUNET_OK, otherwise GNUNET_SYSERR.
[in,out] | store | Operation store |
[in] | hash | Hash of message |
[in] | type | Operation type |
[in] | delay | Delay |
Definition at line 192 of file gnunet-service-messenger_operation_store.c.
References create_operation(), destroy_operation(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_MESSENGER_OP_DELETE, GNUNET_MESSENGER_OP_UNKNOWN, GNUNET_OK, GNUNET_SYSERR, GNUNET_MESSENGER_Operation::hash, op, GNUNET_MESSENGER_OperationStore::operations, start_operation(), stop_operation(), GNUNET_MESSENGER_Operation::store, and type.
Referenced by callback_found_message(), delete_srv_room_message(), idle_request_room_messages(), and send_message_request().
void cancel_store_operation | ( | struct GNUNET_MESSENGER_OperationStore * | store, |
const struct GNUNET_HashCode * | hash | ||
) |
Stops any active operation under a given hash in a specific operation store.
Beware that calling this method will also implicitly free the memory of any active operation under the given hash!
[in,out] | store | Operation store |
[in] | hash | Hash of message |
Definition at line 227 of file gnunet-service-messenger_operation_store.c.
References destroy_operation(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_ERROR_TYPE_WARNING, GNUNET_h2s(), GNUNET_log, GNUNET_YES, GNUNET_MESSENGER_Operation::hash, op, GNUNET_MESSENGER_OperationStore::operations, stop_operation(), and GNUNET_MESSENGER_Operation::store.
Referenced by callback_operation(), and update_room_message().