mturk 2004/07/27 22:38:04 Modified: ajp/ajplib/test httpd_wrap.h httpd_wrap.c Log: Added create_request, create_server. Revision Changes Path 1.4 +89 -1 jakarta-tomcat-connectors/ajp/ajplib/test/httpd_wrap.h Index: httpd_wrap.h =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/ajp/ajplib/test/httpd_wrap.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- httpd_wrap.h 27 Jul 2004 16:28:05 -0000 1.3 +++ httpd_wrap.h 28 Jul 2004 05:38:04 -0000 1.4 @@ -130,6 +130,40 @@ ((x) == HTTP_INTERNAL_SERVER_ERROR) || \ ((x) == HTTP_SERVICE_UNAVAILABLE) || \ ((x) == HTTP_NOT_IMPLEMENTED)) + +/* Default administrator's address */ +#define DEFAULT_ADMIN "[no address given]" +/* The timeout for waiting for messages */ +#ifndef DEFAULT_TIMEOUT +#define DEFAULT_TIMEOUT 300 +#endif +/* The timeout for waiting for keepalive timeout until next request */ +#ifndef DEFAULT_KEEPALIVE_TIMEOUT +#define DEFAULT_KEEPALIVE_TIMEOUT 15 +#endif +/* The number of requests to entertain per connection */ +#ifndef DEFAULT_KEEPALIVE +#define DEFAULT_KEEPALIVE 100 +#endif +#ifndef DEFAULT_LIMIT_REQUEST_LINE +#define DEFAULT_LIMIT_REQUEST_LINE 8190 +#endif /* default limit on bytes in Request-Line (Method+URI+HTTP-version) */ +#ifndef DEFAULT_LIMIT_REQUEST_FIELDSIZE +#define DEFAULT_LIMIT_REQUEST_FIELDSIZE 8190 +#endif /* default limit on bytes in any one header field */ +#ifndef DEFAULT_LIMIT_REQUEST_FIELDS +#define DEFAULT_LIMIT_REQUEST_FIELDS 100 +#endif /* default limit on number of request header fields */ +#ifndef DEFAULT_CONTENT_TYPE +#define DEFAULT_CONTENT_TYPE "text/plain" +#endif +/** + * The address 255.255.255.255, when used as a virtualhost address, + * will become the "default" server when the ip doesn't match other vhosts. + */ +#define DEFAULT_VHOST_ADDR 0xfffffffful + + /** @} */ /** * @defgroup Methods List of Methods recognized by the server @@ -195,6 +229,14 @@ struct process_rec { /** Global pool. Cleared upon normal exit */ apr_pool_t *pool; + /** Configuration pool. Cleared upon restart */ + apr_pool_t *pconf; + /** Number of command line arguments passed to the program */ + int argc; + /** The command line arguments */ + const char * const *argv; + /** The program name used to execute the program */ + const char *short_name; }; /** A structure that represents the current request */ @@ -323,14 +365,52 @@ struct apr_bucket_alloc_t *bucket_alloc; }; +/** A structure to be used for Per-vhost config */ +typedef struct server_addr_rec server_addr_rec; +struct server_addr_rec { + /** The next server in the list */ + server_addr_rec *next; + /** The bound address, for this server */ + apr_sockaddr_t *host_addr; + /** The bound port, for this server */ + apr_port_t host_port; + /** The name given in <VirtualHost> */ + char *virthost; +}; + /** A structure to store information for each virtual server */ struct server_rec { /** The process this server is running in */ process_rec *process; - /** The server hostname */ + /* Contact information */ + /** The admin's contact information */ + char *server_admin; + /** The server hostname */ char *server_hostname; /** for redirects, etc. */ apr_port_t port; + /** The log level for this server */ + int loglevel; + + server_addr_rec *addrs; + /** Timeout, as an apr interval, before we give up */ + apr_interval_time_t timeout; + /** The apr interval we will wait for another request */ + apr_interval_time_t keep_alive_timeout; + /** Maximum requests per connection */ + int keep_alive_max; + /** Use persistent connections? */ + int keep_alive; + + /** true if this is the virtual server */ + int is_virtual; + /** limit on size of the HTTP request line */ + int limit_req_line; + /** limit on size of any request header field */ + int limit_req_fieldsize; + /** limit on number of request header fields */ + int limit_req_fields; + }; /* Apache logging support */ @@ -474,7 +554,15 @@ */ AP_DECLARE(request_rec *) ap_wrap_create_request(conn_rec *conn); +/** + * create the server_rec structure from process_rec. + */ +AP_DECLARE(server_rec *) ap_wrap_create_server(process_rec *process, apr_pool_t *p); +/** + * create the main process_rec. + */ +AP_DECLARE(process_rec *) ap_wrap_create_process(int argc, const char * const *argv); #ifdef __cplusplus } 1.6 +59 -0 jakarta-tomcat-connectors/ajp/ajplib/test/httpd_wrap.c Index: httpd_wrap.c =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/ajp/ajplib/test/httpd_wrap.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- httpd_wrap.c 27 Jul 2004 17:28:31 -0000 1.5 +++ httpd_wrap.c 28 Jul 2004 05:38:04 -0000 1.6 @@ -162,6 +162,65 @@ return r; } +AP_DECLARE(process_rec *) ap_wrap_create_process(int argc, const char * const *argv) +{ + process_rec *process; + apr_pool_t *cntx; + apr_status_t stat; + + stat = apr_pool_create(&cntx, NULL); + if (stat != APR_SUCCESS) { + /* XXX From the time that we took away the NULL pool->malloc mapping + * we have been unable to log here without segfaulting. + */ + ap_log_error(APLOG_MARK, APLOG_ERR, stat, NULL, + "apr_pool_create() failed to create " + "initial context"); + apr_terminate(); + exit(1); + } + + apr_pool_tag(cntx, "process"); + + process = apr_palloc(cntx, sizeof(process_rec)); + process->pool = cntx; + + apr_pool_create(&process->pconf, process->pool); + apr_pool_tag(process->pconf, "pconf"); + process->argc = argc; + process->argv = argv; + process->short_name = apr_filepath_name_get(argv[0]); + return process; +} + +AP_DECLARE(server_rec *) ap_wrap_create_server(process_rec *process, apr_pool_t *p) +{ + apr_status_t rv; + server_rec *s = (server_rec *) apr_pcalloc(p, sizeof(server_rec)); + + s->process = process; + s->port = 0; + s->server_admin = DEFAULT_ADMIN; + s->server_hostname = NULL; + s->loglevel = DEFAULT_LOGLEVEL; + s->limit_req_line = DEFAULT_LIMIT_REQUEST_LINE; + s->limit_req_fieldsize = DEFAULT_LIMIT_REQUEST_FIELDSIZE; + s->limit_req_fields = DEFAULT_LIMIT_REQUEST_FIELDS; + s->timeout = apr_time_from_sec(DEFAULT_TIMEOUT); + s->keep_alive_timeout = apr_time_from_sec(DEFAULT_KEEPALIVE_TIMEOUT); + s->keep_alive_max = DEFAULT_KEEPALIVE; + s->keep_alive = 1; + s->addrs = apr_pcalloc(p, sizeof(server_addr_rec)); + + /* NOT virtual host; don't match any real network interface */ + rv = apr_sockaddr_info_get(&s->addrs->host_addr, + NULL, APR_INET, 0, 0, p); + + s->addrs->host_port = 0; /* matches any port */ + s->addrs->virthost = ""; /* must be non-NULL */ + + return s; +} AP_DECLARE(conn_rec *) ap_run_create_connection(apr_pool_t *ptrans, server_rec *server,
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]