You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by yl...@apache.org on 2021/09/09 16:55:24 UTC
svn commit: r1893184 - in /httpd/httpd/trunk:
changes-entries/ap_create_connection.txt include/ap_mmn.h
include/http_connection.h modules/proxy/mod_proxy_connect.c
modules/proxy/mod_proxy_ftp.c modules/proxy/proxy_util.c
server/connection.c server/log.c
Author: ylavic
Date: Thu Sep 9 16:55:24 2021
New Revision: 1893184
URL: http://svn.apache.org/viewvc?rev=1893184&view=rev
Log:
core: Add ap_create_connection() to create a server or client/proxy connection.
c->outgoing shouldn't be set by mod_ssl, ap_create_connection() allows that
and this commit also replaces all the calls to ap_run_create_connection() in
mod_proxy modules (not in the MPMs which create incoming connections only).
* include/http_connection.h, server/connection.c:
Declare and implement ap_create_connection().
* modules/proxy/proxy_util.c, modules/proxy/mod_proxy_connect.c,
modules/proxy/mod_proxy_ftp.c:
Use ap_create_connection() instead of ap_run_create_connection(), and don't
provide a connection_id a scoreboard handle for outgoing connection.
* server/log.c(do_errorlog_default):
Use c->outgoing instead of c->sbh to determine if it's a "client" or "remote"
connection.
Added:
httpd/httpd/trunk/changes-entries/ap_create_connection.txt
Modified:
httpd/httpd/trunk/include/ap_mmn.h
httpd/httpd/trunk/include/http_connection.h
httpd/httpd/trunk/modules/proxy/mod_proxy_connect.c
httpd/httpd/trunk/modules/proxy/mod_proxy_ftp.c
httpd/httpd/trunk/modules/proxy/proxy_util.c
httpd/httpd/trunk/server/connection.c
httpd/httpd/trunk/server/log.c
Added: httpd/httpd/trunk/changes-entries/ap_create_connection.txt
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/changes-entries/ap_create_connection.txt?rev=1893184&view=auto
==============================================================================
--- httpd/httpd/trunk/changes-entries/ap_create_connection.txt (added)
+++ httpd/httpd/trunk/changes-entries/ap_create_connection.txt Thu Sep 9 16:55:24 2021
@@ -0,0 +1,2 @@
+ *) core: Add ap_create_connection() to create either a server or client/proxy
+ connection.
\ No newline at end of file
Modified: httpd/httpd/trunk/include/ap_mmn.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mmn.h?rev=1893184&r1=1893183&r2=1893184&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_mmn.h (original)
+++ httpd/httpd/trunk/include/ap_mmn.h Thu Sep 9 16:55:24 2021
@@ -679,6 +679,7 @@
* ap_proxy_define_worker_ex() to mod_proxy.h
* 20210531.3 (2.5.1-dev) Add hook child_stopping to get informed that a child
* is being shut down.
+ * 20210531.4 (2.5.1-dev) Add ap_create_connection
*/
#define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */
@@ -686,7 +687,7 @@
#ifndef MODULE_MAGIC_NUMBER_MAJOR
#define MODULE_MAGIC_NUMBER_MAJOR 20210531
#endif
-#define MODULE_MAGIC_NUMBER_MINOR 3 /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 4 /* 0...n */
/**
* Determine if the server's current MODULE_MAGIC_NUMBER is at least a
Modified: httpd/httpd/trunk/include/http_connection.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/http_connection.h?rev=1893184&r1=1893183&r2=1893184&view=diff
==============================================================================
--- httpd/httpd/trunk/include/http_connection.h (original)
+++ httpd/httpd/trunk/include/http_connection.h Thu Sep 9 16:55:24 2021
@@ -135,6 +135,28 @@ AP_DECLARE_HOOK(int,process_connection,(
*/
AP_DECLARE_HOOK(int,pre_close_connection,(conn_rec *c))
+/**
+ * Create a new server/incoming or client/outgoing/proxy connection
+ * @param p The pool from which to allocate the connection record
+ * @param server The server record to create the connection too.
+ * @param csd The socket that has been accepted
+ * @param conn_id A unique identifier for this connection. The ID only
+ * needs to be unique at that time, not forever.
+ * @param sbh A handle to scoreboard information for this connection.
+ * @param alloc The bucket allocator to use for all bucket/brigade creations
+ * @param outgoing Whether it's an outgoing (client) connection
+ * @return An allocated connection record or NULL.
+ * @remark To allow for future flags, outgoing must be a boolean (0 or 1)
+ * for now, otherwise NULL is returned
+ */
+AP_DECLARE(conn_rec *) ap_create_connection(apr_pool_t *p,
+ server_rec *server,
+ apr_socket_t *csd,
+ long conn_id, void *sbh,
+ apr_bucket_alloc_t *alloc,
+ unsigned int outgoing);
+
+
/** End Of Connection (EOC) bucket */
AP_DECLARE_DATA extern const apr_bucket_type_t ap_bucket_type_eoc;
Modified: httpd/httpd/trunk/modules/proxy/mod_proxy_connect.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy_connect.c?rev=1893184&r1=1893183&r2=1893184&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_connect.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_connect.c Thu Sep 9 16:55:24 2021
@@ -261,8 +261,8 @@ static int proxy_connect_handler(request
* Send the HTTP/1.1 CONNECT request to the remote server
*/
- backconn = ap_run_create_connection(c->pool, r->server, sock,
- c->id, c->sbh, c->bucket_alloc);
+ backconn = ap_create_connection(c->pool, r->server, sock, 0, NULL,
+ c->bucket_alloc, 1);
if (!backconn) {
/* peer reset */
ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, APLOGNO(01021)
Modified: httpd/httpd/trunk/modules/proxy/mod_proxy_ftp.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy_ftp.c?rev=1893184&r1=1893183&r2=1893184&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_ftp.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_ftp.c Thu Sep 9 16:55:24 2021
@@ -1968,11 +1968,11 @@ static int proxy_ftp_handler(request_rec
}
/* the transfer socket is now open, create a new connection */
- data = ap_run_create_connection(p, r->server, data_sock, r->connection->id,
- r->connection->sbh, c->bucket_alloc);
+ data = ap_create_connection(p, r->server, data_sock, 0, NULL,
+ c->bucket_alloc, 1);
if (!data) {
/*
- * the peer reset the connection already; ap_run_create_connection() closed
+ * the peer reset the connection already; ap_create_connection() closed
* the socket
*/
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01054)
Modified: httpd/httpd/trunk/modules/proxy/proxy_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/proxy_util.c?rev=1893184&r1=1893183&r2=1893184&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/proxy_util.c (original)
+++ httpd/httpd/trunk/modules/proxy/proxy_util.c Thu Sep 9 16:55:24 2021
@@ -3404,13 +3404,12 @@ static int proxy_connection_create(const
/*
* The socket is now open, create a new backend server connection
*/
- conn->connection = ap_run_create_connection(conn->scpool, s, conn->sock,
- 0, NULL,
- bucket_alloc);
+ conn->connection = ap_create_connection(conn->scpool, s, conn->sock,
+ 0, NULL, bucket_alloc, 1);
if (!conn->connection) {
/*
- * the peer reset the connection already; ap_run_create_connection()
+ * the peer reset the connection already; ap_create_connection()
* closed the socket
*/
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0,
Modified: httpd/httpd/trunk/server/connection.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/connection.c?rev=1893184&r1=1893183&r2=1893184&view=diff
==============================================================================
--- httpd/httpd/trunk/server/connection.c (original)
+++ httpd/httpd/trunk/server/connection.c Thu Sep 9 16:55:24 2021
@@ -43,6 +43,29 @@ AP_IMPLEMENT_HOOK_RUN_FIRST(int,process_
AP_IMPLEMENT_HOOK_RUN_ALL(int,pre_connection,(conn_rec *c, void *csd),(c, csd),OK,DECLINED)
AP_IMPLEMENT_HOOK_RUN_ALL(int,pre_close_connection,(conn_rec *c),(c),OK,DECLINED)
+AP_DECLARE(conn_rec *) ap_create_connection(apr_pool_t *p,
+ server_rec *server,
+ apr_socket_t *csd,
+ long conn_id, void *sbh,
+ apr_bucket_alloc_t *alloc,
+ unsigned int outgoing)
+{
+ conn_rec *c;
+
+ /* Some day it may be flags, so deny anything but 0 or 1 for now */
+ if (outgoing > 1) {
+ return NULL;
+ }
+
+ c = ap_run_create_connection(p, server, csd, conn_id, sbh, alloc);
+
+ if (c && outgoing) {
+ c->outgoing = 1;
+ }
+
+ return c;
+}
+
/*
* More machine-dependent networking gooo... on some systems,
* you've got to be *really* sure that all the packets are acknowledged
Modified: httpd/httpd/trunk/server/log.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/log.c?rev=1893184&r1=1893183&r2=1893184&view=diff
==============================================================================
--- httpd/httpd/trunk/server/log.c (original)
+++ httpd/httpd/trunk/server/log.c Thu Sep 9 16:55:24 2021
@@ -914,14 +914,14 @@ static int do_errorlog_default(const ap_
* a scoreboard handle, it is likely a client.
*/
if (info->r) {
- len += apr_snprintf(buf + len, buflen - len,
- info->r->connection->sbh ? "[client %s:%d] " : "[remote %s:%d] ",
+ len += apr_snprintf(buf + len, buflen - len, "[%s %s:%d] ",
+ info->r->connection->outgoing ? "remote" : "client",
info->r->useragent_ip,
info->r->useragent_addr ? info->r->useragent_addr->port : 0);
}
else if (info->c) {
- len += apr_snprintf(buf + len, buflen - len,
- info->c->sbh ? "[client %s:%d] " : "[remote %s:%d] ",
+ len += apr_snprintf(buf + len, buflen - len, "[%s %s:%d] ",
+ info->c->outgoing ? "remote" : "client",
info->c->client_ip,
info->c->client_addr ? info->c->client_addr->port : 0);
}