On 07/24/2015 03:50 PM, Stefan Eissing wrote:
>
>> Am 24.07.2015 um 15:40 schrieb Ruediger Pluem <[email protected]>:
>>
>>
>>
>> On 07/24/2015 02:09 PM, [email protected] wrote:
>>> Author: icing
>>> Date: Fri Jul 24 12:09:44 2015
>>> New Revision: 1692486
>>> +static int core_upgrade_handler(request_rec *r)
>>> +{
>>> + conn_rec *c = r->connection;
>>> + const char *upgrade = apr_table_get(r->headers_in, "Upgrade");
>>> +
>>> + if (upgrade && *upgrade) {
>>> + const char *conn = apr_table_get(r->headers_in, "Connection");
>>> + if (ap_find_token(r->pool, conn, "upgrade")) {
>>> + apr_array_header_t *offers = NULL;
>>> + const char *err;
>>> +
>>> + err = ap_parse_token_list_strict(r->pool, upgrade, &offers, 0);
>>> + if (err) {
>>> + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(02910)
>>> + "parsing Upgrade header: %s", err);
>>> + return DECLINED;
>>> + }
>>> +
>>> + if (offers && offers->nelts > 0) {
>>> + const char *protocol = ap_select_protocol(c, r, r->server,
>>> + offers);
>>> + if (strcmp(protocol, ap_run_protocol_get(c))) {
>>> + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
>>> APLOGNO(02909)
>>> + "Upgrade selects '%s'", protocol);
>>> + /* Let the client know what we are upgrading to. */
>>> + apr_table_clear(r->headers_out);
>>> + apr_table_setn(r->headers_out, "Upgrade", protocol);
>>> + apr_table_setn(r->headers_out, "Connection",
>>> "Upgrade");
>>> +
>>> + r->status = HTTP_SWITCHING_PROTOCOLS;
>>> + r->status_line = ap_get_status_line(r->status);
>>> + ap_send_interim_response(r, 1);
>>> +
>>> + ap_switch_protocol(c, r, r->server, protocol);
>>> +
>>> + /* make sure httpd closes the connection after this */
>>> + c->keepalive = AP_CONN_CLOSE;
>>> + ap_lingering_close(c);
>>> +
>>> + if (c->sbh) {
>>> + ap_update_child_status_from_conn(c->sbh,
>>> + SERVER_CLOSING,
>>> c);
>>> + }
>>
>> The c->keepalive = AP_CONN_CLOSE looks fine to me, but why should we do the
>> other stuff in a handler.
>> IMHO that should be done by the existing code.
>
> Not sure I understand. You mean the interim response or the whole handler?
No I mean the
ap_lingering_close(c);
and the scoreboard update.
Regards
RĂ¼diger