|
Packit |
90a5c9 |
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
Packit |
90a5c9 |
* contributor license agreements. See the NOTICE file distributed with
|
|
Packit |
90a5c9 |
* this work for additional information regarding copyright ownership.
|
|
Packit |
90a5c9 |
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
Packit |
90a5c9 |
* (the "License"); you may not use this file except in compliance with
|
|
Packit |
90a5c9 |
* the License. You may obtain a copy of the License at
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* Unless required by applicable law or agreed to in writing, software
|
|
Packit |
90a5c9 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
Packit |
90a5c9 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
Packit |
90a5c9 |
* See the License for the specific language governing permissions and
|
|
Packit |
90a5c9 |
* limitations under the License.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
Packit |
90a5c9 |
* contributor license agreements. See the NOTICE file distributed with
|
|
Packit |
90a5c9 |
* this work for additional information regarding copyright ownership.
|
|
Packit |
90a5c9 |
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
Packit |
90a5c9 |
* (the "License"); you may not use this file except in compliance with
|
|
Packit |
90a5c9 |
* the License. You may obtain a copy of the License at
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* Unless required by applicable law or agreed to in writing, software
|
|
Packit |
90a5c9 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
Packit |
90a5c9 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
Packit |
90a5c9 |
* See the License for the specific language governing permissions and
|
|
Packit |
90a5c9 |
* limitations under the License.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#include <assert.h>
|
|
Packit |
90a5c9 |
#include <stddef.h>
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#include <httpd.h>
|
|
Packit |
90a5c9 |
#include <http_core.h>
|
|
Packit |
90a5c9 |
#include <http_connection.h>
|
|
Packit |
90a5c9 |
#include <http_log.h>
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#include "h2_private.h"
|
|
Packit |
90a5c9 |
#include "h2.h"
|
|
Packit |
90a5c9 |
#include "h2_mplx.h"
|
|
Packit |
90a5c9 |
#include "h2_stream.h"
|
|
Packit |
90a5c9 |
#include "h2_bucket_eos.h"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
typedef struct {
|
|
Packit |
90a5c9 |
apr_bucket_refcount refcount;
|
|
Packit |
90a5c9 |
h2_stream *stream;
|
|
Packit |
90a5c9 |
} h2_bucket_eos;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static apr_status_t bucket_cleanup(void *data)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
h2_stream **pstream = data;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (*pstream) {
|
|
Packit |
90a5c9 |
/* If bucket_destroy is called after us, this prevents
|
|
Packit |
90a5c9 |
* bucket_destroy from trying to destroy the stream again. */
|
|
Packit |
90a5c9 |
*pstream = NULL;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
return APR_SUCCESS;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static apr_status_t bucket_read(apr_bucket *b, const char **str,
|
|
Packit |
90a5c9 |
apr_size_t *len, apr_read_type_e block)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
(void)b;
|
|
Packit |
90a5c9 |
(void)block;
|
|
Packit |
90a5c9 |
*str = NULL;
|
|
Packit |
90a5c9 |
*len = 0;
|
|
Packit |
90a5c9 |
return APR_SUCCESS;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
apr_bucket *h2_bucket_eos_make(apr_bucket *b, h2_stream *stream)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
h2_bucket_eos *h;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
h = apr_bucket_alloc(sizeof(*h), b->list);
|
|
Packit |
90a5c9 |
h->stream = stream;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
b = apr_bucket_shared_make(b, h, 0, 0);
|
|
Packit |
90a5c9 |
b->type = &h2_bucket_type_eos;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
return b;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
apr_bucket *h2_bucket_eos_create(apr_bucket_alloc_t *list,
|
|
Packit |
90a5c9 |
h2_stream *stream)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
apr_bucket *b = apr_bucket_alloc(sizeof(*b), list);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
APR_BUCKET_INIT(b);
|
|
Packit |
90a5c9 |
b->free = apr_bucket_free;
|
|
Packit |
90a5c9 |
b->list = list;
|
|
Packit |
90a5c9 |
b = h2_bucket_eos_make(b, stream);
|
|
Packit |
90a5c9 |
if (stream) {
|
|
Packit |
90a5c9 |
h2_bucket_eos *h = b->data;
|
|
Packit |
90a5c9 |
apr_pool_pre_cleanup_register(stream->pool, &h->stream, bucket_cleanup);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
return b;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static void bucket_destroy(void *data)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
h2_bucket_eos *h = data;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (apr_bucket_shared_destroy(h)) {
|
|
Packit |
90a5c9 |
h2_stream *stream = h->stream;
|
|
Packit |
90a5c9 |
if (stream && stream->pool) {
|
|
Packit |
90a5c9 |
apr_pool_cleanup_kill(stream->pool, &h->stream, bucket_cleanup);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
apr_bucket_free(h);
|
|
Packit |
90a5c9 |
if (stream) {
|
|
Packit |
90a5c9 |
h2_stream_dispatch(stream, H2_SEV_EOS_SENT);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
const apr_bucket_type_t h2_bucket_type_eos = {
|
|
Packit |
90a5c9 |
"H2EOS", 5, APR_BUCKET_METADATA,
|
|
Packit |
90a5c9 |
bucket_destroy,
|
|
Packit |
90a5c9 |
bucket_read,
|
|
Packit |
90a5c9 |
apr_bucket_setaside_noop,
|
|
Packit |
90a5c9 |
apr_bucket_split_notimpl,
|
|
Packit |
90a5c9 |
apr_bucket_shared_copy
|
|
Packit |
90a5c9 |
};
|
|
Packit |
90a5c9 |
|