📄 eapi.patch
字号:
return rv;@@ -268,6 +278,9 @@ #if defined (WIN32) || defined(NETWARE) if (fb->flags & B_SOCKET) {+#ifdef EAPI+ if (!ap_hook_call("ap::buff::recvwithtimeout", &rv, fb, buf, nbyte))+#endif /* EAPI */ rv = recvwithtimeout(fb->fd_in, buf, nbyte, 0); if (rv == SOCKET_ERROR) errno = WSAGetLastError();@@ -315,6 +328,9 @@ } else #endif+#ifdef EAPI+ if (!ap_hook_call("ap::buff::write", &rv, fb, buf, nbyte))+#endif /* EAPI */ #if defined (B_SFIO) rv = sfwrite(fb->sf_out, buf, nbyte); #else@@ -341,6 +357,9 @@ #if defined(WIN32) || defined(NETWARE) if (fb->flags & B_SOCKET) {+#ifdef EAPI+ if (!ap_hook_call("ap::buff::sendwithtimeout", &rv, fb, buf, nbyte))+#endif /* EAPI */ rv = sendwithtimeout(fb->fd, buf, nbyte, 0); if (rv == SOCKET_ERROR) errno = WSAGetLastError();@@ -421,6 +440,10 @@ (size_t) SF_UNBOUND, 1, SF_WRITE); #endif +#ifdef EAPI+ fb->ctx = ap_ctx_new(p);+#endif /* EAPI */+ return fb; } @@ -1067,6 +1090,9 @@ i = 0; while (i < nvec) { do+#ifdef EAPI+ if (!ap_hook_call("ap::buff::writev", &rv, fb, &vec[i], nvec -i))+#endif /* EAPI */ rv = writev(fb->fd, &vec[i], nvec - i); while (rv == -1 && (errno == EINTR || errno == EAGAIN) && !(fb->flags & B_EOUT));+---------------------------------------------------------------------------| Add the implementation of the additional `add_module' and| `rewrite_command' module hooks. Additionally the `ctx'| variables are initialized.+---------------------------------------------------------------------------Index: src/main/http_config.c--- src/main/http_config.c 2000/01/21 18:06:29 1.1.1.8+++ src/main/http_config.c 2000/01/21 19:51:10 1.11@@ -582,6 +582,20 @@ m->name = tmp; } #endif /*_OSD_POSIX*/++#ifdef EAPI+ /*+ * Invoke the `add_module' hook inside the now existing set+ * of modules to let them all now that this module was added.+ */+ {+ module *m2;+ for (m2 = top_module; m2 != NULL; m2 = m2->next)+ if (m2->magic == MODULE_MAGIC_COOKIE_EAPI)+ if (m2->add_module != NULL)+ (*m2->add_module)(m);+ }+#endif /* EAPI */ } /* @@ -596,6 +610,21 @@ { module *modp; +#ifdef EAPI+ /*+ * Invoke the `remove_module' hook inside the now existing+ * set of modules to let them all now that this module is+ * beeing removed.+ */+ {+ module *m2;+ for (m2 = top_module; m2 != NULL; m2 = m2->next)+ if (m2->magic == MODULE_MAGIC_COOKIE_EAPI)+ if (m2->remove_module != NULL)+ (*m2->remove_module)(m);+ }+#endif /* EAPI */+ modp = top_module; if (modp == m) { /* We are the top module, special case */@@ -985,6 +1014,27 @@ const command_rec *cmd; module *mod = top_module; +#ifdef EAPI+ /*+ * Invoke the `rewrite_command' of modules to allow+ * they to rewrite the directive line before we+ * process it.+ */+ {+ module *m;+ char *cp;+ for (m = top_module; m != NULL; m = m->next) {+ if (m->magic == MODULE_MAGIC_COOKIE_EAPI) {+ if (m->rewrite_command != NULL) {+ cp = (m->rewrite_command)(parms, config, l);+ if (cp != NULL)+ l = cp;+ }+ }+ }+ }+#endif /* EAPI */+ if ((l[0] == '#') || (!l[0])) return NULL; @@ -1334,6 +1384,10 @@ s->limit_req_fieldsize = main_server->limit_req_fieldsize; s->limit_req_fields = main_server->limit_req_fields; +#ifdef EAPI+ s->ctx = ap_ctx_new(p);+#endif /* EAPI */+ *ps = s; return ap_parse_vhost_addrs(p, hostname, s);@@ -1444,6 +1498,10 @@ s->module_config = create_server_config(p, s); s->lookup_defaults = create_default_per_dir_config(p);++#ifdef EAPI+ s->ctx = ap_ctx_new(p);+#endif /* EAPI */ return s; }+---------------------------------------------------------------------------| Add the ap_global_ctx variable and the new| ap_add_config_define() function. Additionally the| implementation of the additional `new_connection' module hook| is added plus the initialization of one more `ctx' variable.+---------------------------------------------------------------------------Index: src/main/http_main.c--- src/main/http_main.c 2000/02/24 13:55:32 1.1.1.9+++ src/main/http_main.c 2000/02/24 13:58:16 1.30@@ -259,6 +259,9 @@ int ap_listenbacklog; int ap_dump_settings = 0; API_VAR_EXPORT int ap_extended_status = 0;+#ifdef EAPI+API_VAR_EXPORT ap_ctx *ap_global_ctx;+#endif /* EAPI */ /* * The max child slot ever assigned, preserved across restarts. Necessary@@ -438,6 +441,30 @@ } } +#ifdef EAPI+API_EXPORT(void) ap_add_config_define(const char *define)+{+ char **var;+ var = (char **)ap_push_array(ap_server_config_defines);+ *var = ap_pstrdup(pcommands, define);+ return;+}++/*+ * Invoke the `close_connection' hook of modules to let them do+ * some connection dependent actions before we close it.+ */+static void ap_call_close_connection_hook(conn_rec *c)+{+ module *m;+ for (m = top_module; m != NULL; m = m->next)+ if (m->magic == MODULE_MAGIC_COOKIE_EAPI)+ if (m->close_connection != NULL)+ (*m->close_connection)(c);+ return;+}+#endif /* EAPI */+ #ifndef NETWARE static APACHE_TLS int volatile exit_after_unblock = 0; #endif@@ -1188,6 +1215,10 @@ ap_log_transaction(log_req); } +#ifdef EAPI+ ap_call_close_connection_hook(save_req->connection);+#endif /* EAPI */+ ap_bsetflag(save_req->connection->client, B_EOUT, 1); ap_bclose(save_req->connection->client); @@ -1196,6 +1227,9 @@ ap_longjmp(jmpbuffer, 1); } else { /* abort the connection */+#ifdef EAPI+ ap_call_close_connection_hook(current_conn);+#endif /* EAPI */ ap_bsetflag(current_conn->client, B_EOUT, 1); ap_bclose(current_conn->client); current_conn->aborted = 1;@@ -1261,7 +1295,11 @@ } #endif +#ifdef EAPI+API_EXPORT(unsigned int) ap_set_callback_and_alarm(void (*fn) (int), int x)+#else unsigned int ap_set_callback_and_alarm(void (*fn) (int), int x)+#endif { unsigned int old; @@ -1497,10 +1535,16 @@ /* Send any leftover data to the client, but never try to again */ if (ap_bflush(r->connection->client) == -1) {+#ifdef EAPI+ ap_call_close_connection_hook(r->connection);+#endif /* EAPI */ ap_kill_timeout(r); ap_bclose(r->connection->client); return; }+#ifdef EAPI+ ap_call_close_connection_hook(r->connection);+#endif /* EAPI */ ap_bsetflag(r->connection->client, B_EOUT, 1); /* Close our half of the connection --- send the client a FIN */@@ -2200,6 +2244,9 @@ #endif /* Clear the pool - including any registered cleanups */ ap_destroy_pool(pglobal);+#ifdef EAPI+ ap_kill_alloc_shared();+#endif exit(code); } @@ -3208,6 +3255,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; }@@ -3614,6 +3679,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 BIG_SECURITY_HOLE printf(" -D BIG_SECURITY_HOLE\n"); #endif@@ -3767,6 +3841,22 @@ 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 */ } #ifndef MULTITHREAD@@ -4188,6 +4278,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); }@@ -4216,6 +4309,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@@ -4226,6 +4322,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); }@@ -4950,16 +5049,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;@@ -5095,6 +5209,10 @@ ap_destroy_pool(r->pool); } +#ifdef EAPI+ ap_call_close_connection_hook(conn);+#endif /* EAPI */+ ap_bclose(cio); } exit(0);@@ -5446,6 +5564,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@@ -5456,6 +5577,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); }@@ -6782,6 +6906,9 @@ } } +#ifdef EAPI+ ap_init_alloc_shared(TRUE);+#endif if (!ap_os_is_path_absolute(ap_server_confname)) { char *full_conf_path;@@ -6815,6 +6942,10 @@ } #endif server_conf = ap_read_config(pconf, ptrans, ap_server_confname);++#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 2000/01/21 18:06:32 1.1.1.8+++ src/main/http_request.c 2000/01/21 19:51:11 1.7@@ -1316,6 +1316,9 @@ new->no_local_copy = r->no_local_copy; new->read_length = r->read_length; /* We can only read it once */ new->vlist_validator = r->vlist_validator;+#ifdef EAPI+ new->ctx = r->ctx;+#endif /* EAPI */ ap_table_setn(new->subprocess_env, "REDIRECT_STATUS", ap_psprintf(r->pool, "%d", r->status));+---------------------------------------------------------------------------| Just add the initialization of the `ctx' variable for| request_rec structures.+---------------------------------------------------------------------------Index: src/main/http_protocol.c--- src/main/http_protocol.c 2000/02/24 13:55:33 1.1.1.9+++ src/main/http_protocol.c 2000/02/24 13:58:17 1.9@@ -1028,6 +1028,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|B_EBCDIC2ASCII, 1); #endif@@ -1174,6 +1178,11 @@ rnew->read_body = REQUEST_NO_BODY; rnew->main = (request_rec *) r;++#ifdef EAPI+ rnew->ctx = r->ctx;+#endif /* EAPI */+ } 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 1999/08/17 11:22:01 1.1.1.5+++ src/modules/standard/mod_so.c 1999/12/01 07:11:36 1.6@@ -257,11 +257,24 @@ * Make sure the found module structure is really a module structure
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -