Le 27/06/2014 06:44, Christophe JAILLET a écrit :
Le 26/06/2014 05:34, Eric Covener a écrit :
I think this is only a performance concern.
Hi,
I have on my local tree an attempt to speed-up wstunnel by removing
useless processing mostly for non-EBCDIC server.
The idea, taken from mod_proxy_http, is to:
- avoid a call to 'apr_pstrcat' to built a constant string
- avoid calls to 'strlen' (even if gcc should be able to remove
one of them at compile time)
I tried to go one step further, for non-EBCDIC server, and use an
immortal bucket instead of the pool one. This avoids the allocation of
a few bytes in a memory pool and saves a memcpy.
Obviously, this is done only once per-connection when the request is
upgraded to WS.
This is untested and I was wondering if it would make any difference
in the real world?
Do you think it worses the added complexity ?
The same kind of approach can also be done in mod_proxy_http in order
to avoid a memory allocation and a strcpy.
Best regards,
CJ
With a non-empty file, it's better !
CJ
Index: mod_proxy_wstunnel.c
===================================================================
--- mod_proxy_wstunnel.c (révision 1605659)
+++ mod_proxy_wstunnel.c (copie de travail)
@@ -325,7 +325,9 @@
conn_rec *c = r->connection;
apr_socket_t *sock = conn->sock;
conn_rec *backconn = conn->connection;
+#if APR_CHARSET_EBCDIC
char *buf;
+#endif
apr_bucket_brigade *header_brigade;
apr_bucket *e;
char *old_cl_val = NULL;
@@ -336,6 +338,7 @@
apr_socket_t *sockets[3] = {NULL, NULL, NULL};
int status;
proxyws_dir_conf *dconf = ap_get_module_config(r->per_dir_config,
&proxy_wstunnel_module);
+ static const char ws_hdr[] = "Upgrade: WebSocket" CRLF "Connection:
Upgrade" CRLF CRLF;
header_brigade = apr_brigade_create(p, backconn->bucket_alloc);
@@ -348,9 +351,13 @@
return rv;
}
- buf = apr_pstrcat(p, "Upgrade: WebSocket", CRLF, "Connection: Upgrade",
CRLF, CRLF, NULL);
- ap_xlate_proto_to_ascii(buf, strlen(buf));
- e = apr_bucket_pool_create(buf, strlen(buf), p, c->bucket_alloc);
+#if APR_CHARSET_EBCDIC
+ buf = apr_pmemdup(p, ws_hdr, sizeof(ws_hdr)-1);
+ ap_xlate_proto_to_ascii(buf, sizeof(ws_hdr)-1);
+ e = apr_bucket_pool_create(buf, sizeof(ws_hdr)-1, p, c->bucket_alloc);
+#else
+ e = apr_bucket_immortal_create(ws_hdr, sizeof(ws_hdr)-1, c->bucket_alloc);
+#endif
APR_BRIGADE_INSERT_TAIL(header_brigade, e);
if ((rv = ap_proxy_pass_brigade(c->bucket_alloc, r, conn, backconn,