"Fossies" - the Fresh Open Source Software Archive

Member "mod_http2-1.15.17/mod_http2/h2_task.h" (22 Feb 2021, 4211 Bytes) of package /linux/www/apache_httpd_modules/mod_http2-1.15.17.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "h2_task.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 1.15.16_vs_1.15.17.

    1 /* Licensed to the Apache Software Foundation (ASF) under one or more
    2  * contributor license agreements.  See the NOTICE file distributed with
    3  * this work for additional information regarding copyright ownership.
    4  * The ASF licenses this file to You under the Apache License, Version 2.0
    5  * (the "License"); you may not use this file except in compliance with
    6  * the License.  You may obtain a copy of the License at
    7  *
    8  *     http://www.apache.org/licenses/LICENSE-2.0
    9  *
   10  * Unless required by applicable law or agreed to in writing, software
   11  * distributed under the License is distributed on an "AS IS" BASIS,
   12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   13  * See the License for the specific language governing permissions and
   14  * limitations under the License.
   15  */
   16 
   17 #ifndef __mod_h2__h2_task__
   18 #define __mod_h2__h2_task__
   19 
   20 #include <http_core.h>
   21 
   22 /**
   23  * A h2_task fakes a HTTP/1.1 request from the data in a HTTP/2 stream 
   24  * (HEADER+CONT.+DATA) the module receives.
   25  *
   26  * In order to answer a HTTP/2 stream, we want all Apache httpd infrastructure
   27  * to be involved as usual, as if this stream can as a separate HTTP/1.1
   28  * request. The basic trickery to do so was derived from google's mod_spdy
   29  * source. Basically, we fake a new conn_rec object, even with its own
   30  * socket and give it to ap_process_connection().
   31  *
   32  * Since h2_task instances are executed in separate threads, we may have
   33  * different lifetimes than our h2_stream or h2_session instances. Basically,
   34  * we would like to be as standalone as possible.
   35  *
   36  * Finally, to keep certain connection level filters, such as ourselves and
   37  * especially mod_ssl ones, from messing with our data, we need a filter
   38  * of our own to disable those.
   39  */
   40 
   41 struct h2_bucket_beam;
   42 struct h2_conn;
   43 struct h2_mplx;
   44 struct h2_task;
   45 struct h2_request;
   46 struct h2_response_parser;
   47 struct h2_stream;
   48 struct h2_worker;
   49 
   50 typedef struct h2_task h2_task;
   51 
   52 struct h2_task {
   53     const char *id;
   54     int stream_id;
   55     conn_rec *c;
   56     apr_pool_t *pool;
   57     
   58     const struct h2_request *request;
   59     apr_interval_time_t timeout;
   60     int rst_error;                   /* h2 related stream abort error */
   61     
   62     struct {
   63         struct h2_bucket_beam *beam;
   64         unsigned int eos : 1;
   65         apr_bucket_brigade *bb;
   66         apr_bucket_brigade *bbchunk;
   67         apr_off_t chunked_total;
   68     } input;
   69     struct {
   70         struct h2_bucket_beam *beam;
   71         unsigned int opened : 1;
   72         unsigned int sent_response : 1;
   73         unsigned int copy_files : 1;
   74         unsigned int buffered : 1;
   75         struct h2_response_parser *rparser;
   76         apr_bucket_brigade *bb;
   77         apr_size_t max_buffer;
   78     } output;
   79     
   80     struct h2_mplx *mplx;
   81     
   82     unsigned int filters_set    : 1;
   83     unsigned int worker_started : 1; /* h2_worker started processing */
   84     unsigned int redo : 1;           /* was throttled, should be restarted later */
   85     
   86     int worker_done;                 /* h2_worker finished */
   87     int done_done;                   /* task_done has been handled */
   88     
   89     apr_time_t started_at;           /* when processing started */
   90     apr_time_t done_at;              /* when processing was done */
   91     apr_bucket *eor;
   92 };
   93 
   94 h2_task *h2_task_create(conn_rec *secondary, int stream_id,
   95                         const h2_request *req, struct h2_mplx *m, 
   96                         struct h2_bucket_beam *input, 
   97                         apr_interval_time_t timeout,
   98                         apr_size_t output_max_mem);
   99 
  100 void h2_task_destroy(h2_task *task);
  101 
  102 apr_status_t h2_task_do(h2_task *task, apr_thread_t *thread, int worker_id);
  103 
  104 void h2_task_redo(h2_task *task);
  105 int h2_task_can_redo(h2_task *task);
  106 int h2_task_has_started(h2_task *task);
  107 
  108 /**
  109  * Reset the task with the given error code, resets all input/output.
  110  */
  111 void h2_task_rst(h2_task *task, int error);
  112 
  113 void h2_task_register_hooks(void);
  114 /*
  115  * One time, post config initialization.
  116  */
  117 apr_status_t h2_task_init(apr_pool_t *pool, server_rec *s);
  118 
  119 extern APR_OPTIONAL_FN_TYPE(ap_logio_add_bytes_in) *h2_task_logio_add_bytes_in;
  120 extern APR_OPTIONAL_FN_TYPE(ap_logio_add_bytes_out) *h2_task_logio_add_bytes_out;
  121 
  122 #endif /* defined(__mod_h2__h2_task__) */