#include "gnunet-service-messenger_operation.h"
#include "gnunet-service-messenger_message_kind.h"
#include "gnunet-service-messenger_operation_store.h"
#include "gnunet-service-messenger_room.h"
Go to the source code of this file.
Functions | |
struct GNUNET_MESSENGER_Operation * | create_operation (const struct GNUNET_HashCode *hash) |
Creates and allocates a new operation under a given hash. More... | |
void | destroy_operation (struct GNUNET_MESSENGER_Operation *op) |
Destroys an operation and frees its memory fully. More... | |
static void | callback_operation (void *cls) |
struct GNUNET_MESSENGER_Operation * | load_operation (struct GNUNET_MESSENGER_OperationStore *store, const char *path) |
Loads data from a configuration file at a selected path into a new allocated and created operation for a specific operation store if the required information could be read successfully. More... | |
void | save_operation (const struct GNUNET_MESSENGER_Operation *op, const char *path) |
Saves data from an operation into a configuration file at a selected path which can be load to restore the operation completely and continue its process. More... | |
void | callback_room_deletion (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_HashCode *hash) |
void | callback_room_merge (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_HashCode *hash) |
enum GNUNET_GenericReturnValue | start_operation (struct GNUNET_MESSENGER_Operation *op, enum GNUNET_MESSENGER_OperationType type, struct GNUNET_MESSENGER_OperationStore *store, struct GNUNET_TIME_Relative delay) |
Starts an inactive operation with a given delay in a specific operation store. More... | |
enum GNUNET_GenericReturnValue | stop_operation (struct GNUNET_MESSENGER_Operation *op) |
Stops an active operation and resets its type to be GNUNET_MESSENGER_OP_UNKNOWN. More... | |
struct GNUNET_MESSENGER_Operation * create_operation | ( | const struct GNUNET_HashCode * | hash | ) |
Creates and allocates a new operation under a given hash.
[in] | hash | Hash of message |
Definition at line 33 of file gnunet-service-messenger_operation.c.
References GNUNET_assert, GNUNET_memcpy, GNUNET_MESSENGER_OP_UNKNOWN, GNUNET_new, GNUNET_TIME_absolute_get_zero_(), GNUNET_MESSENGER_Operation::hash, and op.
Referenced by load_operation(), and use_store_operation().
void destroy_operation | ( | struct GNUNET_MESSENGER_Operation * | op | ) |
Destroys an operation and frees its memory fully.
[in,out] | op | Operation |
Definition at line 52 of file gnunet-service-messenger_operation.c.
References GNUNET_assert, GNUNET_free, GNUNET_SCHEDULER_cancel(), and op.
Referenced by callback_scan_for_operations(), cancel_store_operation(), iterate_destroy_operations(), load_operation(), and use_store_operation().
|
static |
Definition at line 206 of file gnunet-service-messenger_operation.c.
References cancel_store_operation(), create_message_merge(), delete_store_message(), get_srv_room_message_store(), GNUNET_assert, GNUNET_ERROR_TYPE_WARNING, GNUNET_h2s(), GNUNET_log, GNUNET_memcpy, GNUNET_MESSENGER_OP_DELETE, GNUNET_MESSENGER_OP_MERGE, GNUNET_MESSENGER_OP_REQUEST, GNUNET_OK, GNUNET_MESSENGER_SrvRoom::host, op, GNUNET_MESSENGER_OperationStore::room, send_srv_room_message(), and type.
Referenced by load_operation(), and start_operation().
struct GNUNET_MESSENGER_Operation * load_operation | ( | struct GNUNET_MESSENGER_OperationStore * | store, |
const char * | path | ||
) |
Loads data from a configuration file at a selected path into a new allocated and created operation for a specific operation store if the required information could be read successfully.
The method will return the new operation and it will be started automatically to match its timestamp of execution.
If the method fails to restore any valid operation from the file, NULL gets returned instead.
[in,out] | store | Operation store |
[in] | path | Path of a configuration file |
Definition at line 67 of file gnunet-service-messenger_operation.c.
References callback_operation(), cfg, create_operation(), destroy_operation(), GNUNET_assert, GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_destroy(), GNUNET_CONFIGURATION_get_data(), GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_parse(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSENGER_OP_DELETE, GNUNET_MESSENGER_OP_MERGE, GNUNET_MESSENGER_OP_REQUEST, GNUNET_MESSENGER_OP_UNKNOWN, GNUNET_OK, GNUNET_OS_project_data_gnunet(), GNUNET_SCHEDULER_add_delayed_with_priority(), GNUNET_SCHEDULER_PRIORITY_BACKGROUND, GNUNET_TIME_absolute_get_remaining(), op, and GNUNET_MESSENGER_Operation::store.
Referenced by callback_scan_for_operations().
void save_operation | ( | const struct GNUNET_MESSENGER_Operation * | op, |
const char * | path | ||
) |
Saves data from an operation into a configuration file at a selected path which can be load to restore the operation completely and continue its process.
[in] | op | Operation |
[in] | path | Path of a configuration file |
Definition at line 152 of file gnunet-service-messenger_operation.c.
References cfg, GNUNET_assert, GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_destroy(), GNUNET_CONFIGURATION_set_value_number(), GNUNET_CONFIGURATION_set_value_string(), GNUNET_CONFIGURATION_write(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_OS_project_data_gnunet(), GNUNET_STRINGS_data_to_string_alloc(), and op.
Referenced by iterate_save_operations().
void callback_room_deletion | ( | struct GNUNET_MESSENGER_SrvRoom * | room, |
const struct GNUNET_HashCode * | hash | ||
) |
void callback_room_merge | ( | struct GNUNET_MESSENGER_SrvRoom * | room, |
const struct GNUNET_HashCode * | hash | ||
) |
enum GNUNET_GenericReturnValue start_operation | ( | struct GNUNET_MESSENGER_Operation * | op, |
enum GNUNET_MESSENGER_OperationType | type, | ||
struct GNUNET_MESSENGER_OperationStore * | store, | ||
struct GNUNET_TIME_Relative | delay | ||
) |
Starts an inactive operation with a given delay in a specific operation store.
The method will replace the operations type to process it correctly. An operation can't be started twice, it has to be stopped or fully processed first.
[in,out] | op | Operation |
[in] | type | Type of operation |
[in,out] | store | Operation store |
[in] | delay | Delay |
Definition at line 261 of file gnunet-service-messenger_operation.c.
References callback_operation(), GNUNET_assert, GNUNET_OK, GNUNET_SCHEDULER_add_delayed_with_priority(), GNUNET_SCHEDULER_PRIORITY_BACKGROUND, GNUNET_SYSERR, GNUNET_TIME_absolute_add(), GNUNET_TIME_absolute_get(), op, timestamp(), and type.
Referenced by use_store_operation().
enum GNUNET_GenericReturnValue stop_operation | ( | struct GNUNET_MESSENGER_Operation * | op | ) |
Stops an active operation and resets its type to be GNUNET_MESSENGER_OP_UNKNOWN.
Definition at line 291 of file gnunet-service-messenger_operation.c.
References GNUNET_assert, GNUNET_MESSENGER_OP_UNKNOWN, GNUNET_OK, GNUNET_SCHEDULER_cancel(), GNUNET_SYSERR, GNUNET_TIME_absolute_get_zero_(), and op.
Referenced by cancel_store_operation(), and use_store_operation().