char *scheme; /* required to release the proxy connection */
} ws_baton_t;
-static apr_status_t proxy_wstunnel_transfer(request_rec *r, conn_rec *c_i, conn_rec *c_o,
- apr_bucket_brigade *bb, char *name);
+static apr_status_t proxy_wstunnel_transfer(request_rec *r,
+ conn_rec *c_i, conn_rec *c_o,
+ apr_bucket_brigade *bb,
+ const char *name, int *sent);
static void proxy_wstunnel_callback(void *b);
static int proxy_wstunnel_pump(ws_baton_t *baton, apr_time_t timeout, int try_async) {
apr_socket_t *client_socket = baton->client_soc;
apr_status_t rv;
apr_bucket_brigade *bb = baton->bb;
- int done = 0;
+ int done = 0, replied = 0;
do {
rv = apr_pollset_poll(pollset, timeout, &pollcnt, &signalled);
if (pollevent & (APR_POLLIN | APR_POLLHUP)) {
ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, APLOGNO(02446)
"sock was readable");
- done |= proxy_wstunnel_transfer(r, backconn, c, bb,
- "sock") != APR_SUCCESS;
+ done |= proxy_wstunnel_transfer(r, backconn, c, bb, "sock",
+ NULL) != APR_SUCCESS;
}
else if (pollevent & APR_POLLERR) {
ap_log_rerror(APLOG_MARK, APLOG_NOTICE, 0, r, APLOGNO(02447)
if (pollevent & (APR_POLLIN | APR_POLLHUP)) {
ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, APLOGNO(02448)
"client was readable");
- done |= proxy_wstunnel_transfer(r, c, backconn, bb,
- "client") != APR_SUCCESS;
+ done |= proxy_wstunnel_transfer(r, c, backconn, bb, "client",
+ &replied) != APR_SUCCESS;
}
else if (pollevent & APR_POLLERR) {
ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, APLOGNO(02607)
ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r,
"finished with poll() - cleaning up");
- return OK;
+ if (!replied) {
+ return HTTP_BAD_GATEWAY;
+ }
+ else {
+ return OK;
+ }
}
static void proxy_wstunnel_finish(ws_baton_t *baton) {
}
-static apr_status_t proxy_wstunnel_transfer(request_rec *r, conn_rec *c_i, conn_rec *c_o,
- apr_bucket_brigade *bb, char *name)
+static apr_status_t proxy_wstunnel_transfer(request_rec *r,
+ conn_rec *c_i, conn_rec *c_o,
+ apr_bucket_brigade *bb,
+ const char *name, int *sent)
{
apr_status_t rv;
#ifdef DEBUGGING
"read %" APR_OFF_T_FMT
" bytes from %s", len, name);
#endif
+ if (sent) {
+ *sent = 1;
+ }
rv = ap_pass_brigade(c_o->output_filters, bb);
if (rv == APR_SUCCESS) {
ap_fflush(c_o->output_filters, bb);