Go to the source code of this file.
Data Structures | |
struct | HandlerList |
List of arrays of message handlers. More... | |
struct | NotifyList |
List of arrays of message handlers. More... | |
struct | GNUNET_SERVER_Handle |
handle for a server More... | |
struct | GNUNET_SERVER_TransmitHandle |
Handle server returns for aborting transmission to a client. More... | |
struct | GNUNET_SERVER_Client |
handle for a client of the server More... | |
Macros | |
#define | LOG_STRERROR_FILE(kind, syscall, filename) |
Functions | |
void * | GNUNET_SERVER_client_get_user_context_ (struct GNUNET_SERVER_Client *client, size_t size) |
Return user context associated with the given client. More... | |
void | GNUNET_SERVER_client_set_user_context_ (struct GNUNET_SERVER_Client *client, void *ptr, size_t size) |
Set user context to be associated with the given client. More... | |
static void | process_listen_socket (void *cls) |
Scheduler says our listen socket is ready. 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... | |
struct GNUNET_SERVER_Handle * | GNUNET_SERVER_create_with_sockets (GNUNET_CONNECTION_AccessCheck access_cb, void *access_cb_cls, struct GNUNET_NETWORK_Handle **lsocks, struct GNUNET_TIME_Relative idle_timeout, int require_found) |
Create a new server. More... | |
struct GNUNET_SERVER_Handle * | GNUNET_SERVER_create (GNUNET_CONNECTION_AccessCheck access_cb, void *access_cb_cls, struct sockaddr *const *server_addr, const socklen_t *socklen, struct GNUNET_TIME_Relative idle_timeout, int require_found) |
Create a new server. More... | |
void | GNUNET_SERVER_client_mark_monitor (struct GNUNET_SERVER_Client *client) |
Set the 'monitor' flag on this client. More... | |
static void | do_destroy (void *cls) |
Helper function for test_monitor_clients() to trigger GNUNET_SERVER_destroy() after the stack has unwound. More... | |
static void | test_monitor_clients (struct GNUNET_SERVER_Handle *server) |
Check if only 'monitor' clients are left. More... | |
void | GNUNET_SERVER_suspend (struct GNUNET_SERVER_Handle *server) |
Suspend accepting connections from the listen socket temporarily. More... | |
void | GNUNET_SERVER_resume (struct GNUNET_SERVER_Handle *server) |
Resume accepting connections from the listen socket. More... | |
void | GNUNET_SERVER_stop_listening (struct GNUNET_SERVER_Handle *server) |
Stop the listen socket and get ready to shutdown the server once only 'monitor' clients are left. More... | |
void | GNUNET_SERVER_destroy (struct GNUNET_SERVER_Handle *server) |
Free resources held by this server. More... | |
void | GNUNET_SERVER_add_handlers (struct GNUNET_SERVER_Handle *server, const struct GNUNET_SERVER_MessageHandler *handlers) |
Add additional handlers to an existing server. More... | |
void | GNUNET_SERVER_set_callbacks (struct GNUNET_SERVER_Handle *server, GNUNET_SERVER_MstCreateCallback create, GNUNET_SERVER_MstDestroyCallback destroy, GNUNET_SERVER_MstReceiveCallback receive, void *cls) |
Change functions used by the server to tokenize the message stream. More... | |
static void | warn_no_receive_done (void *cls) |
Task run to warn about missing calls to GNUNET_SERVER_receive_done. More... | |
void | GNUNET_SERVER_disable_receive_done_warning (struct GNUNET_SERVER_Client *client) |
Disable the warning the server issues if a message is not acknowledged in a timely fashion. More... | |
int | GNUNET_SERVER_inject (struct GNUNET_SERVER_Handle *server, struct GNUNET_SERVER_Client *sender, const struct GNUNET_MessageHeader *message) |
Inject a message into the server, pretend it came from the specified client. More... | |
static void | process_incoming (void *cls, const void *buf, size_t available, const struct sockaddr *addr, socklen_t addrlen, int errCode) |
We are receiving an incoming message. More... | |
static void | process_mst (struct GNUNET_SERVER_Client *client, int ret) |
Process messages from the client's message tokenizer until either the tokenizer is empty (and then schedule receiving more), or until some handler is not immediately done (then wait for restart_processing) or shutdown. More... | |
static void | restart_processing (void *cls) |
Task run to start again receiving from the network and process requests. More... | |
static int | client_message_tokenizer_callback (void *cls, void *client, const struct GNUNET_MessageHeader *message) |
This function is called whenever our inbound message tokenizer has received a complete message. More... | |
struct GNUNET_SERVER_Client * | GNUNET_SERVER_connect_socket (struct GNUNET_SERVER_Handle *server, struct GNUNET_CONNECTION_Handle *connection) |
Add a TCP socket-based connection to the set of handles managed by this server. More... | |
void | GNUNET_SERVER_client_set_timeout (struct GNUNET_SERVER_Client *client, struct GNUNET_TIME_Relative timeout) |
Change the timeout for a particular client. More... | |
void | GNUNET_SERVER_client_keep (struct GNUNET_SERVER_Client *client) |
Notify the server that the given client handle should be kept (keeps the connection up if possible, increments the internal reference counter). More... | |
void | GNUNET_SERVER_client_drop (struct GNUNET_SERVER_Client *client) |
Notify the server that the given client handle is no longer required. More... | |
int | GNUNET_SERVER_client_get_address (struct GNUNET_SERVER_Client *client, void **addr, size_t *addrlen) |
Obtain the network address of the other party. More... | |
void | GNUNET_SERVER_disconnect_notify (struct GNUNET_SERVER_Handle *server, GNUNET_SERVER_DisconnectCallback callback, void *callback_cls) |
Ask the server to notify us whenever a client disconnects. More... | |
void | GNUNET_SERVER_connect_notify (struct GNUNET_SERVER_Handle *server, GNUNET_SERVER_ConnectCallback callback, void *callback_cls) |
Ask the server to notify us whenever a client connects. More... | |
void | GNUNET_SERVER_disconnect_notify_cancel (struct GNUNET_SERVER_Handle *server, GNUNET_SERVER_DisconnectCallback callback, void *callback_cls) |
Ask the server to stop notifying us whenever a client connects. More... | |
void | GNUNET_SERVER_connect_notify_cancel (struct GNUNET_SERVER_Handle *server, GNUNET_SERVER_ConnectCallback callback, void *callback_cls) |
Ask the server to stop notifying us whenever a client disconnects. More... | |
void | GNUNET_SERVER_client_disconnect (struct GNUNET_SERVER_Client *client) |
Ask the server to disconnect from the given client. More... | |
int | GNUNET_SERVER_client_disable_corking (struct GNUNET_SERVER_Client *client) |
Disable the "CORK" feature for communication with the given client, forcing the OS to immediately flush the buffer on transmission instead of potentially buffering multiple messages. More... | |
static size_t | transmit_ready_callback_wrapper (void *cls, size_t size, void *buf) |
Wrapper for transmission notification that calls the original callback and update the last activity time for our connection. More... | |
struct GNUNET_SERVER_TransmitHandle * | GNUNET_SERVER_notify_transmit_ready (struct GNUNET_SERVER_Client *client, size_t size, struct GNUNET_TIME_Relative timeout, GNUNET_CONNECTION_TransmitReadyNotify callback, void *callback_cls) |
Notify us when the server has enough space to transmit a message of the given size to the given client. More... | |
void | GNUNET_SERVER_notify_transmit_ready_cancel (struct GNUNET_SERVER_TransmitHandle *th) |
Abort transmission request. More... | |
void | GNUNET_SERVER_client_persist_ (struct GNUNET_SERVER_Client *client) |
Set the persistent flag on this client, used to setup client connection to only be killed when the service it's connected to is actually dead. More... | |
void | GNUNET_SERVER_receive_done (struct GNUNET_SERVER_Client *client, int success) |
Resume receiving from this client, we are done processing the current request. More... | |
#define LOG_STRERROR_FILE | ( | kind, | |
syscall, | |||
filename | |||
) |
Definition at line 31 of file tcp_server_legacy.c.
void* GNUNET_SERVER_client_get_user_context_ | ( | struct GNUNET_SERVER_Client * | client, |
size_t | size | ||
) |
Return user context associated with the given client.
Note: you should probably use the macro (call without the underscore).
client | client to query |
size | number of bytes in user context struct (for verification only) |
Definition at line 349 of file tcp_server_legacy.c.
References GNUNET_assert, size, GNUNET_SERVER_Client::user_context, and GNUNET_SERVER_Client::user_context_size.
void GNUNET_SERVER_client_set_user_context_ | ( | struct GNUNET_SERVER_Client * | client, |
void * | ptr, | ||
size_t | size | ||
) |
Set user context to be associated with the given client.
Note: you should probably use the macro (call without the underscore).
client | client to query |
ptr | pointer to user context |
size | number of bytes in user context struct (for verification only) |
Definition at line 369 of file tcp_server_legacy.c.
References size, GNUNET_SERVER_Client::user_context, and GNUNET_SERVER_Client::user_context_size.
|
static |
Scheduler says our listen socket is ready.
Process it!
cls | handle to our server for which we are processing the listen socket |
Definition at line 391 of file tcp_server_legacy.c.
References GNUNET_SERVER_Handle::access_cb, GNUNET_SERVER_Handle::access_cb_cls, GNUNET_CONNECTION_create_from_accept(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_NETWORK_fdset_isset(), GNUNET_SCHEDULER_get_task_context(), GNUNET_SERVER_connect_socket(), GNUNET_SERVER_resume(), GNUNET_SERVER_Handle::listen_sockets, GNUNET_SERVER_Handle::listen_task, LOG, GNUNET_SCHEDULER_TaskContext::read_ready, GNUNET_CONNECTION_Handle::sock, and tc.
Referenced by GNUNET_SERVER_resume().
|
static |
Create and initialize a listen socket for the server.
server_addr | address to listen on |
socklen | length of server_addr |
Definition at line 431 of file tcp_server_legacy.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 GNUNET_SERVER_create().
struct GNUNET_SERVER_Handle* GNUNET_SERVER_create_with_sockets | ( | GNUNET_CONNECTION_AccessCheck | access_cb, |
void * | access_cb_cls, | ||
struct GNUNET_NETWORK_Handle ** | lsocks, | ||
struct GNUNET_TIME_Relative | idle_timeout, | ||
int | require_found | ||
) |
Create a new server.
access_cb | function for access control |
access_cb_cls | closure for access_cb |
lsocks | NULL-terminated array of listen sockets |
idle_timeout | after how long should we timeout idle connections? |
require_found | if GNUNET_YES, connections sending messages of unknown type will be closed |
Definition at line 532 of file tcp_server_legacy.c.
References GNUNET_SERVER_Handle::access_cb, GNUNET_SERVER_Handle::access_cb_cls, GNUNET_new, GNUNET_SERVER_resume(), GNUNET_SERVER_Handle::idle_timeout, GNUNET_SERVER_Handle::listen_sockets, and GNUNET_SERVER_Handle::require_found.
Referenced by GNUNET_SERVER_create(), LEGACY_SERVICE_start(), libgnunet_plugin_transport_tcp_init(), and service_task().
struct GNUNET_SERVER_Handle* GNUNET_SERVER_create | ( | GNUNET_CONNECTION_AccessCheck | access_cb, |
void * | access_cb_cls, | ||
struct sockaddr *const * | server_addr, | ||
const socklen_t * | socklen, | ||
struct GNUNET_TIME_Relative | idle_timeout, | ||
int | require_found | ||
) |
Create a new server.
access_cb | function for access control |
access_cb_cls | closure for access_cb |
server_addr | address to listen on (including port), NULL terminated array |
socklen | length of server_addr |
idle_timeout | after how long should we timeout idle connections? |
require_found | if YES, connections sending messages of unknown type will be closed |
Definition at line 566 of file tcp_server_legacy.c.
References GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_malloc, GNUNET_SERVER_create_with_sockets(), LOG_STRERROR, and open_listen_socket().
Referenced by LEGACY_SERVICE_start(), and service_task().
void GNUNET_SERVER_client_mark_monitor | ( | struct GNUNET_SERVER_Client * | client | ) |
Set the 'monitor' flag on this client.
Clients which have been marked as 'monitors' won't prevent the server from shutting down once 'GNUNET_SERVER_stop_listening()' has been invoked. The idea is that for "normal" clients we likely want to allow them to process their requests; however, monitor-clients are likely to 'never' disconnect during shutdown and thus will not be considered when determining if the server should continue to exist after GNUNET_SERVER_destroy() has been called.
client | the client to set the 'monitor' flag on |
Definition at line 641 of file tcp_server_legacy.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_YES, and GNUNET_SERVER_Client::is_monitor.
|
static |
Helper function for test_monitor_clients() to trigger GNUNET_SERVER_destroy() after the stack has unwound.
cls | the struct GNUNET_SERVER_Handle * to destroy |
Definition at line 656 of file tcp_server_legacy.c.
References GNUNET_SERVER_destroy().
Referenced by test_monitor_clients().
|
static |
Check if only 'monitor' clients are left.
If so, destroy the server completely.
server | server to test for full shutdown |
Definition at line 671 of file tcp_server_legacy.c.
References GNUNET_SERVER_Handle::clients_head, do_destroy(), GNUNET_NO, GNUNET_SCHEDULER_add_now(), GNUNET_SYSERR, GNUNET_YES, GNUNET_SERVER_Handle::in_soft_shutdown, GNUNET_SERVER_Client::is_monitor, GNUNET_SERVER_Client::next, and GNUNET_SERVER_Client::server.
Referenced by GNUNET_SERVER_client_disconnect(), and GNUNET_SERVER_stop_listening().
void GNUNET_SERVER_suspend | ( | struct GNUNET_SERVER_Handle * | server | ) |
Suspend accepting connections from the listen socket temporarily.
server | server to stop accepting connections. |
Definition at line 692 of file tcp_server_legacy.c.
References GNUNET_SCHEDULER_cancel(), GNUNET_SERVER_Handle::listen_task, and GNUNET_SERVER_Client::server.
Referenced by connect_notify().
void GNUNET_SERVER_resume | ( | struct GNUNET_SERVER_Handle * | server | ) |
Resume accepting connections from the listen socket.
server | server to resume accepting connections. |
Definition at line 703 of file tcp_server_legacy.c.
References GNUNET_NETWORK_fdset_create(), GNUNET_NETWORK_fdset_destroy(), GNUNET_NETWORK_fdset_set(), GNUNET_SCHEDULER_add_read_net_with_priority(), GNUNET_SCHEDULER_add_select(), GNUNET_SCHEDULER_PRIORITY_HIGH, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_SERVER_Handle::listen_sockets, GNUNET_SERVER_Handle::listen_task, and process_listen_socket().
Referenced by disconnect_notify(), GNUNET_SERVER_create_with_sockets(), and process_listen_socket().
void GNUNET_SERVER_stop_listening | ( | struct GNUNET_SERVER_Handle * | server | ) |
Stop the listen socket and get ready to shutdown the server once only 'monitor' clients are left.
server | server to stop listening on |
Definition at line 743 of file tcp_server_legacy.c.
References GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_NETWORK_socket_close(), GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_cancel(), GNUNET_YES, GNUNET_SERVER_Handle::in_soft_shutdown, GNUNET_SERVER_Handle::listen_sockets, GNUNET_SERVER_Handle::listen_task, LOG, and test_monitor_clients().
Referenced by shutdown_task().
void GNUNET_SERVER_destroy | ( | struct GNUNET_SERVER_Handle * | server | ) |
Free resources held by this server.
server | server to destroy |
Definition at line 775 of file tcp_server_legacy.c.
References NotifyList::callback, NotifyList::callback_cls, GNUNET_SERVER_Handle::clients_head, GNUNET_SERVER_Handle::connect_notify_list_head, GNUNET_SERVER_Handle::connect_notify_list_tail, GNUNET_SERVER_Handle::disconnect_notify_list_head, GNUNET_SERVER_Handle::disconnect_notify_list_tail, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_NETWORK_socket_close(), GNUNET_OK, GNUNET_SCHEDULER_cancel(), GNUNET_SERVER_client_disconnect(), GNUNET_SERVER_Handle::handlers, GNUNET_SERVER_Handle::listen_sockets, GNUNET_SERVER_Handle::listen_task, LOG, and HandlerList::next.
Referenced by do_destroy(), LEGACY_SERVICE_stop(), libgnunet_plugin_transport_tcp_done(), and shutdown_task().
void GNUNET_SERVER_add_handlers | ( | struct GNUNET_SERVER_Handle * | server, |
const struct GNUNET_SERVER_MessageHandler * | handlers | ||
) |
Add additional handlers to an existing server.
server | the server to add handlers to |
handlers | array of message handlers for incoming messages; the last entry must have "NULL" for the "callback"; multiple entries for the same type are allowed, they will be called in order of occurrence. These handlers can be removed later; the handlers array must exist until removed (or server is destroyed). |
Definition at line 840 of file tcp_server_legacy.c.
References GNUNET_new, handlers, GNUNET_SERVER_Handle::handlers, and p.
Referenced by LEGACY_SERVICE_start(), libgnunet_plugin_transport_tcp_init(), and service_task().
void GNUNET_SERVER_set_callbacks | ( | struct GNUNET_SERVER_Handle * | server, |
GNUNET_SERVER_MstCreateCallback | create, | ||
GNUNET_SERVER_MstDestroyCallback | destroy, | ||
GNUNET_SERVER_MstReceiveCallback | receive, | ||
void * | cls | ||
) |
Change functions used by the server to tokenize the message stream.
(very rarely used).
server | server to modify |
create | new tokenizer initialization function |
destroy | new tokenizer destruction function |
receive | new tokenizer receive function |
cls | closure for create, receive, destroy |
Definition at line 863 of file tcp_server_legacy.c.
References create, destroy(), GNUNET_SERVER_Handle::mst_cls, GNUNET_SERVER_Handle::mst_create, GNUNET_SERVER_Handle::mst_destroy, and GNUNET_SERVER_Handle::mst_receive.
|
static |
Task run to warn about missing calls to GNUNET_SERVER_receive_done.
cls | our struct GNUNET_SERVER_Client * to process more requests from |
Definition at line 882 of file tcp_server_legacy.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, GNUNET_SERVER_Client::warn_start, GNUNET_SERVER_Client::warn_task, and GNUNET_SERVER_Client::warn_type.
Referenced by GNUNET_SERVER_inject().
void GNUNET_SERVER_disable_receive_done_warning | ( | struct GNUNET_SERVER_Client * | client | ) |
Disable the warning the server issues if a message is not acknowledged in a timely fashion.
Use this call if a client is intentionally delayed for a while. Only applies to the current message.
client | client for which to disable the warning |
Definition at line 908 of file tcp_server_legacy.c.
References GNUNET_SCHEDULER_cancel(), and GNUNET_SERVER_Client::warn_task.
Referenced by handle_tcp_data().
int GNUNET_SERVER_inject | ( | struct GNUNET_SERVER_Handle * | server, |
struct GNUNET_SERVER_Client * | sender, | ||
const struct GNUNET_MessageHeader * | message | ||
) |
Inject a message into the server, pretend it came from the specified client.
Delivery of the message will happen instantly (if a handler is installed; otherwise the call does nothing).
server | the server receiving the message |
sender | the "pretended" sender of the message can be NULL! |
message | message to transmit |
Definition at line 934 of file tcp_server_legacy.c.
References GNUNET_SERVER_MessageHandler::callback, GNUNET_break, GNUNET_break_op, GNUNET_ERROR_TYPE_BULK, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_MESSAGE_TYPE_ALL, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_SYSERR, GNUNET_TIME_absolute_get(), GNUNET_TIME_UNIT_MINUTES, GNUNET_YES, HandlerList::handlers, GNUNET_SERVER_Handle::handlers, LOG, mh, HandlerList::next, GNUNET_SERVER_Handle::require_found, GNUNET_MessageHeader::size, size, GNUNET_SERVER_Client::suspended, GNUNET_MessageHeader::type, type, warn_no_receive_done(), GNUNET_SERVER_Client::warn_start, GNUNET_SERVER_Client::warn_task, and GNUNET_SERVER_Client::warn_type.
Referenced by client_message_tokenizer_callback().
|
static |
We are receiving an incoming message.
Process it.
cls | our closure (handle for the client) |
buf | buffer with data received from network |
available | number of bytes available in buf |
addr | address of the sender |
addrlen | length of addr |
errCode | code indicating errors receiving, 0 for success |
Definition at line 1099 of file tcp_server_legacy.c.
References GNUNET_TIME_Absolute::abs_value_us, buf, GNUNET_SERVER_Client::connection, end, GNUNET_a2s(), GNUNET_assert, GNUNET_break, GNUNET_CONNECTION_check(), GNUNET_CONNECTION_receive(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_MAX_MESSAGE_SIZE, GNUNET_NO, GNUNET_SERVER_client_disconnect(), GNUNET_SERVER_client_drop(), GNUNET_SERVER_client_keep(), GNUNET_SERVER_mst_receive(), GNUNET_TIME_absolute_add(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_remaining(), GNUNET_YES, GNUNET_SERVER_Client::idle_timeout, GNUNET_SERVER_Client::last_activity, LOG, GNUNET_SERVER_Client::mst, GNUNET_SERVER_Handle::mst_cls, GNUNET_SERVER_Handle::mst_receive, process_mst(), GNUNET_SERVER_Client::receive_pending, ret, GNUNET_SERVER_Client::server, and GNUNET_SERVER_Client::shutdown_now.
Referenced by GNUNET_SERVER_connect_socket(), process_mst(), and restart_processing().
|
static |
Process messages from the client's message tokenizer until either the tokenizer is empty (and then schedule receiving more), or until some handler is not immediately done (then wait for restart_processing) or shutdown.
client | the client to process, RC must have already been increased using GNUNET_SERVER_client_keep and will be decreased by one in this function |
ret | GNUNET_NO to start processing from the buffer, GNUNET_OK if the mst buffer is drained and we should instantly go back to receiving GNUNET_SYSERR if we should instantly abort due to error in a previous step |
Definition at line 1038 of file tcp_server_legacy.c.
References GNUNET_SERVER_Client::connection, GNUNET_CONNECTION_receive(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_MAX_MESSAGE_SIZE, GNUNET_NO, GNUNET_OK, GNUNET_SERVER_client_disconnect(), GNUNET_SERVER_mst_receive(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_SYSERR, GNUNET_YES, GNUNET_SERVER_Client::idle_timeout, LOG, GNUNET_SERVER_Client::mst, GNUNET_SERVER_Handle::mst_cls, GNUNET_SERVER_Handle::mst_receive, process_incoming(), GNUNET_SERVER_Client::receive_pending, ret, GNUNET_SERVER_Client::server, GNUNET_SERVER_Client::shutdown_now, and GNUNET_SERVER_Client::suspended.
Referenced by process_incoming(), and restart_processing().
|
static |
Task run to start again receiving from the network and process requests.
cls | our struct GNUNET_SERVER_Client * to process more requests from |
Definition at line 1198 of file tcp_server_legacy.c.
References GNUNET_SERVER_Client::connection, GNUNET_assert, GNUNET_CONNECTION_receive(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_MAX_MESSAGE_SIZE, GNUNET_NO, GNUNET_SERVER_client_drop(), GNUNET_SERVER_client_keep(), GNUNET_YES, GNUNET_SERVER_Client::idle_timeout, LOG, process_incoming(), process_mst(), GNUNET_SERVER_Client::receive_pending, GNUNET_SERVER_Client::restart_task, and GNUNET_SERVER_Client::shutdown_now.
Referenced by GNUNET_SERVER_receive_done().
|
static |
This function is called whenever our inbound message tokenizer has received a complete message.
cls | closure (struct GNUNET_SERVER_Handle) |
client | identification of the client (struct GNUNET_SERVER_Client * ) |
message | the actual message |
Definition at line 1236 of file tcp_server_legacy.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_NO, GNUNET_OK, GNUNET_SERVER_client_disconnect(), GNUNET_SERVER_inject(), GNUNET_SYSERR, GNUNET_YES, GNUNET_SERVER_Client::in_process_client_buffer, LOG, ret, GNUNET_SERVER_Client::server, GNUNET_SERVER_Client::shutdown_now, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.
Referenced by GNUNET_SERVER_connect_socket().
struct GNUNET_SERVER_Client* GNUNET_SERVER_connect_socket | ( | struct GNUNET_SERVER_Handle * | server, |
struct GNUNET_CONNECTION_Handle * | connection | ||
) |
Add a TCP socket-based connection to the set of handles managed by this server.
Use this function for outgoing (P2P) connections that we initiated (and where this server should process incoming messages).
server | the server to use |
connection | the connection to manage (client must stop using this connection from now on) |
Definition at line 1271 of file tcp_server_legacy.c.
References NotifyList::callback, NotifyList::callback_cls, client_message_tokenizer_callback(), GNUNET_SERVER_Handle::clients_head, GNUNET_SERVER_Handle::clients_tail, GNUNET_SERVER_Handle::connect_notify_list_head, GNUNET_SERVER_Client::connection, GNUNET_assert, GNUNET_CONNECTION_receive(), GNUNET_CONTAINER_DLL_insert, GNUNET_MAX_MESSAGE_SIZE, GNUNET_new, GNUNET_SERVER_mst_create(), GNUNET_SYSERR, GNUNET_TIME_absolute_get(), GNUNET_YES, GNUNET_SERVER_Handle::idle_timeout, GNUNET_SERVER_Client::idle_timeout, GNUNET_SERVER_Client::last_activity, GNUNET_SERVER_Client::mst, GNUNET_SERVER_Handle::mst_cls, GNUNET_SERVER_Handle::mst_create, NotifyList::next, process_incoming(), GNUNET_SERVER_Client::receive_pending, and GNUNET_SERVER_Client::server.
Referenced by notify_send_probe(), process_listen_socket(), and tcp_plugin_get_session().
void GNUNET_SERVER_client_set_timeout | ( | struct GNUNET_SERVER_Client * | client, |
struct GNUNET_TIME_Relative | timeout | ||
) |
Change the timeout for a particular client.
Decreasing the timeout may not go into effect immediately (only after the previous timeout times out or activity happens on the socket).
client | the client to update |
timeout | new timeout for activities on the socket |
Definition at line 1316 of file tcp_server_legacy.c.
References GNUNET_SERVER_Client::idle_timeout, and timeout.
Referenced by handle_tcp_welcome(), and tcp_plugin_send().
void GNUNET_SERVER_client_keep | ( | struct GNUNET_SERVER_Client * | client | ) |
Notify the server that the given client handle should be kept (keeps the connection up if possible, increments the internal reference counter).
client | the client to keep |
Definition at line 1331 of file tcp_server_legacy.c.
References GNUNET_SERVER_Client::reference_count.
Referenced by process_incoming(), and restart_processing().
void GNUNET_SERVER_client_drop | ( | struct GNUNET_SERVER_Client * | client | ) |
Notify the server that the given client handle is no longer required.
Decrements the reference counter. If that counter reaches zero an inactive connection maybe closed.
client | the client to drop |
Definition at line 1346 of file tcp_server_legacy.c.
References GNUNET_assert, GNUNET_SERVER_client_disconnect(), GNUNET_YES, GNUNET_SERVER_Client::reference_count, and GNUNET_SERVER_Client::shutdown_now.
Referenced by process_incoming(), and restart_processing().
int GNUNET_SERVER_client_get_address | ( | struct GNUNET_SERVER_Client * | client, |
void ** | addr, | ||
size_t * | addrlen | ||
) |
Obtain the network address of the other party.
client | the client to get the address for |
addr | where to store the address |
addrlen | where to store the length of the addr |
Definition at line 1364 of file tcp_server_legacy.c.
References GNUNET_SERVER_Client::connection, and GNUNET_CONNECTION_get_address().
Referenced by handle_tcp_data(), handle_tcp_nat_probe(), and handle_tcp_welcome().
void GNUNET_SERVER_disconnect_notify | ( | struct GNUNET_SERVER_Handle * | server, |
GNUNET_SERVER_DisconnectCallback | callback, | ||
void * | callback_cls | ||
) |
Ask the server to notify us whenever a client disconnects.
This function is called whenever the actual network connection is closed; the reference count may be zero or larger than zero at this point.
server | the server manageing the clients |
callback | function to call on disconnect |
callback_cls | closure for callback |
Definition at line 1382 of file tcp_server_legacy.c.
References NotifyList::callback, NotifyList::callback_cls, GNUNET_SERVER_Handle::disconnect_notify_list_head, GNUNET_SERVER_Handle::disconnect_notify_list_tail, GNUNET_CONTAINER_DLL_insert, and GNUNET_new.
Referenced by libgnunet_plugin_transport_tcp_init().
void GNUNET_SERVER_connect_notify | ( | struct GNUNET_SERVER_Handle * | server, |
GNUNET_SERVER_ConnectCallback | callback, | ||
void * | callback_cls | ||
) |
Ask the server to notify us whenever a client connects.
This function is called whenever the actual network connection is opened. If the server is destroyed before this notification is explicitly cancelled, the 'callback' will once be called with a 'client' argument of NULL to indicate that the server itself is now gone (and that the callback won't be called anymore and also can no longer be cancelled).
server | the server manageing the clients |
callback | function to call on sconnect |
callback_cls | closure for callback |
Definition at line 1411 of file tcp_server_legacy.c.
References NotifyList::callback, NotifyList::callback_cls, GNUNET_SERVER_Handle::clients_head, GNUNET_SERVER_Handle::connect_notify_list_head, GNUNET_SERVER_Handle::connect_notify_list_tail, GNUNET_CONTAINER_DLL_insert, GNUNET_new, GNUNET_SERVER_Client::next, and GNUNET_SERVER_Client::server.
Referenced by libgnunet_plugin_transport_tcp_init().
void GNUNET_SERVER_disconnect_notify_cancel | ( | struct GNUNET_SERVER_Handle * | server, |
GNUNET_SERVER_DisconnectCallback | callback, | ||
void * | callback_cls | ||
) |
Ask the server to stop notifying us whenever a client connects.
server | the server manageing the clients |
callback | function to call on connect |
callback_cls | closure for callback |
Definition at line 1437 of file tcp_server_legacy.c.
References NotifyList::callback, NotifyList::callback_cls, GNUNET_SERVER_Handle::disconnect_notify_list_head, GNUNET_SERVER_Handle::disconnect_notify_list_tail, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_free, and NotifyList::next.
void GNUNET_SERVER_connect_notify_cancel | ( | struct GNUNET_SERVER_Handle * | server, |
GNUNET_SERVER_ConnectCallback | callback, | ||
void * | callback_cls | ||
) |
Ask the server to stop notifying us whenever a client disconnects.
server | the server manageing the clients |
callback | function to call on disconnect |
callback_cls | closure for callback |
Definition at line 1467 of file tcp_server_legacy.c.
References NotifyList::callback, NotifyList::callback_cls, GNUNET_SERVER_Handle::connect_notify_list_head, GNUNET_SERVER_Handle::connect_notify_list_tail, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_free, and NotifyList::next.
void GNUNET_SERVER_client_disconnect | ( | struct GNUNET_SERVER_Client * | client | ) |
Ask the server to disconnect from the given client.
This is the same as returning GNUNET_SYSERR from a message handler, except that it allows dropping of a client even when not handling a message from that client.
client | the client to disconnect from |
Definition at line 1497 of file tcp_server_legacy.c.
References NotifyList::callback, NotifyList::callback_cls, GNUNET_SERVER_Handle::clients_head, GNUNET_SERVER_Handle::clients_tail, GNUNET_SERVER_Client::connection, GNUNET_SERVER_TransmitHandle::cth, GNUNET_SERVER_Handle::disconnect_notify_list_head, GNUNET_CONNECTION_destroy(), GNUNET_CONNECTION_persist_(), GNUNET_CONNECTION_receive_cancel(), GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_NO, GNUNET_SCHEDULER_cancel(), GNUNET_SERVER_mst_destroy(), GNUNET_SERVER_notify_transmit_ready_cancel(), GNUNET_YES, GNUNET_SERVER_Client::in_process_client_buffer, LOG, GNUNET_SERVER_Client::mst, GNUNET_SERVER_Handle::mst_cls, GNUNET_SERVER_Handle::mst_destroy, NotifyList::next, GNUNET_SERVER_Client::persist, GNUNET_SERVER_Client::receive_pending, GNUNET_SERVER_Client::reference_count, GNUNET_SERVER_Client::restart_task, GNUNET_SERVER_Client::server, GNUNET_SERVER_Client::shutdown_now, test_monitor_clients(), GNUNET_SERVER_Client::th, and GNUNET_SERVER_Client::warn_task.
Referenced by client_message_tokenizer_callback(), GNUNET_SERVER_client_drop(), GNUNET_SERVER_destroy(), GNUNET_SERVER_receive_done(), process_incoming(), process_mst(), and tcp_plugin_disconnect_session().
int GNUNET_SERVER_client_disable_corking | ( | struct GNUNET_SERVER_Client * | client | ) |
Disable the "CORK" feature for communication with the given client, forcing the OS to immediately flush the buffer on transmission instead of potentially buffering multiple messages.
client | handle to the client |
Definition at line 1589 of file tcp_server_legacy.c.
References GNUNET_SERVER_Client::connection, and GNUNET_CONNECTION_disable_corking().
|
static |
Wrapper for transmission notification that calls the original callback and update the last activity time for our connection.
cls | the struct GNUNET_SERVER_Client * |
size | number of bytes we can transmit |
buf | where to copy the message |
Definition at line 1605 of file tcp_server_legacy.c.
References buf, GNUNET_SERVER_TransmitHandle::callback, GNUNET_SERVER_TransmitHandle::callback_cls, GNUNET_SERVER_TransmitHandle::cth, GNUNET_TIME_absolute_get(), GNUNET_SERVER_Client::last_activity, size, and GNUNET_SERVER_Client::th.
Referenced by GNUNET_SERVER_notify_transmit_ready().
struct GNUNET_SERVER_TransmitHandle* GNUNET_SERVER_notify_transmit_ready | ( | struct GNUNET_SERVER_Client * | client, |
size_t | size, | ||
struct GNUNET_TIME_Relative | timeout, | ||
GNUNET_CONNECTION_TransmitReadyNotify | callback, | ||
void * | callback_cls | ||
) |
Notify us when the server has enough space to transmit a message of the given size to the given client.
client | client to transmit message to |
size | requested amount of buffer space |
timeout | after how long should we give up (and call notify with buf NULL and size 0)? |
callback | function to call when space is available |
callback_cls | closure for callback |
Definition at line 1619 of file tcp_server_legacy.c.
References GNUNET_SERVER_TransmitHandle::callback, GNUNET_SERVER_TransmitHandle::callback_cls, GNUNET_SERVER_Client::connection, GNUNET_SERVER_TransmitHandle::cth, GNUNET_CONNECTION_notify_transmit_ready(), size, GNUNET_SERVER_Client::th, timeout, and transmit_ready_callback_wrapper().
Referenced by process_pending_messages().
void GNUNET_SERVER_notify_transmit_ready_cancel | ( | struct GNUNET_SERVER_TransmitHandle * | th | ) |
Abort transmission request.
th | request to abort |
Definition at line 1646 of file tcp_server_legacy.c.
References GNUNET_SERVER_TransmitHandle::callback, GNUNET_SERVER_TransmitHandle::cth, and GNUNET_CONNECTION_notify_transmit_ready_cancel().
Referenced by GNUNET_SERVER_client_disconnect(), and tcp_plugin_disconnect_session().
void GNUNET_SERVER_client_persist_ | ( | struct GNUNET_SERVER_Client * | client | ) |
Set the persistent flag on this client, used to setup client connection to only be killed when the service it's connected to is actually dead.
client | the client to set the persistent flag on |
Definition at line 1662 of file tcp_server_legacy.c.
References GNUNET_YES, and GNUNET_SERVER_Client::persist.
void GNUNET_SERVER_receive_done | ( | struct GNUNET_SERVER_Client * | client, |
int | success | ||
) |
Resume receiving from this client, we are done processing the current request.
This function must be called from within each GNUNET_SERVER_MessageCallback (or its respective continuations).
client | client we were processing a message of |
success | GNUNET_OK to keep the connection open and continue to receive GNUNET_NO to close the connection (normal behavior) GNUNET_SYSERR to close the connection (signal serious error) |
Definition at line 1681 of file tcp_server_legacy.c.
References GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_SERVER_client_disconnect(), GNUNET_YES, GNUNET_SERVER_Client::in_process_client_buffer, LOG, GNUNET_SERVER_Client::reference_count, restart_processing(), GNUNET_SERVER_Client::restart_task, GNUNET_SERVER_Client::server, GNUNET_SERVER_Client::shutdown_now, GNUNET_SERVER_Client::suspended, and GNUNET_SERVER_Client::warn_task.
Referenced by delayed_done(), handle_tcp_data(), handle_tcp_nat_probe(), handle_tcp_welcome(), and write_test().