View | Details | Raw Unified | Return to bug 56299
Collapse All | Expand All

(-)modules/proxy/mod_proxy_wstunnel.c (-20 / +17 lines)
Lines 103-112 Link Here
103
        rv = ap_get_brigade(c_i->input_filters, bb, AP_MODE_READBYTES,
103
        rv = ap_get_brigade(c_i->input_filters, bb, AP_MODE_READBYTES,
104
                            APR_NONBLOCK_READ, AP_IOBUFSIZE);
104
                            APR_NONBLOCK_READ, AP_IOBUFSIZE);
105
        if (rv == APR_SUCCESS) {
105
        if (rv == APR_SUCCESS) {
106
            if (c_o->aborted)
106
            if (c_o->aborted) {
107
                return APR_EPIPE;
107
                return APR_EPIPE;
108
            if (APR_BRIGADE_EMPTY(bb))
108
            }
109
            if (APR_BRIGADE_EMPTY(bb)) {
109
                break;
110
                break;
111
            }
110
#ifdef DEBUGGING
112
#ifdef DEBUGGING
111
            len = -1;
113
            len = -1;
112
            apr_brigade_length(bb, 0, &len);
114
            apr_brigade_length(bb, 0, &len);
Lines 178-184 Link Here
178
    conn_rec *c = r->connection;
180
    conn_rec *c = r->connection;
179
    apr_socket_t *sock = conn->sock;
181
    apr_socket_t *sock = conn->sock;
180
    conn_rec *backconn = conn->connection;
182
    conn_rec *backconn = conn->connection;
181
    int client_error = 0;
182
    char *buf;
183
    char *buf;
183
    apr_bucket_brigade *header_brigade;
184
    apr_bucket_brigade *header_brigade;
184
    apr_bucket *e;
185
    apr_bucket *e;
Lines 224-230 Link Here
224
225
225
    pollfd.p = p;
226
    pollfd.p = p;
226
    pollfd.desc_type = APR_POLL_SOCKET;
227
    pollfd.desc_type = APR_POLL_SOCKET;
227
    pollfd.reqevents = APR_POLLIN;
228
    pollfd.reqevents = APR_POLLIN | APR_POLLHUP;
228
    pollfd.desc.s = sock;
229
    pollfd.desc.s = sock;
229
    pollfd.client_data = NULL;
230
    pollfd.client_data = NULL;
230
    apr_pollset_add(pollset, &pollfd);
231
    apr_pollset_add(pollset, &pollfd);
Lines 237-242 Link Here
237
    r->proto_output_filters = c->output_filters;
238
    r->proto_output_filters = c->output_filters;
238
    r->input_filters = c->input_filters;
239
    r->input_filters = c->input_filters;
239
    r->proto_input_filters = c->input_filters;
240
    r->proto_input_filters = c->input_filters;
241
    /* This handler should take care of the entire connection; make it so that
242
     * nothing else is attempted on the connection after returning. */
243
    c->keepalive = AP_CONN_CLOSE;
240
244
241
    remove_reqtimeout(r->input_filters);
245
    remove_reqtimeout(r->input_filters);
242
246
Lines 257-294 Link Here
257
261
258
            if (cur->desc.s == sock) {
262
            if (cur->desc.s == sock) {
259
                pollevent = cur->rtnevents;
263
                pollevent = cur->rtnevents;
260
                if (pollevent & APR_POLLIN) {
264
                if (pollevent & (APR_POLLIN | APR_POLLHUP)) {
261
                    ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, APLOGNO(02446)
265
                    ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, APLOGNO(02446)
262
                                  "sock was readable");
266
                                  "sock was readable");
263
                    rv = proxy_wstunnel_transfer(r, backconn, c, bb, "sock");
267
                    rv = proxy_wstunnel_transfer(r, backconn, c, bb, "sock");
264
                    }
265
                else if ((pollevent & APR_POLLERR)
266
                         || (pollevent & APR_POLLHUP)) {
267
                         rv = APR_EPIPE;
268
                         ap_log_rerror(APLOG_MARK, APLOG_NOTICE, 0, r, APLOGNO(02447)
269
                                       "err/hup on backconn");
270
                }
268
                }
269
                else if (pollevent & APR_POLLERR) {
270
                     rv = APR_EPIPE;
271
                     ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, APLOGNO(02447)
272
                                   "error on reading from server conn");
273
                }
271
                else { 
274
                else { 
272
                    rv = APR_EGENERAL;
275
                    rv = APR_EGENERAL;
273
                    ap_log_rerror(APLOG_MARK, APLOG_NOTICE, 0, r, APLOGNO(02605)
276
                    ap_log_rerror(APLOG_MARK, APLOG_NOTICE, 0, r, APLOGNO(02605)
274
                            "unknown event on backconn %d", pollevent);
277
                            "unknown event on backconn %d", pollevent);
275
                }
278
                }
276
                if (rv != APR_SUCCESS)
277
                    client_error = 1;
278
            }
279
            }
279
            else if (cur->desc.s == client_socket) {
280
            else if (cur->desc.s == client_socket) {
280
                pollevent = cur->rtnevents;
281
                pollevent = cur->rtnevents;
281
                if (pollevent & APR_POLLIN) {
282
                if (pollevent & (APR_POLLIN | APR_POLLHUP)) {
282
                    ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, APLOGNO(02448)
283
                    ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, APLOGNO(02448)
283
                                  "client was readable");
284
                                  "client was readable");
284
                    rv = proxy_wstunnel_transfer(r, c, backconn, bb, "client");
285
                    rv = proxy_wstunnel_transfer(r, c, backconn, bb, "client");
285
                }
286
                }
286
                else if ((pollevent & APR_POLLERR)
287
                else if (pollevent & APR_POLLERR) {
287
                        || (pollevent & APR_POLLHUP)) {
288
                    rv = APR_EPIPE;
288
                    rv = APR_EPIPE;
289
                    c->aborted = 1;
289
                    c->aborted = 1;
290
                    ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, APLOGNO(02607)
290
                    ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, APLOGNO(02607)
291
                            "err/hup on client conn");
291
                            "error on reading from client conn");
292
                }
292
                }
293
                else { 
293
                else { 
294
                    rv = APR_EGENERAL;
294
                    rv = APR_EGENERAL;
Lines 311-319 Link Here
311
    ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r,
311
    ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r,
312
                  "finished with poll() - cleaning up");
312
                  "finished with poll() - cleaning up");
313
313
314
    if (client_error) {
315
        return HTTP_INTERNAL_SERVER_ERROR;
316
    }
317
    return OK;
314
    return OK;
318
}
315
}
319
316

Return to bug 56299