|
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 "httpd.h"
|
|
Packit |
90a5c9 |
#include "http_request.h"
|
|
Packit |
90a5c9 |
#include "http_protocol.h"
|
|
Packit |
90a5c9 |
#include "scoreboard.h"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static apr_status_t eor_bucket_cleanup(void *data)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
apr_bucket *b = (apr_bucket *)data;
|
|
Packit |
90a5c9 |
request_rec *r = (request_rec *)b->data;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (r != NULL) {
|
|
Packit |
90a5c9 |
/*
|
|
Packit |
90a5c9 |
* If eor_bucket_destroy is called after us, this prevents
|
|
Packit |
90a5c9 |
* eor_bucket_destroy from trying to destroy the pool again.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
b->data = NULL;
|
|
Packit |
90a5c9 |
/* Update child status and log the transaction */
|
|
Packit |
90a5c9 |
ap_update_child_status(r->connection->sbh, SERVER_BUSY_LOG, r);
|
|
Packit |
90a5c9 |
ap_run_log_transaction(r);
|
|
Packit |
90a5c9 |
if (ap_extended_status) {
|
|
Packit |
90a5c9 |
ap_increment_counts(r->connection->sbh, r);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
return APR_SUCCESS;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static apr_status_t eor_bucket_read(apr_bucket *b, const char **str,
|
|
Packit |
90a5c9 |
apr_size_t *len, apr_read_type_e block)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
*str = NULL;
|
|
Packit |
90a5c9 |
*len = 0;
|
|
Packit |
90a5c9 |
return APR_SUCCESS;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
AP_DECLARE(apr_bucket *) ap_bucket_eor_make(apr_bucket *b, request_rec *r)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
b->length = 0;
|
|
Packit |
90a5c9 |
b->start = 0;
|
|
Packit |
90a5c9 |
b->data = r;
|
|
Packit |
90a5c9 |
b->type = &ap_bucket_type_eor;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
return b;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
AP_DECLARE(apr_bucket *) ap_bucket_eor_create(apr_bucket_alloc_t *list,
|
|
Packit |
90a5c9 |
request_rec *r)
|
|
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 |
if (r) {
|
|
Packit |
90a5c9 |
/*
|
|
Packit |
90a5c9 |
* Register a cleanup for the request pool as the eor bucket could
|
|
Packit |
90a5c9 |
* have been allocated from a different pool then the request pool
|
|
Packit |
90a5c9 |
* e.g. the parent pool of the request pool. In this case
|
|
Packit |
90a5c9 |
* eor_bucket_destroy might be called at a point of time when the
|
|
Packit |
90a5c9 |
* request pool had been already destroyed.
|
|
Packit |
90a5c9 |
* We need to use a pre-cleanup here because a module may create a
|
|
Packit |
90a5c9 |
* sub-pool which is still needed during the log_transaction hook.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
apr_pool_pre_cleanup_register(r->pool, (void *)b, eor_bucket_cleanup);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
return ap_bucket_eor_make(b, r);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static void eor_bucket_destroy(void *data)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
request_rec *r = (request_rec *)data;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (r) {
|
|
Packit |
90a5c9 |
/* eor_bucket_cleanup will be called when the pool gets destroyed */
|
|
Packit |
90a5c9 |
apr_pool_destroy(r->pool);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
AP_DECLARE_DATA const apr_bucket_type_t ap_bucket_type_eor = {
|
|
Packit |
90a5c9 |
"EOR", 5, APR_BUCKET_METADATA,
|
|
Packit |
90a5c9 |
eor_bucket_destroy,
|
|
Packit |
90a5c9 |
eor_bucket_read,
|
|
Packit |
90a5c9 |
apr_bucket_setaside_noop,
|
|
Packit |
90a5c9 |
apr_bucket_split_notimpl,
|
|
Packit |
90a5c9 |
apr_bucket_simple_copy
|
|
Packit |
90a5c9 |
};
|
|
Packit |
90a5c9 |
|