summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-04-22 19:52:39 +0000
committerChristian Grothoff <christian@grothoff.org>2012-04-22 19:52:39 +0000
commite2bf225a32bb93731b574ad698f20acbb92a5803 (patch)
treedc151b39eb6bb96eaa03c447a92205e8c4254b58 /src/include
parent9ba0af50e8f41d40163bbac21003261928084c48 (diff)
downloadgnunet-e2bf225a32bb93731b574ad698f20acbb92a5803.tar.gz
gnunet-e2bf225a32bb93731b574ad698f20acbb92a5803.zip
introducing soft shutdown concept for services; during soft shutdown, services that are still managing non-monitor clients continue to run until those clients disconnect; however, the services do stop to accept new connections (will stop listening); soft shutdown is now used by ats, transport, peerinfo, namestore and most importantly statistics; this should fix #2197
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gnunet_server_lib.h26
-rw-r--r--src/include/gnunet_service_lib.h38
2 files changed, 49 insertions, 15 deletions
diff --git a/src/include/gnunet_server_lib.h b/src/include/gnunet_server_lib.h
index 87c3a8f6c..c0a0a5cba 100644
--- a/src/include/gnunet_server_lib.h
+++ b/src/include/gnunet_server_lib.h
@@ -155,6 +155,16 @@ GNUNET_SERVER_create (GNUNET_CONNECTION_AccessCheck access, void *access_cls,
155 155
156 156
157/** 157/**
158 * Stop the listen socket and get ready to shutdown the server
159 * once only 'monitor' clients are left.
160 *
161 * @param server server to stop listening on
162 */
163void
164GNUNET_SERVER_stop_listening (struct GNUNET_SERVER_Handle *server);
165
166
167/**
158 * Free resources held by this server. 168 * Free resources held by this server.
159 * 169 *
160 * @param server server to destroy 170 * @param server server to destroy
@@ -215,6 +225,22 @@ GNUNET_SERVER_notify_transmit_ready_cancel (struct GNUNET_SERVER_TransmitHandle
215 225
216 226
217/** 227/**
228 * Set the 'monitor' flag on this client. Clients which have been
229 * marked as 'monitors' won't prevent the server from shutting down
230 * once 'GNUNET_SERVER_stop_listening' has been invoked. The idea is
231 * that for "normal" clients we likely want to allow them to process
232 * their requests; however, monitor-clients are likely to 'never'
233 * disconnect during shutdown and thus will not be considered when
234 * determining if the server should continue to exist after
235 * 'GNUNET_SERVER_destroy' has been called.
236 *
237 * @param client the client to set the 'monitor' flag on
238 */
239void
240GNUNET_SERVER_client_mark_monitor (struct GNUNET_SERVER_Client *client);
241
242
243/**
218 * Set the persistent flag on this client, used to setup client connection 244 * Set the persistent flag on this client, used to setup client connection
219 * to only be killed when the service it's connected to is actually dead. 245 * to only be killed when the service it's connected to is actually dead.
220 * 246 *
diff --git a/src/include/gnunet_service_lib.h b/src/include/gnunet_service_lib.h
index 1641e0f93..ec0c15e1b 100644
--- a/src/include/gnunet_service_lib.h
+++ b/src/include/gnunet_service_lib.h
@@ -85,16 +85,22 @@ typedef void (*GNUNET_SERVICE_Main) (void *cls,
85 */ 85 */
86enum GNUNET_SERVICE_Options 86enum GNUNET_SERVICE_Options
87{ 87{
88 /** 88 /**
89 * Use defaults. 89 * Use defaults.
90 */ 90 */
91 GNUNET_SERVICE_OPTION_NONE = 0, 91 GNUNET_SERVICE_OPTION_NONE = 0,
92 92
93 /** 93 /**
94 * Do not trigger server shutdown on signals, allow for the user 94 * Do not trigger server shutdown on signals, allow for the user
95 * to terminate the server explicitly when needed. 95 * to terminate the server explicitly when needed.
96 */ 96 */
97 GNUNET_SERVICE_OPTION_MANUAL_SHUTDOWN = 1 97 GNUNET_SERVICE_OPTION_MANUAL_SHUTDOWN = 1,
98
99 /**
100 * Trigger a SOFT server shutdown on signals, allowing active
101 * non-monitor clients to complete their transactions.
102 */
103 GNUNET_SERVICE_OPTION_SOFT_SHUTDOWN = 2
98}; 104};
99 105
100 106
@@ -104,16 +110,16 @@ enum GNUNET_SERVICE_Options
104 * 110 *
105 * @param argc number of command line arguments 111 * @param argc number of command line arguments
106 * @param argv command line arguments 112 * @param argv command line arguments
107 * @param serviceName our service name 113 * @param service_name our service name
108 * @param opt service options 114 * @param options service options
109 * @param task main task of the service 115 * @param task main task of the service
110 * @param task_cls closure for task 116 * @param task_cls closure for task
111 * @return GNUNET_SYSERR on error, GNUNET_OK 117 * @return GNUNET_SYSERR on error, GNUNET_OK
112 * if we shutdown nicely 118 * if we shutdown nicely
113 */ 119 */
114int 120int
115GNUNET_SERVICE_run (int argc, char *const *argv, const char *serviceName, 121GNUNET_SERVICE_run (int argc, char *const *argv, const char *service_name,
116 enum GNUNET_SERVICE_Options opt, GNUNET_SERVICE_Main task, 122 enum GNUNET_SERVICE_Options options, GNUNET_SERVICE_Main task,
117 void *task_cls); 123 void *task_cls);
118 124
119 125
@@ -123,13 +129,15 @@ struct GNUNET_SERVICE_Context;
123 * Run a service startup sequence within an existing 129 * Run a service startup sequence within an existing
124 * initialized system. 130 * initialized system.
125 * 131 *
126 * @param serviceName our service name 132 * @param service_name our service name
127 * @param cfg configuration to use 133 * @param cfg configuration to use
134 * @param options service options
128 * @return NULL on error, service handle 135 * @return NULL on error, service handle
129 */ 136 */
130struct GNUNET_SERVICE_Context * 137struct GNUNET_SERVICE_Context *
131GNUNET_SERVICE_start (const char *serviceName, 138GNUNET_SERVICE_start (const char *service_name,
132 const struct GNUNET_CONFIGURATION_Handle *cfg); 139 const struct GNUNET_CONFIGURATION_Handle *cfg,
140 enum GNUNET_SERVICE_Options options);
133 141
134 142
135/** 143/**