aboutsummaryrefslogtreecommitdiff
path: root/src/daemon/internal.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2007-08-08 08:07:49 +0000
committerChristian Grothoff <christian@grothoff.org>2007-08-08 08:07:49 +0000
commit0cacf72380222e704cff8c05b329ba6bac41f631 (patch)
tree5fb26264b53a285aece3bb0912645da2275a4715 /src/daemon/internal.h
parent5b7eec5d2d858dd33aa7f65a7655de1410154f0a (diff)
downloadlibmicrohttpd-0cacf72380222e704cff8c05b329ba6bac41f631.tar.gz
libmicrohttpd-0cacf72380222e704cff8c05b329ba6bac41f631.zip
updates
Diffstat (limited to 'src/daemon/internal.h')
-rw-r--r--src/daemon/internal.h87
1 files changed, 78 insertions, 9 deletions
diff --git a/src/daemon/internal.h b/src/daemon/internal.h
index 101acfdd..efadb33a 100644
--- a/src/daemon/internal.h
+++ b/src/daemon/internal.h
@@ -37,6 +37,7 @@
37#include <errno.h> 37#include <errno.h>
38#include <fcntl.h> 38#include <fcntl.h>
39#include <signal.h> 39#include <signal.h>
40#include <sys/mman.h>
40 41
41#include "config.h" 42#include "config.h"
42#include "plibc.h" 43#include "plibc.h"
@@ -49,8 +50,6 @@
49 50
50#include <pthread.h> 51#include <pthread.h>
51 52
52#define MHD_MAX_BUF_SIZE 2048
53
54#define MAX(a,b) ((a)<(b)) ? (b) : (a) 53#define MAX(a,b) ((a)<(b)) ? (b) : (a)
55 54
56 55
@@ -157,41 +156,72 @@ struct MHD_Response {
157 156
158 157
159struct MHD_Connection { 158struct MHD_Connection {
159
160 /**
161 * This is a linked list.
162 */
160 struct MHD_Connection * next; 163 struct MHD_Connection * next;
161 164
165 /**
166 * Reference to the MHD_Daemon struct.
167 */
162 struct MHD_Daemon * daemon; 168 struct MHD_Daemon * daemon;
163 169
170 /**
171 * Linked list of parsed headers.
172 */
164 struct MHD_HTTP_Header * headers_received; 173 struct MHD_HTTP_Header * headers_received;
165 174
175 /**
176 * Response to transmit (initially NULL).
177 */
166 struct MHD_Response * response; 178 struct MHD_Response * response;
167 179
168 /** 180 /**
169 * Request method. Should be GET/POST/etc. 181 * The memory pool is created whenever we first read
182 * from the TCP stream and destroyed at the end of
183 * each request (and re-created for the next request).
184 * In the meantime, this pointer is NULL. The
185 * pool is used for all connection-related data
186 * except for the response (which maybe shared between
187 * connections) and the IP address (which persists
188 * across individual requests).
189 */
190 struct MemoryPool * pool;
191
192 /**
193 * Request method. Should be GET/POST/etc. Allocated
194 * in pool.
170 */ 195 */
171 char * method; 196 char * method;
172 197
173 /** 198 /**
174 * Requested URL (everything after "GET" only). 199 * Requested URL (everything after "GET" only). Allocated
200 * in pool.
175 */ 201 */
176 char * url; 202 char * url;
177 203
178 /** 204 /**
179 * HTTP version string (i.e. http/1.1) 205 * HTTP version string (i.e. http/1.1). Allocated
206 * in pool.
180 */ 207 */
181 char * version; 208 char * version;
182 209
183 /** 210 /**
184 * Buffer for reading requests. 211 * Buffer for reading requests. Allocated
212 * in pool.
185 */ 213 */
186 char * read_buffer; 214 char * read_buffer;
187 215
188 /** 216 /**
189 * Buffer for writing response. 217 * Buffer for writing response (headers only). Allocated
218 * in pool.
190 */ 219 */
191 char * write_buffer; 220 char * write_buffer;
192 221
193 /** 222 /**
194 * Foreign address (of length addr_len). 223 * Foreign address (of length addr_len). MALLOCED (not
224 * in pool!).
195 */ 225 */
196 struct sockaddr_in * addr; 226 struct sockaddr_in * addr;
197 227
@@ -201,12 +231,30 @@ struct MHD_Connection {
201 */ 231 */
202 pthread_t pid; 232 pthread_t pid;
203 233
234 /**
235 * Size of read_buffer (in bytes).
236 */
204 size_t read_buffer_size; 237 size_t read_buffer_size;
205 238
239 /**
240 * Position where we currently append data in
241 * read_buffer (last valid position).
242 */
206 size_t readLoc; 243 size_t readLoc;
207 244
245 /**
246 * Size of write_buffer (in bytes).
247 */
208 size_t write_buffer_size; 248 size_t write_buffer_size;
209 249
250 /**
251 * Offset where we are with sending from write_buffer.
252 */
253 size_t writePos;
254
255 /**
256 * Last valid location in write_buffer.
257 */
210 size_t writeLoc; 258 size_t writeLoc;
211 259
212 /** 260 /**
@@ -264,6 +312,11 @@ struct MHD_Connection {
264 int headersSent; 312 int headersSent;
265 313
266 /** 314 /**
315 * Are we processing the POST data?
316 */
317 int post_processed;
318
319 /**
267 * HTTP response code. Only valid if response object 320 * HTTP response code. Only valid if response object
268 * is already set. 321 * is already set.
269 */ 322 */
@@ -279,6 +332,9 @@ struct MHD_Daemon {
279 332
280 struct MHD_Access_Handler default_handler; 333 struct MHD_Access_Handler default_handler;
281 334
335 /**
336 * Linked list of our current connections.
337 */
282 struct MHD_Connection * connections; 338 struct MHD_Connection * connections;
283 339
284 MHD_AcceptPolicyCallback apc; 340 MHD_AcceptPolicyCallback apc;
@@ -301,11 +357,24 @@ struct MHD_Daemon {
301 int shutdown; 357 int shutdown;
302 358
303 /** 359 /**
360 * Size of the per-connection memory pools.
361 */
362 unsigned int pool_size;
363
364 /**
365 * Limit on the number of parallel connections.
366 */
367 unsigned int max_connections;
368
369 /**
304 * Daemon's options. 370 * Daemon's options.
305 */ 371 */
306 enum MHD_OPTION options; 372 enum MHD_OPTION options;
307 373
308 unsigned short port; 374 /**
375 * Listen port.
376 */
377 unsigned short port;
309 378
310}; 379};
311 380