functions related to starting services (redesign) More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_protocols.h"
#include "gnunet_constants.h"
#include "gnunet_resolver_service.h"
#include "speedup.h"
Go to the source code of this file.
Data Structures | |
struct | ServiceListenContext |
Information the service tracks per listen operation. More... | |
struct | GNUNET_SERVICE_Handle |
Handle to a service. More... | |
struct | GNUNET_SERVICE_Client |
Handle to a client that is connected to a service. More... | |
struct | ServiceHandleList |
A list of service to be launched when GNUNET_SERVICE_main() is called. More... | |
struct | LaunchContext |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "util-service", __VA_ARGS__) |
#define | LOG_STRERROR(kind, syscall) GNUNET_log_from_strerror (kind, "util-service", syscall) |
#define | LOG_STRERROR_FILE(kind, syscall, filename) GNUNET_log_from_strerror_file (kind, "util-service", syscall, filename) |
Enumerations | |
enum | SuspendReason { SUSPEND_STATE_NONE = 0 , SUSPEND_STATE_APP = 1 , SUSPEND_STATE_EMFILE = 2 , SUSPEND_STATE_APP_AND_EMFILE = 3 , SUSPEND_STATE_SHUTDOWN = 4 } |
Reasons why we might be suspended. More... | |
Functions | |
static enum GNUNET_GenericReturnValue | have_non_monitor_clients (struct GNUNET_SERVICE_Handle *sh) |
Check if any of the clients we have left are unrelated to monitoring. More... | |
static void | do_suspend (struct GNUNET_SERVICE_Handle *sh, enum SuspendReason sr) |
Suspend accepting connections from the listen socket temporarily. More... | |
static void | service_shutdown (void *cls) |
Shutdown task triggered when a service should be terminated. More... | |
static bool | check_ipv4_listed (const struct GNUNET_STRINGS_IPv4NetworkPolicy *list, const struct in_addr *add) |
Check if the given IP address is in the list of IP addresses. More... | |
static bool | check_ipv6_listed (const struct GNUNET_STRINGS_IPv6NetworkPolicy *list, const struct in6_addr *ip) |
Check if the given IP address is in the list of IP addresses. More... | |
static void | do_send (void *cls) |
Task run when we are ready to transmit data to the client. More... | |
static void | service_mq_send (struct GNUNET_MQ_Handle *mq, const struct GNUNET_MessageHeader *msg, void *impl_state) |
Signature of functions implementing the sending functionality of a message queue. More... | |
static void | service_mq_cancel (struct GNUNET_MQ_Handle *mq, void *impl_state) |
Implementation function that cancels the currently sent message. More... | |
static void | service_mq_error_handler (void *cls, enum GNUNET_MQ_Error error) |
Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue. More... | |
static void | warn_no_client_continue (void *cls) |
Task run to warn about missing calls to GNUNET_SERVICE_client_continue(). More... | |
static int | service_client_mst_cb (void *cls, const struct GNUNET_MessageHeader *message) |
Functions with this signature are called whenever a complete message is received by the tokenizer for a client. More... | |
static void | service_client_recv (void *cls) |
A client sent us data. More... | |
static void | start_client (struct GNUNET_SERVICE_Handle *sh, struct GNUNET_NETWORK_Handle *csock) |
We have successfully accepted a connection from a client. More... | |
static void | accept_client (void *cls) |
We have a client. More... | |
static void | do_resume (struct GNUNET_SERVICE_Handle *sh, enum SuspendReason sr) |
Resume accepting connections from the listen socket. More... | |
static void | service_main (void *cls) |
First task run by any service. More... | |
static enum GNUNET_GenericReturnValue | process_acl4 (struct GNUNET_STRINGS_IPv4NetworkPolicy **ret, struct GNUNET_SERVICE_Handle *sh, const char *option) |
Parse an IPv4 access control list. More... | |
static enum GNUNET_GenericReturnValue | process_acl6 (struct GNUNET_STRINGS_IPv6NetworkPolicy **ret, struct GNUNET_SERVICE_Handle *sh, const char *option) |
Parse an IPv6 access control list. More... | |
static void | add_unixpath (struct sockaddr **saddrs, socklen_t *saddrlens, const char *unixpath) |
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 struct GNUNET_NETWORK_Handle * | open_listen_socket (const struct sockaddr *server_addr, socklen_t socklen) |
Create and initialize a listen socket for the server. More... | |
static enum GNUNET_GenericReturnValue | setup_service (const struct GNUNET_OS_ProjectData *pd, struct GNUNET_SERVICE_Handle *sh) |
Setup service handle. More... | |
static char * | get_user_name (struct GNUNET_SERVICE_Handle *sh) |
Get the name of the user that'll be used to provide the service. More... | |
static enum GNUNET_GenericReturnValue | set_user_id (struct GNUNET_SERVICE_Handle *sh) |
Set user ID. More... | |
static char * | get_pid_file_name (struct GNUNET_SERVICE_Handle *sh) |
Get the name of the file where we will write the PID of the service. More... | |
static void | pid_file_delete (struct GNUNET_SERVICE_Handle *sh) |
Delete the PID file that was created by our parent. More... | |
static enum GNUNET_GenericReturnValue | detach_terminal (struct GNUNET_SERVICE_Handle *sh) |
Detach from terminal. More... | |
static void | teardown_service (struct GNUNET_SERVICE_Handle *sh) |
Tear down the service, closing the listen sockets and freeing the ACLs. More... | |
static void | return_agpl (void *cls, const struct GNUNET_MessageHeader *msg) |
Function to return link to AGPL source upon request. More... | |
struct GNUNET_SERVICE_Handle * | GNUNET_SERVICE_start (const struct GNUNET_OS_ProjectData *pd, const char *service_name, const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_SERVICE_ConnectHandler connect_cb, GNUNET_SERVICE_DisconnectHandler disconnect_cb, void *cls, const struct GNUNET_MQ_MessageHandler *handlers) |
Low-level function to start a service if the scheduler is already running. More... | |
static void | finish_client_drop (void *cls) |
Asynchronously finish dropping the client. More... | |
void | GNUNET_SERVICE_stop (struct GNUNET_SERVICE_Handle *srv) |
Stops a service that was started with GNUNET_SERVICE_start(). More... | |
int | GNUNET_SERVICE_run_ (const struct GNUNET_OS_ProjectData *pd, int argc, char *const *argv, const char *service_name, enum GNUNET_SERVICE_Options options, GNUNET_SERVICE_InitCallback service_init_cb, GNUNET_SERVICE_ConnectHandler connect_cb, GNUNET_SERVICE_DisconnectHandler disconnect_cb, void *cls, const struct GNUNET_MQ_MessageHandler *handlers) |
Creates the "main" function for a GNUnet service. More... | |
int | GNUNET_SERVICE_register_ (const struct GNUNET_OS_ProjectData *pd, const char *service_name, enum GNUNET_SERVICE_Options options, GNUNET_SERVICE_InitCallback service_init_cb, GNUNET_SERVICE_ConnectHandler connect_cb, GNUNET_SERVICE_DisconnectHandler disconnect_cb, void *cls, const struct GNUNET_MQ_MessageHandler *handlers) |
Registers the GNUnet service to be scheduled as part of a monilithic libgnunet. More... | |
static void | do_registered_services_shutdown (void *cls) |
static void | launch_registered_services (void *cls) |
void | GNUNET_SERVICE_main (const struct GNUNET_OS_ProjectData *pd, int argc, char *const *argv, struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_GenericReturnValue with_scheduler) |
Run the mainloop in a monolithic libgnunet. More... | |
void | GNUNET_SERVICE_suspend (struct GNUNET_SERVICE_Handle *sh) |
Suspend accepting connections from the listen socket temporarily. More... | |
void | GNUNET_SERVICE_resume (struct GNUNET_SERVICE_Handle *sh) |
Resume accepting connections from the listen socket. More... | |
static void | resume_client_receive (void *cls) |
Task run to resume receiving data from the client after the client called GNUNET_SERVICE_client_continue(). More... | |
void | GNUNET_SERVICE_client_continue (struct GNUNET_SERVICE_Client *c) |
Continue receiving further messages from the given client. More... | |
void | GNUNET_SERVICE_client_disable_continue_warning (struct GNUNET_SERVICE_Client *c) |
Disable the warning the server issues if a message is not acknowledged in a timely fashion. More... | |
void | GNUNET_SERVICE_client_drop (struct GNUNET_SERVICE_Client *c) |
Ask the server to disconnect from the given client. More... | |
void | GNUNET_SERVICE_shutdown (struct GNUNET_SERVICE_Handle *sh) |
Explicitly stops the service. More... | |
void | GNUNET_SERVICE_client_mark_monitor (struct GNUNET_SERVICE_Client *c) |
Set the 'monitor' flag on this client. More... | |
void | GNUNET_SERVICE_client_persist (struct GNUNET_SERVICE_Client *c) |
Set the persist option on this client. More... | |
struct GNUNET_MQ_Handle * | GNUNET_SERVICE_client_get_mq (struct GNUNET_SERVICE_Client *c) |
Obtain the message queue of c. More... | |
Variables | |
static struct ServiceHandleList * | hll_head |
static struct ServiceHandleList * | hll_tail |
functions related to starting services (redesign)
Definition in file service.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "util-service", __VA_ARGS__) |
#define LOG_STRERROR | ( | kind, | |
syscall | |||
) | GNUNET_log_from_strerror (kind, "util-service", syscall) |
#define LOG_STRERROR_FILE | ( | kind, | |
syscall, | |||
filename | |||
) | GNUNET_log_from_strerror_file (kind, "util-service", syscall, filename) |
enum SuspendReason |
Reasons why we might be suspended.
Definition at line 83 of file service.c.
|
static |
Check if any of the clients we have left are unrelated to monitoring.
sh | service to check clients for |
Definition at line 359 of file service.c.
References sh.
Referenced by finish_client_drop(), GNUNET_SERVICE_client_mark_monitor(), and service_shutdown().
|
static |
Suspend accepting connections from the listen socket temporarily.
Resume activity using do_resume.
sh | service to stop accepting connections. |
sr | reason for suspending accepting connections |
Definition at line 383 of file service.c.
References GNUNET_assert, GNUNET_SCHEDULER_cancel(), and sh.
Referenced by accept_client(), GNUNET_SERVICE_shutdown(), GNUNET_SERVICE_suspend(), and service_shutdown().
|
static |
Shutdown task triggered when a service should be terminated.
This considers active clients and the service options to see how this specific service is to be terminated, and depending on this proceeds with the shutdown logic.
cls | our struct GNUNET_SERVICE_Handle |
Definition at line 410 of file service.c.
References do_suspend(), GNUNET_assert, GNUNET_SERVICE_OPTION_MANUAL_SHUTDOWN, GNUNET_SERVICE_OPTION_NONE, GNUNET_SERVICE_OPTION_SHUTDOWN_BITMASK, GNUNET_SERVICE_OPTION_SOFT_SHUTDOWN, GNUNET_SERVICE_shutdown(), have_non_monitor_clients(), sh, and SUSPEND_STATE_SHUTDOWN.
Referenced by service_main().
|
static |
Check if the given IP address is in the list of IP addresses.
list | a list of networks |
add | the IP to check (in network byte order) |
Definition at line 442 of file service.c.
Referenced by accept_client().
|
static |
Check if the given IP address is in the list of IP addresses.
list | a list of networks |
ip | the IP to check (in network byte order) |
Definition at line 465 of file service.c.
References GNUNET_is_zero, consensus-simulation::int, and list.
Referenced by accept_client().
|
static |
Task run when we are ready to transmit data to the client.
cls | the struct GNUNET_SERVICE_Client * to send to |
Definition at line 495 of file service.c.
References do_send(), GNUNET_SERVICE_Client::drop_task, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_log_strerror, GNUNET_MQ_ERROR_WRITE, GNUNET_MQ_impl_send_continue(), GNUNET_MQ_impl_send_in_flight(), GNUNET_MQ_inject_error(), GNUNET_NETWORK_socket_send(), GNUNET_SCHEDULER_add_write_net(), GNUNET_TIME_UNIT_FOREVER_REL, LOG, GNUNET_SERVICE_Client::mq, GNUNET_SERVICE_Client::msg, GNUNET_SERVICE_Client::msg_pos, ret, GNUNET_SERVICE_Client::send_task, GNUNET_MessageHeader::size, GNUNET_SERVICE_Client::sock, and GNUNET_MessageHeader::type.
Referenced by do_send(), and service_mq_send().
|
static |
Signature of functions implementing the sending functionality of a message queue.
mq | the message queue |
msg | the message to send |
impl_state | our struct GNUNET_SERVICE_Client * |
Definition at line 564 of file service.c.
References do_send(), GNUNET_SERVICE_Client::drop_task, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_SCHEDULER_add_now(), LOG, mq, msg, GNUNET_SERVICE_Client::msg, GNUNET_SERVICE_Client::msg_pos, GNUNET_SERVICE_Client::send_task, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.
Referenced by start_client().
|
static |
Implementation function that cancels the currently sent message.
mq | message queue |
impl_state | state specific to the implementation |
Definition at line 592 of file service.c.
References GNUNET_assert, GNUNET_SCHEDULER_cancel(), mq, GNUNET_SERVICE_Client::msg, GNUNET_SERVICE_Client::msg_pos, and GNUNET_SERVICE_Client::send_task.
Referenced by start_client().
|
static |
Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue.
Not every message queue implementation supports an error handler.
cls | closure with our struct GNUNET_SERVICE_Client |
error | error code |
Definition at line 615 of file service.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MQ_ERROR_NO_MATCH, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), sh, GNUNET_SERVICE_Client::sh, and GNUNET_SERVICE_Client::warn_type.
Referenced by start_client().
|
static |
Task run to warn about missing calls to GNUNET_SERVICE_client_continue().
cls | our struct GNUNET_SERVICE_Client * to process more requests from |
Definition at line 640 of file service.c.
References _, GNUNET_break, GNUNET_ERROR_TYPE_WARNING, GNUNET_SCHEDULER_add_delayed(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_UNIT_MINUTES, GNUNET_YES, LOG, warn_no_client_continue(), GNUNET_SERVICE_Client::warn_start, GNUNET_SERVICE_Client::warn_task, and GNUNET_SERVICE_Client::warn_type.
Referenced by service_client_mst_cb(), and warn_no_client_continue().
|
static |
Functions with this signature are called whenever a complete message is received by the tokenizer for a client.
Do not call GNUNET_MST_destroy() from within the scope of this callback.
cls | closure with the struct GNUNET_SERVICE_Client * |
message | the actual message |
Definition at line 673 of file service.c.
References GNUNET_SERVICE_Client::drop_task, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MQ_inject_message(), GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_SYSERR, GNUNET_TIME_absolute_get(), GNUNET_TIME_UNIT_MINUTES, LOG, GNUNET_SERVICE_Client::mq, GNUNET_SERVICE_Client::needs_continue, GNUNET_MessageHeader::size, GNUNET_MessageHeader::type, warn_no_client_continue(), GNUNET_SERVICE_Client::warn_start, GNUNET_SERVICE_Client::warn_task, and GNUNET_SERVICE_Client::warn_type.
Referenced by start_client().
|
static |
A client sent us data.
Receive and process it. If we are done, reschedule this task.
cls | the struct GNUNET_SERVICE_Client that sent us data. |
Definition at line 704 of file service.c.
References GNUNET_SERVICE_Client::drop_task, GNUNET_assert, GNUNET_MST_read(), GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_read_net(), GNUNET_SERVICE_client_drop(), GNUNET_SYSERR, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, GNUNET_SERVICE_Client::mst, GNUNET_SERVICE_Client::needs_continue, GNUNET_SERVICE_Client::recv_task, ret, service_client_recv(), and GNUNET_SERVICE_Client::sock.
Referenced by resume_client_receive(), service_client_recv(), and start_client().
|
static |
We have successfully accepted a connection from a client.
Now setup the client (with the scheduler) and tell the application.
sh | service that accepted the client |
csock | socket associated with the client |
Definition at line 749 of file service.c.
References GNUNET_IDENTITY_Handle::cb_cls, GNUNET_CONTAINER_DLL_insert, GNUNET_MQ_queue_for_callbacks(), GNUNET_MQ_set_handlers_closure(), GNUNET_MST_create(), GNUNET_new, GNUNET_SCHEDULER_add_read_net(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_SERVICE_Client::mq, GNUNET_SERVICE_Client::mst, GNUNET_SERVICE_Client::recv_task, service_client_mst_cb(), service_client_recv(), service_mq_cancel(), service_mq_error_handler(), service_mq_send(), sh, GNUNET_SERVICE_Client::sh, GNUNET_SERVICE_Client::sock, and GNUNET_SERVICE_Client::user_context.
Referenced by accept_client().
|
static |
We have a client.
Accept the incoming socket(s) (and reschedule the listen task).
cls | the struct ServiceListenContext of the ready listen socket |
Definition at line 786 of file service.c.
References _, accept_client(), check_ipv4_listed(), check_ipv6_listed(), do_suspend(), GNUNET_a2s(), GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_log_strerror, GNUNET_NETWORK_socket_accept(), GNUNET_NETWORK_socket_close(), GNUNET_OK, GNUNET_SCHEDULER_add_read_net(), GNUNET_TIME_UNIT_FOREVER_REL, ServiceListenContext::listen_socket, ServiceListenContext::listen_task, LOG, sh, ServiceListenContext::sh, start_client(), and SUSPEND_STATE_EMFILE.
Referenced by accept_client(), and do_resume().
|
static |
Resume accepting connections from the listen socket.
sh | service to resume accepting connections. |
sr | reason that is no longer causing the suspension, or SUSPEND_STATE_NONE on first startup |
Definition at line 880 of file service.c.
References accept_client(), GNUNET_assert, GNUNET_SCHEDULER_add_read_net(), GNUNET_TIME_UNIT_FOREVER_REL, sh, and SUSPEND_STATE_NONE.
Referenced by finish_client_drop(), GNUNET_SERVICE_resume(), GNUNET_SERVICE_start(), and service_main().
|
static |
First task run by any service.
Initializes our shutdown task, starts the listening operation on our listen sockets and launches the custom logic of the application service.
cls | our struct GNUNET_SERVICE_Handle |
Definition at line 909 of file service.c.
References GNUNET_IDENTITY_Handle::cb_cls, GNUNET_IDENTITY_Handle::cfg, do_resume(), GNUNET_break, GNUNET_SCHEDULER_add_shutdown(), GNUNET_SERVICE_OPTION_MANUAL_SHUTDOWN, GNUNET_SERVICE_OPTION_SHUTDOWN_BITMASK, service_shutdown(), sh, and SUSPEND_STATE_NONE.
Referenced by GNUNET_SERVICE_run_(), and launch_registered_services().
|
static |
Parse an IPv4 access control list.
ret | location where to write the ACL (set) |
sh | service context to use to get the configuration |
option | name of the ACL option to parse |
Definition at line 940 of file service.c.
References _, GNUNET_IDENTITY_Handle::cfg, GNUNET_break, GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_have_value(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_OK, GNUNET_STRINGS_parse_ipv4_policy(), GNUNET_SYSERR, LOG, ret, and sh.
Referenced by setup_service().
|
static |
Parse an IPv6 access control list.
ret | location where to write the ACL (set) |
sh | service context to use to get the configuration |
option | name of the ACL option to parse |
Definition at line 981 of file service.c.
References _, GNUNET_IDENTITY_Handle::cfg, GNUNET_break, GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_have_value(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_OK, GNUNET_STRINGS_parse_ipv6_policy(), GNUNET_SYSERR, LOG, ret, and sh.
Referenced by setup_service().
|
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 |
Definition at line 1021 of file service.c.
References GNUNET_assert, GNUNET_new, and GNUNET_strlcpy().
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 1065 of file service.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_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_NETWORK_test_pf(), 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 |
Create and initialize a listen socket for the server.
server_addr | address to listen on |
socklen | length of server_addr |
Definition at line 1367 of file service.c.
References _, GNUNET_a2s(), GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_NETWORK_socket_bind(), GNUNET_NETWORK_socket_close(), GNUNET_NETWORK_socket_create(), GNUNET_NETWORK_socket_listen(), GNUNET_OK, LOG, LOG_STRERROR, and port.
Referenced by setup_service().
|
static |
Setup service handle.
Configuration may specify:
pd | project data to use for the service |
sh | service context to initialize |
Definition at line 1476 of file service.c.
References _, GNUNET_IDENTITY_Handle::cfg, dummy, get_server_addresses(), getenv(), GNUNET_break, GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_CONFIGURATION_have_value(), GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_log_strerror, GNUNET_NETWORK_socket_box_native(), GNUNET_NETWORK_socket_close(), GNUNET_new, GNUNET_new_array, GNUNET_NO, GNUNET_OK, GNUNET_SERVICE_OPTION_CLOSE_LSOCKS, GNUNET_SYSERR, ServiceListenContext::listen_socket, LOG, ls, open_listen_socket(), process_acl4(), process_acl6(), sh, and ServiceListenContext::sh.
Referenced by GNUNET_SERVICE_run_(), GNUNET_SERVICE_start(), and launch_registered_services().
|
static |
Get the name of the user that'll be used to provide the service.
sh | service context |
Definition at line 1632 of file service.c.
References GNUNET_IDENTITY_Handle::cfg, GNUNET_CONFIGURATION_get_value_filename(), GNUNET_OK, and sh.
Referenced by set_user_id().
|
static |
Set user ID.
sh | service context |
Definition at line 1653 of file service.c.
References _, get_user_name(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_OK, GNUNET_SYSERR, LOG, and sh.
Referenced by GNUNET_SERVICE_run_(), and launch_registered_services().
|
static |
Get the name of the file where we will write the PID of the service.
sh | service context |
Definition at line 1703 of file service.c.
References GNUNET_IDENTITY_Handle::cfg, GNUNET_CONFIGURATION_get_value_filename(), GNUNET_OK, and sh.
Referenced by pid_file_delete().
|
static |
Delete the PID file that was created by our parent.
sh | service context |
Definition at line 1723 of file service.c.
References get_pid_file_name(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, LOG_STRERROR_FILE, and sh.
Referenced by GNUNET_SERVICE_run_().
|
static |
Detach from terminal.
sh | service context |
Definition at line 1744 of file service.c.
References _, GNUNET_break, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_OK, GNUNET_SYSERR, LOG, LOG_STRERROR, pid, and sh.
Referenced by GNUNET_SERVICE_run_().
|
static |
Tear down the service, closing the listen sockets and freeing the ACLs.
sh | handle to the service to tear down. |
Definition at line 1828 of file service.c.
References GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_NETWORK_socket_close(), GNUNET_OK, GNUNET_SCHEDULER_cancel(), ServiceListenContext::listen_socket, ServiceListenContext::listen_task, and sh.
Referenced by do_registered_services_shutdown(), GNUNET_SERVICE_run_(), and GNUNET_SERVICE_stop().
|
static |
Function to return link to AGPL source upon request.
cls | closure with the identification of the client |
msg | AGPL request |
Definition at line 1857 of file service.c.
References GNUNET_OS_ProjectData::agpl_url, env, GNUNET_AGPL_URL, GNUNET_MESSAGE_TYPE_RESPONSE_AGPL, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_get_mq(), mq, msg, GNUNET_SERVICE_Handle::pd, res, and GNUNET_SERVICE_Client::sh.
Referenced by GNUNET_SERVICE_register_(), GNUNET_SERVICE_run_(), and GNUNET_SERVICE_start().
|
static |
Asynchronously finish dropping the client.
cls | the struct GNUNET_SERVICE_Client . |
Definition at line 1923 of file service.c.
References do_resume(), GNUNET_SERVICE_Client::drop_task, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_destroy(), GNUNET_MST_destroy(), GNUNET_NETWORK_socket_close(), GNUNET_NETWORK_socket_free_memory_only_(), GNUNET_OK, GNUNET_SERVICE_shutdown(), have_non_monitor_clients(), GNUNET_SERVICE_Client::mq, GNUNET_SERVICE_Client::mst, GNUNET_SERVICE_Client::persist, GNUNET_SERVICE_Client::recv_task, GNUNET_SERVICE_Client::send_task, sh, GNUNET_SERVICE_Client::sh, GNUNET_SERVICE_Client::sock, SUSPEND_STATE_EMFILE, SUSPEND_STATE_SHUTDOWN, and GNUNET_SERVICE_Client::warn_task.
Referenced by GNUNET_SERVICE_client_drop(), and GNUNET_SERVICE_stop().
|
static |
Definition at line 2242 of file service.c.
References GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, hll_head, hll_tail, LOG_STRERROR, sh, ServiceHandleList::sh, and teardown_service().
Referenced by launch_registered_services().
|
static |
Definition at line 2276 of file service.c.
References cfg, LaunchContext::cfg, do_registered_services_shutdown(), GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_shutdown(), hll_head, ServiceHandleList::next, LaunchContext::pd, service_main(), set_user_id(), and setup_service().
Referenced by GNUNET_SERVICE_main().
|
static |
Task run to resume receiving data from the client after the client called GNUNET_SERVICE_client_continue().
cls | our struct GNUNET_SERVICE_Client |
Definition at line 2358 of file service.c.
References GNUNET_SERVICE_Client::drop_task, GNUNET_assert, GNUNET_MST_next(), GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_read_net(), GNUNET_SERVICE_client_drop(), GNUNET_SYSERR, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, GNUNET_SERVICE_Client::mst, GNUNET_SERVICE_Client::needs_continue, GNUNET_SERVICE_Client::recv_task, ret, service_client_recv(), and GNUNET_SERVICE_Client::sock.
Referenced by GNUNET_SERVICE_client_continue().
|
static |
Definition at line 2202 of file service.c.
Referenced by do_registered_services_shutdown(), GNUNET_SERVICE_register_(), and launch_registered_services().
|
static |
Definition at line 2205 of file service.c.
Referenced by do_registered_services_shutdown(), and GNUNET_SERVICE_register_().