the automated restart manager service More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_arm_service.h"
#include "gnunet_protocols.h"
#include "arm.h"
Go to the source code of this file.
Data Structures | |
struct | ServiceListeningInfo |
Record with information about a listen socket we have open. More... | |
struct | ServiceList |
List of our services. More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "util", __VA_ARGS__) |
#define | LOG_STRERROR(kind, syscall) GNUNET_log_from_strerror (kind, "util", syscall) |
#define | MAX_NOTIFY_QUEUE 1024 |
How many messages do we queue up at most for optional notifications to a client? (this can cause notifications about outgoing messages to be dropped). More... | |
Functions | |
static void | add_unixpath (struct sockaddr **saddrs, socklen_t *saddrlens, const char *unixpath, int abstract) |
Add the given UNIX domain path as an address to the list (as the first entry). More... | |
static int | get_server_addresses (const char *service_name, const struct GNUNET_CONFIGURATION_Handle *cfg_, struct sockaddr ***addrs, socklen_t **addr_lens) |
Get the list of addresses that a server for the given service should bind to. More... | |
static void | signal_result (struct GNUNET_SERVICE_Client *client, const char *name, uint64_t request_id, enum GNUNET_ARM_Result result) |
Signal our client that we will start or stop the service. More... | |
static void | broadcast_status (const char *name, enum GNUNET_ARM_ServiceMonitorStatus status, struct GNUNET_SERVICE_Client *unicast) |
Tell all clients about status change of a service. More... | |
static void | start_process (struct ServiceList *sl, struct GNUNET_SERVICE_Client *client, uint64_t request_id) |
Actually start the process for the given service. More... | |
static struct ServiceList * | find_service (const char *name) |
Find the process with the given service name in the given list and return it. More... | |
static void | accept_connection (void *cls) |
First connection has come to the listening socket associated with the service, create the service in order to relay the incoming connection to it. More... | |
static void | create_listen_socket (struct sockaddr *sa, socklen_t addr_len, struct ServiceList *sl) |
Creating a listening socket for each of the service's addresses and wait for the first incoming connection to it. More... | |
static void | free_service (struct ServiceList *sl) |
Remove and free an entry in the service list. More... | |
static int | check_start (void *cls, const struct GNUNET_ARM_Message *amsg) |
Check START-message. More... | |
static void | handle_start (void *cls, const struct GNUNET_ARM_Message *amsg) |
Handle START-message. More... | |
static void | trigger_shutdown (void *cls) |
Start a shutdown sequence. More... | |
static int | check_stop (void *cls, const struct GNUNET_ARM_Message *amsg) |
Check STOP-message. More... | |
static void | handle_stop (void *cls, const struct GNUNET_ARM_Message *amsg) |
Handle STOP-message. More... | |
static int | pool_write (char *pool_start, size_t pool_size, size_t *pool_pos, char *str) |
Write a string to a string pool. More... | |
static void | handle_list (void *cls, const struct GNUNET_ARM_Message *request) |
Handle LIST-message. More... | |
static void | handle_test (void *cls, const struct GNUNET_MessageHeader *message) |
Handle TEST-message by sending back TEST. More... | |
static void | do_shutdown () |
We are done with everything. More... | |
static unsigned int | list_count (struct ServiceList *run_head) |
Count how many services are still active. More... | |
static void | shutdown_task (void *cls) |
Task run for shutdown. More... | |
static void | delayed_restart_task (void *cls) |
Task run whenever it is time to restart a child that died. More... | |
static void | maint_child_death (void *cls) |
Task triggered whenever we receive a SIGCHLD (child process died). More... | |
static void | sighandler_child_death () |
Signal handler called for SIGCHLD. More... | |
static void | setup_service (void *cls, const char *section) |
Setup our service record for the given section in the configuration file (assuming the section is for a service). More... | |
static void * | client_connect_cb (void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq) |
A client connected, mark as a monitoring client. More... | |
static void | client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *client, void *app_ctx) |
A client disconnected, clean up associated state. More... | |
static void | handle_monitor (void *cls, const struct GNUNET_MessageHeader *message) |
Handle MONITOR-message. More... | |
static void | run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *serv) |
Process arm requests. More... | |
int | main (int argc, char *const *argv) |
The main function for the arm service. More... | |
Variables | |
static struct ServiceList * | running_head |
List of running services. More... | |
static struct ServiceList * | running_tail |
List of running services. More... | |
static const struct GNUNET_CONFIGURATION_Handle * | cfg |
Our configuration. More... | |
static char * | prefix_command |
Command to prepend to each actual command. More... | |
static char * | final_option |
Option to append to each actual command. More... | |
static struct GNUNET_SCHEDULER_Task * | child_death_task |
ID of task called whenever we get a SIGCHILD. More... | |
static struct GNUNET_SCHEDULER_Task * | child_restart_task |
ID of task called whenever the timeout for restarting a child expires. More... | |
static struct GNUNET_DISK_PipeHandle * | sigpipe |
Pipe used to communicate shutdown via signal. More... | |
static int | in_shutdown |
Are we in shutdown mode? More... | |
static int | global_ret |
Return value from main. More... | |
static int | start_user = GNUNET_YES |
Are we starting user services? More... | |
static int | start_system = GNUNET_YES |
Are we starting system services? More... | |
static struct GNUNET_SERVICE_Handle * | service |
Handle to our service instance. More... | |
static struct GNUNET_NotificationContext * | notifier |
Context for notifications we need to send to our clients. More... | |
the automated restart manager service
Definition in file gnunet-service-arm.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "util", __VA_ARGS__) |
Definition at line 32 of file gnunet-service-arm.c.
#define LOG_STRERROR | ( | kind, | |
syscall | |||
) | GNUNET_log_from_strerror (kind, "util", syscall) |
Definition at line 34 of file gnunet-service-arm.c.
#define MAX_NOTIFY_QUEUE 1024 |
How many messages do we queue up at most for optional notifications to a client? (this can cause notifications about outgoing messages to be dropped).
Definition at line 56 of file gnunet-service-arm.c.
|
static |
Add the given UNIX domain path as an address to the list (as the first entry).
saddrs | array to update |
saddrlens | where to store the address length |
unixpath | path to add |
abstract | GNUNET_YES to add an abstract UNIX domain socket. This parameter is ignore on systems other than LINUX |
Definition at line 293 of file gnunet-service-arm.c.
References GNUNET_assert, GNUNET_new, GNUNET_strlcpy(), and GNUNET_YES.
Referenced by get_server_addresses().
|
static |
Get the list of addresses that a server for the given service should bind to.
service_name | name of the service |
cfg | configuration (which specifies the addresses) |
addrs | set (call by reference) to an array of pointers to the addresses the server should bind to and listen on; the array will be NULL-terminated (on success) |
addr_lens | set (call by reference) to an array of the lengths of the respective struct sockaddr struct in the addrs array (on success) |
*addrs
and *addr_lens
will be set to NULL). Definition at line 342 of file gnunet-service-arm.c.
References _, add_unixpath(), cfg, GNUNET_a2s(), GNUNET_assert, GNUNET_break, GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_CONFIGURATION_have_value(), GNUNET_DISK_directory_create_for_file(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log_strerror_file, GNUNET_malloc, GNUNET_memcpy, GNUNET_NETWORK_shorten_unixpath(), GNUNET_NETWORK_socket_close(), GNUNET_NETWORK_socket_create(), GNUNET_new_array, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, LOG, LOG_STRERROR, port, res, ret, and service_name.
Referenced by setup_service().
|
static |
Signal our client that we will start or stop the service.
client | who is being signalled |
name | name of the service |
request_id | id of the request that is being responded to. |
result | message type to send |
Definition at line 675 of file gnunet-service-arm.c.
References env, GNUNET_htonll(), GNUNET_MESSAGE_TYPE_ARM_RESULT, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SERVICE_client_get_mq(), msg, name, and result.
Referenced by handle_start(), handle_stop(), maint_child_death(), and start_process().
|
static |
Tell all clients about status change of a service.
name | name of the service |
status | message type to send |
unicast | if not NULL, send to this client only. otherwise, send to all clients in the notifier |
Definition at line 700 of file gnunet-service-arm.c.
References env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_ARM_STATUS, GNUNET_MQ_discard(), GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_notification_context_broadcast(), GNUNET_SERVICE_client_get_mq(), GNUNET_YES, msg, name, notifier, and status.
Referenced by handle_monitor(), handle_stop(), maint_child_death(), and start_process().
|
static |
Actually start the process for the given service.
sl | identifies service to start |
client | that asked to start the service (may be NULL) |
request_id | id of the request in response to which the process is being started. 0 if starting was not requested. |
Definition at line 745 of file gnunet-service-arm.c.
References ServiceList::binary, broadcast_status(), cfg, warningfilter::choices, ServiceList::config, final_option, GNUNET_ARM_RESULT_START_FAILED, GNUNET_ARM_RESULT_STARTING, GNUNET_ARM_SERVICE_STARTING, GNUNET_array_append, GNUNET_array_grow, GNUNET_asprintf(), GNUNET_assert, GNUNET_CONFIGURATION_expand_dollar(), GNUNET_CONFIGURATION_get_value_choice(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_log, GNUNET_NETWORK_get_fd(), GNUNET_OK, GNUNET_OS_get_libexec_binary_path(), GNUNET_OS_INHERIT_STD_OUT_AND_ERR, GNUNET_OS_project_data_gnunet(), GNUNET_OS_start_process_s(), GNUNET_OS_USE_PIPE_CONTROL, GNUNET_SCHEDULER_cancel(), GNUNET_strdup, GNUNET_TIME_absolute_get(), GNUNET_YES, ServiceList::last_started_at, ServiceList::listen_head, ls, ServiceList::name, ServiceListeningInfo::next, options, ServiceList::pipe_control, prefix_command, ServiceList::proc, and signal_result().
Referenced by accept_connection(), delayed_restart_task(), handle_start(), and run().
|
static |
Find the process with the given service name in the given list and return it.
name | which service entry to look up |
Definition at line 1004 of file gnunet-service-arm.c.
References name, ServiceList::name, ServiceList::next, and running_head.
Referenced by handle_start(), handle_stop(), and setup_service().
|
static |
First connection has come to the listening socket associated with the service, create the service in order to relay the incoming connection to it.
cls | callback data, struct ServiceListeningInfo describing a listen socket |
Definition at line 1026 of file gnunet-service-arm.c.
References ServiceListeningInfo::accept_task, GNUNET_assert, GNUNET_NO, in_shutdown, ServiceListeningInfo::sl, and start_process().
Referenced by create_listen_socket(), delayed_restart_task(), and maint_child_death().
|
static |
Creating a listening socket for each of the service's addresses and wait for the first incoming connection to it.
sa | address associated with the service |
addr_len | length of sa |
sl | service entry for the service in question |
Definition at line 1046 of file gnunet-service-arm.c.
References _, accept_connection(), ServiceListeningInfo::accept_task, cfg, GNUNET_a2s(), GNUNET_break, GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_CONTAINER_DLL_insert, GNUNET_DISK_fix_permissions(), GNUNET_ERROR_TYPE_BULK, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_log_strerror, GNUNET_NETWORK_socket_bind(), GNUNET_NETWORK_socket_close(), GNUNET_NETWORK_socket_create(), GNUNET_NETWORK_socket_listen(), GNUNET_NETWORK_socket_setsockopt(), GNUNET_NETWORK_unix_precheck(), GNUNET_new, GNUNET_OK, GNUNET_SCHEDULER_add_read_net(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, ServiceList::listen_head, ServiceListeningInfo::listen_socket, ServiceList::listen_tail, ServiceList::name, ServiceListeningInfo::service_addr, ServiceListeningInfo::service_addr_len, and ServiceListeningInfo::sl.
Referenced by setup_service().
|
static |
Remove and free an entry in the service list.
Listen sockets must have already been cleaned up. Only to be called during shutdown.
sl | entry to free |
Definition at line 1175 of file gnunet-service-arm.c.
References ServiceList::binary, ServiceList::config, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_YES, in_shutdown, ServiceList::listen_head, ServiceList::name, running_head, running_tail, and ServiceListeningInfo::sl.
Referenced by maint_child_death(), and shutdown_task().
|
static |
Check START-message.
cls | identification of the client |
amsg | the actual message |
Definition at line 1196 of file gnunet-service-arm.c.
References GNUNET_MQ_check_zero_termination, and GNUNET_OK.
|
static |
Handle START-message.
cls | identification of the client |
amsg | the actual message |
Definition at line 1211 of file gnunet-service-arm.c.
References find_service(), ServiceList::force_start, GNUNET_ARM_RESULT_IN_SHUTDOWN, GNUNET_ARM_RESULT_IS_NOT_KNOWN, GNUNET_ARM_RESULT_IS_STARTED_ALREADY, GNUNET_ntohll(), GNUNET_SERVICE_client_continue(), GNUNET_YES, in_shutdown, ServiceList::proc, GNUNET_ARM_Message::request_id, signal_result(), and start_process().
|
static |
Start a shutdown sequence.
cls | closure (refers to service) |
Definition at line 1257 of file gnunet-service-arm.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, and GNUNET_SCHEDULER_shutdown().
Referenced by handle_stop().
|
static |
Check STOP-message.
cls | identification of the client |
amsg | the actual message |
Definition at line 1274 of file gnunet-service-arm.c.
References GNUNET_MQ_check_zero_termination, and GNUNET_OK.
|
static |
Handle STOP-message.
cls | identification of the client |
amsg | the actual message |
Definition at line 1289 of file gnunet-service-arm.c.
References _, broadcast_status(), find_service(), ServiceList::force_start, GNUNET_ARM_RESULT_IN_SHUTDOWN, GNUNET_ARM_RESULT_IS_NOT_KNOWN, GNUNET_ARM_RESULT_IS_STOPPED_ALREADY, GNUNET_ARM_RESULT_IS_STOPPING_ALREADY, GNUNET_ARM_RESULT_STOPPING, GNUNET_ARM_SERVICE_STOPPING, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_log_strerror, GNUNET_NO, GNUNET_ntohll(), GNUNET_OS_process_kill(), GNUNET_SCHEDULER_add_now(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_persist(), GNUNET_TERM_SIG, GNUNET_TIME_absolute_get(), GNUNET_YES, in_shutdown, ServiceList::killed_at, ServiceList::killing_client, ServiceList::killing_client_request_id, ServiceList::proc, GNUNET_ARM_Message::request_id, signal_result(), and trigger_shutdown().
|
static |
Write a string to a string pool.
pool_start | pointer to the start of the string pool | |
pool_size | size of the string pool | |
[in,out] | pool_pos | current position index in the string pool, will be updated |
str | string to write to the string pool |
Definition at line 1372 of file gnunet-service-arm.c.
References GNUNET_OK, and GNUNET_SYSERR.
Referenced by handle_list().
|
static |
Handle LIST-message.
cls | identification of the client |
request | the actual message |
Definition at line 1391 of file gnunet-service-arm.c.
References GNUNET_TIME_Absolute::abs_value_us, ServiceList::binary, GNUNET_ARM_ServiceInfoMessage::binary_index, env, GNUNET_ARM_SERVICE_STATUS_FAILED, GNUNET_ARM_SERVICE_STATUS_FINISHED, GNUNET_ARM_SERVICE_STATUS_STARTED, GNUNET_ARM_SERVICE_STATUS_STOPPED, GNUNET_ARM_SERVICE_STATUS_STOPPING, GNUNET_assert, GNUNET_break_op, GNUNET_MESSAGE_TYPE_ARM_LIST_RESULT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_OK, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_get_mq(), GNUNET_TIME_absolute_hton(), GNUNET_YES, in_shutdown, ServiceList::killing_client, GNUNET_ARM_ServiceInfoMessage::last_exit_status, ServiceList::last_exit_status, GNUNET_ARM_ServiceInfoMessage::last_started_at, ServiceList::last_started_at, msg, ServiceList::name, GNUNET_ARM_ServiceInfoMessage::name_index, ServiceList::next, pool_write(), ServiceList::proc, request, GNUNET_VPN_RedirectionRequest::request_id, GNUNET_ARM_ServiceInfoMessage::restart_at, ServiceList::restart_at, running_head, and GNUNET_ARM_ServiceInfoMessage::status.
|
static |
Handle TEST-message by sending back TEST.
cls | identification of the client |
message | the actual message |
Definition at line 1478 of file gnunet-service-arm.c.
References env, GNUNET_MESSAGE_TYPE_ARM_TEST, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_get_mq(), and msg.
|
static |
We are done with everything.
Stop remaining tasks, signal handler and the server.
Definition at line 1496 of file gnunet-service-arm.c.
References child_death_task, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_notification_context_destroy(), GNUNET_SCHEDULER_cancel(), GNUNET_SERVICE_shutdown(), notifier, and service.
Referenced by maint_child_death(), and shutdown_task().
|
static |
Count how many services are still active.
running_head | list of services |
Definition at line 1524 of file gnunet-service-arm.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, ServiceList::name, ServiceList::next, and res.
Referenced by maint_child_death(), and shutdown_task().
|
static |
Task run for shutdown.
cls | closure, NULL if we need to self-restart |
Definition at line 1541 of file gnunet-service-arm.c.
References ServiceListeningInfo::accept_task, child_restart_task, do_shutdown(), free_service(), GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_log_strerror, GNUNET_NETWORK_socket_close(), GNUNET_OK, GNUNET_OS_process_kill(), GNUNET_SCHEDULER_cancel(), GNUNET_TERM_SIG, GNUNET_TIME_absolute_get(), GNUNET_YES, in_shutdown, ServiceList::killed_at, list_count(), ServiceList::listen_head, ServiceListeningInfo::listen_socket, ServiceList::listen_tail, ServiceList::name, ServiceList::next, ServiceList::proc, running_head, and ServiceListeningInfo::service_addr.
Referenced by run().
|
static |
Task run whenever it is time to restart a child that died.
cls | closure, always NULL |
Definition at line 1605 of file gnunet-service-arm.c.
References _, accept_connection(), ServiceListeningInfo::accept_task, child_restart_task, delayed_restart_task(), ServiceList::force_start, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_add_delayed_with_priority(), GNUNET_SCHEDULER_add_read_net(), GNUNET_SCHEDULER_PRIORITY_IDLE, GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_relative_min(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, in_shutdown, ServiceList::listen_head, ServiceListeningInfo::listen_socket, ServiceList::name, ServiceListeningInfo::next, ServiceList::next, ServiceList::proc, GNUNET_TIME_Relative::rel_value_us, ServiceList::restart_at, running_head, ServiceListeningInfo::sl, and start_process().
Referenced by delayed_restart_task(), and maint_child_death().
|
static |
Task triggered whenever we receive a SIGCHLD (child process died).
cls | closure, NULL |
Definition at line 1682 of file gnunet-service-arm.c.
References _, GNUNET_TIME_Absolute::abs_value_us, accept_connection(), ServiceListeningInfo::accept_task, ServiceList::backoff, ServiceList::binary, broadcast_status(), child_death_task, child_restart_task, delayed_restart_task(), do_shutdown(), free_service(), GNUNET_ARM_RESULT_STOPPED, GNUNET_ARM_SERVICE_STOPPED, GNUNET_break, GNUNET_DISK_file_read(), GNUNET_DISK_PIPE_END_READ, GNUNET_DISK_pipe_handle(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_NO, GNUNET_OS_process_destroy(), GNUNET_OS_PROCESS_EXITED, GNUNET_OS_process_get_pid(), GNUNET_OS_PROCESS_RUNNING, GNUNET_OS_PROCESS_SIGNALED, GNUNET_OS_process_status(), GNUNET_OS_PROCESS_STOPPED, GNUNET_OS_PROCESS_UNKNOWN, GNUNET_SCHEDULER_add_read_file(), GNUNET_SCHEDULER_add_read_net(), GNUNET_SCHEDULER_add_with_priority(), GNUNET_SCHEDULER_cancel(), GNUNET_SCHEDULER_PRIORITY_IDLE, GNUNET_STRINGS_relative_time_to_string(), GNUNET_SYSERR, GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_STD_BACKOFF, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TIME_UNIT_MINUTES, GNUNET_TIME_UNIT_ZERO, GNUNET_YES, in_shutdown, ServiceList::killed_at, ServiceList::killing_client, ServiceList::killing_client_request_id, ServiceList::last_exit_status, list_count(), ServiceList::listen_head, ServiceListeningInfo::listen_socket, maint_child_death(), ServiceList::name, ServiceListeningInfo::next, ServiceList::next, pid, ServiceList::proc, GNUNET_TIME_Relative::rel_value_us, ServiceList::restart_at, ret, running_head, signal_result(), sigpipe, and status.
Referenced by maint_child_death(), and run().
|
static |
Signal handler called for SIGCHLD.
Triggers the respective handler by writing to the trigger pipe.
Definition at line 1897 of file gnunet-service-arm.c.
References GNUNET_break, GNUNET_DISK_file_write(), GNUNET_DISK_PIPE_END_WRITE, GNUNET_DISK_pipe_handle(), and sigpipe.
Referenced by main().
|
static |
Setup our service record for the given section in the configuration file (assuming the section is for a service).
cls | unused |
section | a section in the configuration file |
Definition at line 1922 of file gnunet-service-arm.c.
References ServiceList::backoff, ServiceList::binary, cfg, config, ServiceList::config, create_listen_socket(), find_service(), ServiceList::force_start, get_server_addresses(), GNUNET_break, GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log_config_invalid(), GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_strdup, GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_TIME_UNIT_MILLISECONDS, GNUNET_YES, consensus-simulation::int, ServiceList::name, ServiceList::pipe_control, ServiceList::restart_at, ret, running_head, running_tail, start_system, and start_user.
Referenced by run().
|
static |
A client connected, mark as a monitoring client.
cls | closure |
client | identification of the client |
mq | queue to talk to client |
Definition at line 2048 of file gnunet-service-arm.c.
References GNUNET_SERVICE_client_mark_monitor(), and mq.
Referenced by main().
|
static |
A client disconnected, clean up associated state.
cls | closure |
client | identification of the client |
app_ctx | must match client |
Definition at line 2070 of file gnunet-service-arm.c.
References GNUNET_assert, ServiceList::next, and running_head.
Referenced by main().
|
static |
Handle MONITOR-message.
cls | identification of the client |
message | the actual message |
Definition at line 2091 of file gnunet-service-arm.c.
References broadcast_status(), GNUNET_ARM_SERVICE_MONITORING_STARTED, GNUNET_notification_context_add(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_get_mq(), and notifier.
|
static |
Process arm requests.
cls | closure, NULL |
serv | the initialized service |
c | configuration to use |
Definition at line 2114 of file gnunet-service-arm.c.
References cfg, child_death_task, final_option, ServiceList::force_start, global_ret, GNUNET_break, GNUNET_CONFIGURATION_expand_dollar(), GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_CONFIGURATION_have_value(), GNUNET_CONFIGURATION_iterate_sections(), GNUNET_DISK_PIPE_END_READ, GNUNET_DISK_pipe_handle(), GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_log_strerror_file, GNUNET_NO, GNUNET_notification_context_create(), GNUNET_OK, GNUNET_SCHEDULER_add_read_file(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), GNUNET_strdup, GNUNET_SYSERR, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, maint_child_death(), MAX_NOTIFY_QUEUE, ServiceList::next, notifier, prefix_command, running_head, service, setup_service(), shutdown_task(), sigpipe, start_process(), start_system, and start_user.
Referenced by main().
int main | ( | int | argc, |
char *const * | argv | ||
) |
The main function for the arm service.
argc | number of arguments from the command line |
argv | command line arguments |
Definition at line 2221 of file gnunet-service-arm.c.
References client_connect_cb(), client_disconnect_cb(), global_ret, GNUNET_assert, GNUNET_DISK_PF_NONE, GNUNET_DISK_pipe(), GNUNET_DISK_pipe_close(), GNUNET_free, GNUNET_MESSAGE_TYPE_ARM_LIST, GNUNET_MESSAGE_TYPE_ARM_MONITOR, GNUNET_MESSAGE_TYPE_ARM_START, GNUNET_MESSAGE_TYPE_ARM_STOP, GNUNET_MESSAGE_TYPE_ARM_TEST, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_OS_project_data_gnunet(), GNUNET_SERVICE_OPTION_CLOSE_LSOCKS, GNUNET_SERVICE_OPTION_MANUAL_SHUTDOWN, GNUNET_SERVICE_run_(), GNUNET_SIGCHLD, GNUNET_SIGNAL_handler_install(), GNUNET_SIGNAL_handler_uninstall(), handlers, list, monitor, run(), shc_chld, sighandler_child_death(), sigpipe, and start.
|
static |
List of running services.
Definition at line 206 of file gnunet-service-arm.c.
Referenced by client_disconnect_cb(), delayed_restart_task(), find_service(), free_service(), handle_list(), maint_child_death(), run(), setup_service(), and shutdown_task().
|
static |
List of running services.
Definition at line 211 of file gnunet-service-arm.c.
Referenced by free_service(), and setup_service().
|
static |
Our configuration.
Definition at line 216 of file gnunet-service-arm.c.
Referenced by create_listen_socket(), get_server_addresses(), run(), setup_service(), and start_process().
|
static |
Command to prepend to each actual command.
Definition at line 221 of file gnunet-service-arm.c.
Referenced by run(), and start_process().
|
static |
Option to append to each actual command.
Definition at line 226 of file gnunet-service-arm.c.
Referenced by run(), and start_process().
|
static |
ID of task called whenever we get a SIGCHILD.
Definition at line 231 of file gnunet-service-arm.c.
Referenced by do_shutdown(), maint_child_death(), and run().
|
static |
ID of task called whenever the timeout for restarting a child expires.
Definition at line 237 of file gnunet-service-arm.c.
Referenced by delayed_restart_task(), maint_child_death(), and shutdown_task().
|
static |
Pipe used to communicate shutdown via signal.
Definition at line 242 of file gnunet-service-arm.c.
Referenced by main(), maint_child_death(), run(), and sighandler_child_death().
|
static |
Are we in shutdown mode?
Definition at line 247 of file gnunet-service-arm.c.
Referenced by accept_connection(), delayed_restart_task(), free_service(), handle_list(), handle_start(), handle_stop(), maint_child_death(), and shutdown_task().
|
static |
Return value from main.
Definition at line 252 of file gnunet-service-arm.c.
|
static |
Are we starting user services?
Definition at line 257 of file gnunet-service-arm.c.
Referenced by run(), and setup_service().
|
static |
Are we starting system services?
Definition at line 262 of file gnunet-service-arm.c.
Referenced by run(), and setup_service().
|
static |
Handle to our service instance.
Our service is a bit special in that its service is not immediately stopped once we get a shutdown request (since we need to continue service until all of our child processes are dead). This handle is used to shut down the service (and thus trigger process termination) once all child processes are also dead. A special option in the ARM configuration modifies the behaviour of the service implementation to not do the shutdown immediately.
Definition at line 274 of file gnunet-service-arm.c.
Referenced by add_service_handle(), callback_shutdown_service(), check_get(), check_set(), check_statistics_value(), check_watch(), close_service_room(), create_message_info(), create_message_peer(), create_service(), create_srv_handle(), destroy_service(), do_shutdown(), entry_service_room(), find_subsystem_entry(), free_service_record(), get_service_contact_store(), get_service_peer_identity(), get_service_room(), gns_string_to_value(), handle_get(), handle_service_message(), handle_set(), handle_statistics_value(), handle_watch(), init_peer_store(), open_service_room(), recv_message_miss(), remove_service_handle(), resolver_lookup_get_next_label(), run(), srv_status(), and store_service().
|
static |
Context for notifications we need to send to our clients.
Definition at line 279 of file gnunet-service-arm.c.
Referenced by broadcast_status(), do_shutdown(), handle_monitor(), and run().