cvs commit: jakarta-tomcat-connectors/ajp/proxy proxy_http.c
mturk 2004/08/10 11:05:01 Modified:ajp/proxy proxy_http.c Log: Make sure that the things get logged using the same look-and-feal. Also fix the return code from DECLINED to service unavailable if the connection breaks. Revision ChangesPath 1.5 +15 -8 jakarta-tomcat-connectors/ajp/proxy/proxy_http.c Index: proxy_http.c === RCS file: /home/cvs/jakarta-tomcat-connectors/ajp/proxy/proxy_http.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- proxy_http.c 6 Aug 2004 14:12:22 - 1.4 +++ proxy_http.c 10 Aug 2004 18:05:01 - 1.5 @@ -1115,6 +1115,7 @@ int status; char server_portstr[32]; char *scheme; +const char *proxy_function; const char *u; proxy_conn_rec *backend = NULL; int is_ssl = 0; @@ -1154,12 +1155,19 @@ return DECLINED; } is_ssl = 1; +proxy_function = HTTPS; } else if (!(strcmp(scheme, http) == 0 || (strcmp(scheme, ftp) == 0 proxyname))) { ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r-server, proxy: HTTP: declining URL %s, url); return DECLINED; /* only interested in HTTP, or FTP via proxy */ } +else { +if (*scheme == 'h') +proxy_function = HTTP; +else +proxy_function = FTP; +} ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r-server, proxy: HTTP: serving URL %s, url); @@ -1173,11 +1181,11 @@ } /* create space for state information */ if (!backend) { -status = ap_proxy_acquire_connection(scheme, backend, worker, r-server); +status = ap_proxy_acquire_connection(proxy_function, backend, worker, r-server); if (status != OK) { if (backend) { backend-close_on_recycle = 1; -ap_proxy_release_connection(scheme, backend, r-server); +ap_proxy_release_connection(proxy_function, backend, r-server); } return status; } @@ -1200,14 +1208,13 @@ } /* Step Two: Make the Connection */ -status = ap_proxy_connect_backend(scheme, backend, worker, r-server); -if ( status != OK ) { -return status; +if (ap_proxy_connect_backend(proxy_function, backend, worker, r-server)) { +return HTTP_SERVICE_UNAVAILABLE; } /* Step Three: Create conn_rec */ if (!backend-connection) { -status = ap_proxy_connection_create(scheme, backend, c, r-server); +status = ap_proxy_connection_create(proxy_function, backend, c, r-server); if (status != OK) return status; } @@ -1224,12 +1231,12 @@ server_portstr); if (status != OK) { /* clean up even if there is an error */ -ap_proxy_http_cleanup(scheme, r, backend); +ap_proxy_http_cleanup(proxy_function, r, backend); return status; } /* Step Six: Clean Up */ -status = ap_proxy_http_cleanup(scheme, r, backend); +status = ap_proxy_http_cleanup(proxy_function, r, backend); if ( status != OK ) { return status; } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/ajp/proxy proxy_http.c
mturk 2004/08/06 04:44:45 Modified:ajp/proxy proxy_http.c Log: We have a proxy-http using connection pool ;) Need some thorough testing. Revision ChangesPath 1.2 +82 -284 jakarta-tomcat-connectors/ajp/proxy/proxy_http.c Index: proxy_http.c === RCS file: /home/cvs/jakarta-tomcat-connectors/ajp/proxy/proxy_http.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- proxy_http.c 3 Aug 2004 10:01:18 - 1.1 +++ proxy_http.c 6 Aug 2004 11:44:45 - 1.2 @@ -20,20 +20,13 @@ module AP_MODULE_DECLARE_DATA proxy_http_module; int ap_proxy_http_canon(request_rec *r, char *url); -int ap_proxy_http_handler(request_rec *r, proxy_server_conf *conf, +int ap_proxy_http_handler(request_rec *r, proxy_worker *worker, + proxy_server_conf *conf, char *url, const char *proxyname, apr_port_t proxyport); -typedef struct { -const char *name; -apr_port_t port; -apr_sockaddr_t *addr; -apr_socket_t *sock; -int close; -} proxy_http_conn_t; - -static apr_status_t ap_proxy_http_cleanup(request_rec *r, - proxy_http_conn_t *p_conn, +static apr_status_t ap_proxy_http_cleanup(const char *scheme, + request_rec *r, proxy_conn_rec *backend); /* @@ -146,7 +139,8 @@ const char* domainp ; const char* pathe = NULL; const char* domaine = NULL; -size_t l1, l2, i, poffs = 0, doffs = 0 ; +size_t l1, l2, poffs = 0, doffs = 0 ; +int i; int ddiff = 0 ; int pdiff = 0 ; char* ret ; @@ -248,230 +242,8 @@ } static -apr_status_t ap_proxy_http_determine_connection(apr_pool_t *p, request_rec *r, -proxy_http_conn_t *p_conn, -conn_rec *c, -proxy_server_conf *conf, -apr_uri_t *uri, -char **url, -const char *proxyname, -apr_port_t proxyport, -char *server_portstr, -int server_portstr_size) { -int server_port; -apr_status_t err; -apr_sockaddr_t *uri_addr; -/* - * Break up the URL to determine the host to connect to - */ - -/* we break the URL into host, port, uri */ -if (APR_SUCCESS != apr_uri_parse(p, *url, uri)) { -return ap_proxyerror(r, HTTP_BAD_REQUEST, - apr_pstrcat(p,URI cannot be parsed: , *url, - NULL)); -} -if (!uri-port) { -uri-port = apr_uri_port_of_scheme(uri-scheme); -} - -ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r-server, - proxy: HTTP connecting %s to %s:%d, *url, uri-hostname, - uri-port); - -/* do a DNS lookup for the destination host */ -/* see memory note above */ -err = apr_sockaddr_info_get(uri_addr, apr_pstrdup(c-pool, uri-hostname), -APR_UNSPEC, uri-port, 0, c-pool); - -/* allocate these out of the connection pool - the check on - * r-connection-id makes sure that this string does not get accessed - * past the connection lifetime */ -/* are we connecting directly, or via a proxy? */ -if (proxyname) { -p_conn-name = apr_pstrdup(c-pool, proxyname); -p_conn-port = proxyport; -/* see memory note above */ -err = apr_sockaddr_info_get(p_conn-addr, p_conn-name, APR_UNSPEC, -p_conn-port, 0, c-pool); -} else { -p_conn-name = apr_pstrdup(c-pool, uri-hostname); -p_conn-port = uri-port; -p_conn-addr = uri_addr; -*url = apr_pstrcat(p, uri-path, uri-query ? ? : , - uri-query ? uri-query : , - uri-fragment ? # : , - uri-fragment ? uri-fragment : , NULL); -} - -if (err != APR_SUCCESS) { -return ap_proxyerror(r, HTTP_BAD_GATEWAY, - apr_pstrcat(p, DNS lookup failure for: , - p_conn-name, NULL)); -} - -/* Get the server port for the Via headers */ -{ -server_port = ap_get_server_port(r); -if (ap_is_default_port(server_port, r)) { -
cvs commit: jakarta-tomcat-connectors/ajp/proxy proxy_http.c proxy_util.c
mturk 2004/08/06 07:05:46 Modified:ajp/proxy proxy_http.c proxy_util.c Log: Fix the assertion bug for reslist caused by returning the same connection back to the pool twice. Revision ChangesPath 1.3 +8 -13 jakarta-tomcat-connectors/ajp/proxy/proxy_http.c Index: proxy_http.c === RCS file: /home/cvs/jakarta-tomcat-connectors/ajp/proxy/proxy_http.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- proxy_http.c 6 Aug 2004 11:44:45 - 1.2 +++ proxy_http.c 6 Aug 2004 14:05:45 - 1.3 @@ -796,7 +796,8 @@ } if (len = 0) { apr_socket_close(backend-sock); -backend-connection = NULL; +backend-sock = NULL; +//backend-connection = NULL; ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, proxy: error reading status line from remote server %s, backend-hostname); @@ -819,7 +820,8 @@ */ else if ((buffer[5] != '1') || (len = sizeof(buffer)-1)) { apr_socket_close(backend-sock); -backend-connection = NULL; +//backend-connection = NULL; +backend-sock = NULL; return ap_proxyerror(r, HTTP_BAD_GATEWAY, apr_pstrcat(p, Corrupt status line returned by remote server: , buffer, NULL)); @@ -1029,7 +1031,7 @@ * backend server from hanging around waiting * for a slow client to eat these bytes */ -ap_proxy_http_cleanup(NULL, r, backend); +backend-close = 1; /* signal that we must leave */ finish = TRUE; } @@ -1092,18 +1094,11 @@ /* if the connection is HTTP/1.1, or Connection: close, * we close the socket, otherwise we leave it open for KeepAlive support */ -if (backend-close) { +if (backend-close || (r-proto_num HTTP_VERSION(1,1))) { backend-close_on_recycle = 1; -ap_set_module_config(r-connection, proxy_http_module, backend); +ap_set_module_config(r-connection-conn_config, proxy_http_module, NULL); ap_proxy_release_connection(scheme, backend, r-server); } -else if(r-proto_num HTTP_VERSION(1,1)) { -if (backend-sock) { -apr_socket_close(backend-sock); -backend-sock = NULL; -backend-connection = NULL; -} -} return OK; } @@ -1231,7 +1226,7 @@ /* Step Five: Receive the Response */ status = ap_proxy_http_process_response(p, r, backend, backend-connection, conf, server_portstr); -if ( status != OK ) { +if (status != OK) { /* clean up even if there is an error */ ap_proxy_http_cleanup(scheme, r, backend); return status; 1.20 +22 -39jakarta-tomcat-connectors/ajp/proxy/proxy_util.c Index: proxy_util.c === RCS file: /home/cvs/jakarta-tomcat-connectors/ajp/proxy/proxy_util.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- proxy_util.c 6 Aug 2004 11:43:53 - 1.19 +++ proxy_util.c 6 Aug 2004 14:05:45 - 1.20 @@ -1319,14 +1319,24 @@ static apr_status_t connection_cleanup(void *theconn) { proxy_conn_rec *conn = (proxy_conn_rec *)theconn; +proxy_worker *worker = conn-worker; + /* deterimine if the connection need to be closed */ if (conn-close_on_recycle) { if (conn-sock) apr_socket_close(conn-sock); conn-sock = NULL; } -conn-connection = NULL; -ap_proxy_release_connection(NULL, conn, NULL); +#if APR_HAS_THREADS +if (worker-hmax worker-cp-res) { +apr_reslist_release(worker-cp-res, (void *)conn); +} +else +#endif +{ +worker-cp-conn = conn; +} + /* Allways return the SUCCESS */ return APR_SUCCESS; } @@ -1486,39 +1496,12 @@ server_rec *s) { apr_status_t rv = APR_SUCCESS; -proxy_worker *worker = conn-worker; -if (!worker) { -/* something bad happened. Obviously bug. - * for now make a core dump. - */ -} - -/* Need to close the connection */ -if (conn-sock conn-close) { -apr_socket_close(conn-sock); -conn-sock = NULL; -} -conn-close = 0; /* If there is a connection kill it's cleanup
cvs commit: jakarta-tomcat-connectors/ajp/proxy proxy_http.c
mturk 2004/08/06 07:12:22 Modified:ajp/proxy proxy_http.c Log: Always use the cleanup. Do not close the socket directly. Revision ChangesPath 1.4 +2 -6 jakarta-tomcat-connectors/ajp/proxy/proxy_http.c Index: proxy_http.c === RCS file: /home/cvs/jakarta-tomcat-connectors/ajp/proxy/proxy_http.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- proxy_http.c 6 Aug 2004 14:05:45 - 1.3 +++ proxy_http.c 6 Aug 2004 14:12:22 - 1.4 @@ -795,9 +795,7 @@ len = ap_getline(buffer, sizeof(buffer), rp, 0); } if (len = 0) { -apr_socket_close(backend-sock); -backend-sock = NULL; -//backend-connection = NULL; +ap_proxy_http_cleanup(NULL, r, backend); ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, proxy: error reading status line from remote server %s, backend-hostname); @@ -819,9 +817,7 @@ * if the status line was 8192 bytes */ else if ((buffer[5] != '1') || (len = sizeof(buffer)-1)) { -apr_socket_close(backend-sock); -//backend-connection = NULL; -backend-sock = NULL; +ap_proxy_http_cleanup(NULL, r, backend); return ap_proxyerror(r, HTTP_BAD_GATEWAY, apr_pstrcat(p, Corrupt status line returned by remote server: , buffer, NULL)); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]