📄 eapi.patch
字号:
/* Clear the pool - including any registered cleanups */ ap_destroy_pool(pglobal); #endif+#ifdef EAPI+ ap_kill_alloc_shared();+#endif exit(code); } @@ -3722,6 +3764,24 @@ conn->remote_addr = *remaddr; conn->remote_ip = ap_pstrdup(conn->pool, inet_ntoa(conn->remote_addr.sin_addr));+#ifdef EAPI+ conn->ctx = ap_ctx_new(conn->pool);+#endif /* EAPI */++#ifdef EAPI+ /*+ * Invoke the `new_connection' hook of modules to let them do+ * some connection dependent actions before we go on with+ * processing the request on this connection.+ */+ {+ module *m;+ for (m = top_module; m != NULL; m = m->next)+ if (m->magic == MODULE_MAGIC_COOKIE_EAPI)+ if (m->new_connection != NULL)+ (*m->new_connection)(conn);+ }+#endif /* EAPI */ return conn; }@@ -4232,6 +4292,15 @@ printf("Server's Module Magic Number: %u:%u\n", MODULE_MAGIC_NUMBER_MAJOR, MODULE_MAGIC_NUMBER_MINOR); printf("Server compiled with....\n");+#ifdef EAPI+ printf(" -D EAPI\n");+#endif+#ifdef EAPI_MM+ printf(" -D EAPI_MM\n");+#ifdef EAPI_MM_CORE_PATH+ printf(" -D EAPI_MM_CORE_PATH=\"" EAPI_MM_CORE_PATH "\"\n");+#endif+#endif #ifdef TPF show_os_specific_compile_settings(); #endif@@ -4407,6 +4476,23 @@ ap_server_pre_read_config = ap_make_array(pcommands, 1, sizeof(char *)); ap_server_post_read_config = ap_make_array(pcommands, 1, sizeof(char *)); ap_server_config_defines = ap_make_array(pcommands, 1, sizeof(char *));++#ifdef EAPI+ ap_hook_init();+ ap_hook_configure("ap::buff::read", + AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST);+ ap_hook_configure("ap::buff::write", + AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST);+ ap_hook_configure("ap::buff::writev", + AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST);+ ap_hook_configure("ap::buff::sendwithtimeout", + AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST);+ ap_hook_configure("ap::buff::recvwithtimeout", + AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST);++ ap_global_ctx = ap_ctx_new(NULL);+#endif /* EAPI */+ /* overkill since static */ for (i = 0; i < HARD_SERVER_LIMIT; i++) { pid_table[i] = 0;@@ -4907,6 +4993,9 @@ ap_sync_scoreboard_image(); if (ap_scoreboard_image->global.running_generation != ap_my_generation) {+#ifdef EAPI+ ap_call_close_connection_hook(current_conn);+#endif /* EAPI */ ap_bclose(conn_io); clean_child_exit(0); }@@ -4935,6 +5024,9 @@ */ #ifdef NO_LINGCLOSE+#ifdef EAPI+ ap_call_close_connection_hook(current_conn);+#endif /* EAPI */ ap_bclose(conn_io); /* just close it */ #else if (r && r->connection@@ -4945,6 +5037,9 @@ lingering_close(r); } else {+#ifdef EAPI+ ap_call_close_connection_hook(current_conn);+#endif /* EAPI */ ap_bsetflag(conn_io, B_EOUT, 1); ap_bclose(conn_io); }@@ -5745,16 +5840,31 @@ usage(argv[0]); } }+#ifdef EAPI+ ap_init_alloc_shared(TRUE);+#endif ap_suexec_enabled = init_suexec(); server_conf = ap_read_config(pconf, ptrans, ap_server_confname); +#ifdef EAPI+ ap_init_alloc_shared(FALSE);+#endif+ if (ap_configtestonly) { fprintf(stderr, "Syntax OK\n");+#ifdef EAPI+ clean_parent_exit(0);+#else exit(0);+#endif } if (ap_dump_settings) {+#ifdef EAPI+ clean_parent_exit(0);+#else exit(0);+#endif } child_timeouts = !ap_standalone || one_process;@@ -5902,6 +6012,10 @@ ap_destroy_pool(r->pool); } +#ifdef EAPI+ ap_call_close_connection_hook(conn);+#endif /* EAPI */+ ap_bclose(cio); } exit(0);@@ -6278,6 +6392,9 @@ ap_kill_cleanups_for_socket(ptrans, csd); #ifdef NO_LINGCLOSE+#ifdef EAPI+ ap_call_close_connection_hook(current_conn);+#endif /* EAPI */ ap_bclose(conn_io); /* just close it */ #else if (r && r->connection@@ -6288,6 +6405,9 @@ lingering_close(r); } else {+#ifdef EAPI+ ap_call_close_connection_hook(current_conn);+#endif /* EAPI */ ap_bsetflag(conn_io, B_EOUT, 1); ap_bclose(conn_io); }@@ -7863,6 +7983,10 @@ if (!conf_specified) ap_cpystrn(ap_server_confname, SERVER_CONFIG_FILE, sizeof(ap_server_confname)); +#ifdef EAPI+ ap_init_alloc_shared(TRUE);+#endif+ if (!ap_os_is_path_absolute(ap_server_confname)) ap_cpystrn(ap_server_confname, ap_server_root_relative(pcommands, ap_server_confname),@@ -7903,6 +8027,9 @@ #else /* ndef WIN32 */ server_conf = ap_read_config(pconf, ptrans, ap_server_confname); #endif+#ifdef EAPI+ ap_init_alloc_shared(FALSE);+#endif if (ap_configtestonly) { fprintf(stderr, "%s: Syntax OK\n", ap_server_root_relative(pcommands, ap_server_confname));+---------------------------------------------------------------------------| Just add the initialization of the `ctx' variable for| conn_rec structures.+---------------------------------------------------------------------------Index: src/main/http_request.c--- src/main/http_request.c 28 Jul 2006 13:55:34 -0000 1.1.1.20+++ src/main/http_request.c 28 Jul 2006 13:56:29 -0000 1.20@@ -1373,6 +1373,10 @@ new->method = r->method; new->method_number = r->method_number;+#ifdef EAPI+ /* initialize context _BEFORE_ ap_parse_uri() call */+ new->ctx = r->ctx;+#endif /* EAPI */ ap_parse_uri(new, new_uri); new->request_config = ap_create_request_config(r->pool); new->per_dir_config = r->server->lookup_defaults;+---------------------------------------------------------------------------| Just add the initialization of the `ctx' variable for| request_rec structures.+---------------------------------------------------------------------------Index: src/main/http_protocol.c--- src/main/http_protocol.c 28 Jul 2006 13:55:34 -0000 1.1.1.24+++ src/main/http_protocol.c 28 Jul 2006 13:56:29 -0000 1.24@@ -1173,6 +1173,10 @@ r->status = HTTP_REQUEST_TIME_OUT; /* Until we get a request */ r->the_request = NULL; +#ifdef EAPI+ r->ctx = ap_ctx_new(r->pool);+#endif /* EAPI */+ #ifdef CHARSET_EBCDIC ap_bsetflag(r->connection->client, B_ASCII2EBCDIC, r->ebcdic.conv_in = 1); ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, r->ebcdic.conv_out = 1);@@ -1341,6 +1345,11 @@ rnew->read_body = REQUEST_NO_BODY; rnew->main = (request_rec *) r;++#ifdef EAPI+ rnew->ctx = r->ctx;+#endif /* EAPI */+ } API_EXPORT(void) ap_finalize_sub_req_protocol(request_rec *sub)+---------------------------------------------------------------------------| Add support for loading both EAPI and AP13 modules.+---------------------------------------------------------------------------Index: src/modules/standard/mod_so.c--- src/modules/standard/mod_so.c 28 Jul 2006 13:55:28 -0000 1.1.1.13+++ src/modules/standard/mod_so.c 28 Jul 2006 13:56:29 -0000 1.14@@ -267,11 +267,24 @@ * Make sure the found module structure is really a module structure * */+#ifdef EAPI+ if ( modp->magic != MODULE_MAGIC_COOKIE_AP13 + && modp->magic != MODULE_MAGIC_COOKIE_EAPI) {+#else if (modp->magic != MODULE_MAGIC_COOKIE) {+#endif return ap_pstrcat(cmd->pool, "API module structure `", modname, "' in file ", szModuleFile, " is garbled -" " perhaps this is not an Apache module DSO?", NULL); }+#ifdef EAPI+ if (modp->magic == MODULE_MAGIC_COOKIE_AP13) {+ ap_log_error(APLOG_MARK, APLOG_WARNING|APLOG_NOERRNO, NULL,+ "Loaded DSO %s uses plain Apache 1.3 API, "+ "this module might crash under EAPI! "+ "(please recompile it with -DEAPI)", filename);+ }+#endif /* * Add this module to the Apache core structures+---------------------------------------------------------------------------| Add additional logging functions to the CustomLog directive| which can be used by other modules to create additional| logfile tags. Actually we add two types of hooks: One hook| for intercepting the new and generic %x (eXtension) tag and| one hook for creating new %x tags at all.+---------------------------------------------------------------------------Index: src/modules/standard/mod_log_config.c--- src/modules/standard/mod_log_config.c 28 Jul 2006 13:55:27 -0000 1.1.1.16+++ src/modules/standard/mod_log_config.c 28 Jul 2006 13:56:29 -0000 1.29@@ -221,6 +221,9 @@ typedef const char *(*item_key_func) (request_rec *, char *); typedef struct {+#ifdef EAPI+ char ch;+#endif item_key_func func; char *arg; int condition_sense;@@ -542,15 +545,36 @@ } }; +#ifdef EAPI+static struct log_item_list *find_log_func(pool *p, char k)+#else /* EAPI */ static struct log_item_list *find_log_func(char k)+#endif /* EAPI */ { int i;+#ifdef EAPI+ struct log_item_list *lil;+#endif /* EAPI */ for (i = 0; log_item_keys[i].ch; ++i) if (k == log_item_keys[i].ch) { return &log_item_keys[i]; } +#ifdef EAPI+ if (ap_hook_status(ap_psprintf(p, "ap::mod_log_config::log_%c", k)) + != AP_HOOK_STATE_NOTEXISTANT) {+ lil = (struct log_item_list *)+ ap_pcalloc(p, sizeof(struct log_item_list));+ if (lil == NULL)+ return NULL;+ lil->ch = k;+ lil->func = NULL;+ lil->want_orig_default = 0;+ return lil;+ }+#endif /* EAPI */+ return NULL; } @@ -676,7 +700,11 @@ break; default:+#ifdef EAPI+ l = find_log_func(p, *s++);+#else /* EAPI */ l = find_log_func(*s++);+#endif /* EAPI */ if (!l) { char dummy[2]; @@ -685,6 +713,9 @@ return ap_pstrcat(p, "Unrecognized LogFormat directive %", dummy, NULL); }+#ifdef EAPI+ it->ch = s[-1];+#endif it->func = l->func; if (it->want_orig == -1) { it->want_orig = l->want_orig_default;@@ -746,6 +777,15 @@ /* We do. Do it... */ +#ifdef EAPI+ if (item->func == NULL) {+ cp = NULL;+ ap_hook_use(ap_psprintf(r->pool, "ap::mod_log_config::log_%c", item->ch),+ AP_HOOK_SIG3(ptr,ptr,ptr), AP_HOOK_DECLINE(NULL),+ &cp, r, item->arg);+ }+ else+#endif cp = (*item->func) (item->want_orig ? orig : r, item->arg); return cp ? cp : "-"; }+---------------------------------------------------------------------------| Allow RewriteCond and RewriteRule directives to lookup | variables from other modules.+---------------------------------------------------------------------------Index: src/modules/standard/mod_rewrite.c--- src/modules/standard/mod_rewrite.c 28 Jul 2006 13:55:29 -0000 1.1.1.22+++ src/modules/standard/mod_rewrite.c 28 Jul 2006 13:56:29 -0000 1.20@@ -3864,6 +3864,15 @@ } #endif /* ndef WIN32 && NETWARE*/ +#ifdef EAPI+ else {+ ap_hook_use("ap::mod_rewrite::lookup_variable",+ AP_HOOK_SIG3(ptr,ptr,ptr), + AP_HOOK_DECLINE(NULL),+ &result, r, var);+ }+#endif+ if (result == NULL) { return ap_pstrdup(r->pool, ""); }+---------------------------------------------------------------------------| Add an EAPI hook to allow other modules to add content to | the status HTML page.+---------------------------------------------------------------------------Index: src/modules/standard/mod_status.c--- src/modules/standard/mod_status.c 8 Feb 2008 11:15:41 -0000 1.1.1.19+++ src/modules/standard/mod_status.c 8 Feb 2008 11:17:39 -0000 1.16@@ -696,6 +733,12 @@ #endif }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -