summaryrefslogtreecommitdiffstats
path: root/modules/proxy/mod_proxy_wstunnel.c
diff options
context:
space:
mode:
authorYann Ylavic <ylavic@apache.org>2016-02-10 23:42:57 +0100
committerYann Ylavic <ylavic@apache.org>2016-02-10 23:42:57 +0100
commit64f843d74b84465d21998a0bc1da608eb31057b4 (patch)
treee2988b17effbc01d98c841033991a3ab699e7315 /modules/proxy/mod_proxy_wstunnel.c
parentMake images align center (diff)
downloadapache2-64f843d74b84465d21998a0bc1da608eb31057b4.tar.xz
apache2-64f843d74b84465d21998a0bc1da608eb31057b4.zip
Prefer "goto cleanup" over "do {... if (error) break; ... } while(0)"
construction for error handling/jump (as suggested by Ruediger). Hence we can move backend->close = 1 (for mod_proxy_wstunnel) and proxy_run_detach_backend() (for mod_proxy_http2) in the cleanup fallback. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1729749 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--modules/proxy/mod_proxy_wstunnel.c70
1 files changed, 33 insertions, 37 deletions
diff --git a/modules/proxy/mod_proxy_wstunnel.c b/modules/proxy/mod_proxy_wstunnel.c
index fb88a534cf..0ff50796bc 100644
--- a/modules/proxy/mod_proxy_wstunnel.c
+++ b/modules/proxy/mod_proxy_wstunnel.c
@@ -423,6 +423,7 @@ static int proxy_wstunnel_handler(request_rec *r, proxy_worker *worker,
char *scheme;
conn_rec *c = r->connection;
apr_pool_t *p = r->pool;
+ char *locurl = url;
apr_uri_t *uri;
int is_ssl = 0;
@@ -449,53 +450,48 @@ static int proxy_wstunnel_handler(request_rec *r, proxy_worker *worker,
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(02451) "serving URL %s", url);
/* create space for state information */
- status = ap_proxy_acquire_connection(scheme, &backend, worker,
- r->server);
+ status = ap_proxy_acquire_connection(scheme, &backend, worker, r->server);
if (status != OK) {
- if (backend) {
- backend->close = 1;
- ap_proxy_release_connection(scheme, backend, r->server);
- }
- return status;
+ goto cleanup;
}
backend->is_ssl = is_ssl;
backend->close = 0;
- do { /* while (0): break out */
- char *locurl = url;
- /* Step One: Determine Who To Connect To */
- status = ap_proxy_determine_connection(p, r, conf, worker, backend,
- uri, &locurl, proxyname, proxyport,
- server_portstr,
- sizeof(server_portstr));
- if (status != OK)
- break;
-
- /* Step Two: Make the Connection */
- if (ap_proxy_connect_backend(scheme, backend, worker, r->server)) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02452)
- "failed to make connection to backend: %s",
- backend->hostname);
- status = HTTP_SERVICE_UNAVAILABLE;
- break;
- }
- /* Step Three: Create conn_rec */
- if (!backend->connection) {
- if ((status = ap_proxy_connection_create(scheme, backend,
- c, r->server)) != OK)
- break;
- }
+ /* Step One: Determine Who To Connect To */
+ status = ap_proxy_determine_connection(p, r, conf, worker, backend,
+ uri, &locurl, proxyname, proxyport,
+ server_portstr,
+ sizeof(server_portstr));
+ if (status != OK) {
+ goto cleanup;
+ }
- backend->close = 1; /* must be after ap_proxy_determine_connection */
+ /* Step Two: Make the Connection */
+ if (ap_proxy_connect_backend(scheme, backend, worker, r->server)) {
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02452)
+ "failed to make connection to backend: %s",
+ backend->hostname);
+ status = HTTP_SERVICE_UNAVAILABLE;
+ goto cleanup;
+ }
+
+ /* Step Three: Create conn_rec */
+ if (!backend->connection) {
+ status = ap_proxy_connection_create(scheme, backend, c, r->server);
+ if (status != OK) {
+ goto cleanup;
+ }
+ }
- /* Step Three: Process the Request */
- status = proxy_wstunnel_request(p, r, backend, worker, conf, uri, locurl,
- server_portstr, scheme);
- } while (0);
+ /* Step Three: Process the Request */
+ status = proxy_wstunnel_request(p, r, backend, worker, conf, uri, locurl,
+ server_portstr, scheme);
+cleanup:
/* Do not close the socket */
- if (status != SUSPENDED) {
+ if (backend && status != SUSPENDED) {
+ backend->close = 1;
ap_proxy_release_connection(scheme, backend, r->server);
}
return status;