Apache2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
h2_bucket_beam.h
Go to the documentation of this file.
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 h2_bucket_beam_h
18 #define h2_bucket_beam_h
19 
20 struct apr_thread_mutex_t;
21 struct apr_thread_cond_t;
22 
23 /*******************************************************************************
24  * apr_bucket list without bells and whistles
25  ******************************************************************************/
26 
31 typedef struct {
32  APR_RING_HEAD(h2_bucket_list, apr_bucket) list;
33 } h2_blist;
34 
35 #define H2_BLIST_INIT(b) APR_RING_INIT(&(b)->list, apr_bucket, link);
36 #define H2_BLIST_SENTINEL(b) APR_RING_SENTINEL(&(b)->list, apr_bucket, link)
37 #define H2_BLIST_EMPTY(b) APR_RING_EMPTY(&(b)->list, apr_bucket, link)
38 #define H2_BLIST_FIRST(b) APR_RING_FIRST(&(b)->list)
39 #define H2_BLIST_LAST(b) APR_RING_LAST(&(b)->list)
40 #define H2_BLIST_INSERT_HEAD(b, e) do { \
41  apr_bucket *ap__b = (e); \
42  APR_RING_INSERT_HEAD(&(b)->list, ap__b, apr_bucket, link); \
43  } while (0)
44 #define H2_BLIST_INSERT_TAIL(b, e) do { \
45  apr_bucket *ap__b = (e); \
46  APR_RING_INSERT_TAIL(&(b)->list, ap__b, apr_bucket, link); \
47  } while (0)
48 #define H2_BLIST_CONCAT(a, b) do { \
49  APR_RING_CONCAT(&(a)->list, &(b)->list, apr_bucket, link); \
50  } while (0)
51 #define H2_BLIST_PREPEND(a, b) do { \
52  APR_RING_PREPEND(&(a)->list, &(b)->list, apr_bucket, link); \
53  } while (0)
54 
55 /*******************************************************************************
56  * h2_bucket_beam
57  ******************************************************************************/
58 
129 typedef void h2_beam_mutex_leave(struct apr_thread_mutex_t *lock);
130 
131 typedef struct {
134 } h2_beam_lock;
135 
137 
139 
140 typedef void h2_beam_io_callback(void *ctx, h2_bucket_beam *beam,
141  apr_off_t bytes);
142 typedef void h2_beam_ev_callback(void *ctx, h2_bucket_beam *beam);
143 
145 typedef struct {
146  APR_RING_HEAD(h2_beam_proxy_list, h2_beam_proxy) list;
148 
149 typedef int h2_beam_can_beam_callback(void *ctx, h2_bucket_beam *beam,
150  apr_file_t *file);
151 
152 typedef enum {
156 
161 int h2_beam_no_files(void *ctx, h2_bucket_beam *beam, apr_file_t *file);
162 
164  int id;
165  const char *tag;
175 
178 
179  apr_off_t sent_bytes; /* amount of bytes send */
180  apr_off_t received_bytes; /* amount of bytes received */
181 
182  apr_size_t buckets_sent; /* # of beam buckets sent */
183  apr_size_t files_beamed; /* how many file handles have been set aside */
184 
185  unsigned int aborted : 1;
186  unsigned int closed : 1;
187  unsigned int close_sent : 1;
188  unsigned int tx_mem_limits : 1; /* only memory size counts on transfers */
189 
192 
193  apr_off_t cons_bytes_reported; /* amount of bytes reported as consumed */
196  void *cons_ctx;
197 
198  apr_off_t prod_bytes_reported; /* amount of bytes reported as produced */
200  void *prod_ctx;
201 
204 };
205 
224  apr_pool_t *pool,
225  int id, const char *tag,
227  apr_size_t buffer_size,
228  apr_interval_time_t timeout);
229 
234 
245  apr_read_type_e block);
246 
253 
263  apr_bucket_brigade *green_buckets,
264  apr_read_type_e block,
265  apr_off_t readbytes);
266 
270 int h2_beam_empty(h2_bucket_beam *beam);
271 
276 
283 void h2_beam_abort(h2_bucket_beam *beam);
284 
291 
299 
301 
313 
319  apr_interval_time_t timeout);
321 
326  apr_size_t buffer_size);
328 
342  h2_beam_ev_callback *ev_cb,
343  h2_beam_io_callback *io_cb, void *ctx);
344 
353 
365  h2_beam_io_callback *io_cb, void *ctx);
366 
378  h2_beam_can_beam_callback *cb, void *ctx);
379 
384 
389 
394 
396 
398  apr_bucket_brigade *dest,
399  const apr_bucket *src);
400 
402 
403 void h2_beam_log(h2_bucket_beam *beam, conn_rec *c, int level, const char *msg);
404 
405 #endif /* h2_bucket_beam_h */
void h2_beam_ev_callback(void *ctx, h2_bucket_beam *beam)
Definition: h2_bucket_beam.h:142
#define APR_RING_HEAD(head, elem)
Definition: apr_ring.h:91
size_t apr_size_t
Definition: apr.h:393
apr_status_t h2_beam_create(h2_bucket_beam **pbeam, apr_pool_t *pool, int id, const char *tag, h2_beam_owner_t owner, apr_size_t buffer_size, apr_interval_time_t timeout)
void h2_beam_send_from(h2_bucket_beam *beam, apr_pool_t *p)
int h2_beam_was_received(h2_bucket_beam *beam)
apr_bucket_brigade * recv_buffer
Definition: h2_bucket_beam.h:171
Definition: apr_arch_thread_mutex.h:28
Definition: apr_arch_file_io.h:107
Definition: h2_bucket_beam.h:131
Definition: h2_bucket_beam.h:154
apr_status_t h2_beam_close(h2_bucket_beam *beam)
h2_bproxy_list proxies
Definition: h2_bucket_beam.h:172
apr_bucket_brigade request_rec apr_pool_t * pool
Definition: mod_dav.h:555
unsigned int tx_mem_limits
Definition: h2_bucket_beam.h:188
apr_size_t buckets_sent
Definition: h2_bucket_beam.h:182
void * cons_ctx
Definition: h2_bucket_beam.h:196
apr_interval_time_t h2_beam_timeout_get(h2_bucket_beam *beam)
h2_blist purge_list
Definition: h2_bucket_beam.h:170
apr_bucket * h2_bucket_beamer(h2_bucket_beam *beam, apr_bucket_brigade *dest, const apr_bucket *src)
Definition: h2_bucket_beam.h:397
unsigned int close_sent
Definition: h2_bucket_beam.h:187
apr_thread_mutex_t * mutex
Definition: h2_bucket_beam.h:132
int h2_beam_is_closed(h2_bucket_beam *beam)
Definition: h2_bucket_beam.h:163
h2_beam_io_callback * cons_io_cb
Definition: h2_bucket_beam.h:195
void h2_beam_mutex_leave(struct apr_thread_mutex_t *lock)
Definition: h2_bucket_beam.h:129
apr_off_t received_bytes
Definition: h2_bucket_beam.h:180
h2_blist send_list
Definition: h2_bucket_beam.h:168
Definition: apr_buckets.h:258
apr_off_t h2_beam_get_buffered(h2_bucket_beam *beam)
apr_int64_t apr_interval_time_t
Definition: apr_time.h:55
Structure to store things which are per connection.
Definition: httpd.h:1183
thread_id owner
Definition: apr_arch_thread_cond.h:38
void h2_beam_timeout_set(h2_bucket_beam *beam, apr_interval_time_t timeout)
int h2_beam_can_beam_callback(void *ctx, h2_bucket_beam *beam, apr_file_t *file)
Definition: h2_bucket_beam.h:149
h2_beam_owner_t
Definition: h2_bucket_beam.h:152
h2_beam_mutex_leave * leave
Definition: h2_bucket_beam.h:133
apr_interval_time_t timeout
Definition: h2_bucket_beam.h:177
h2_beam_ev_callback * cons_ev_cb
Definition: h2_bucket_beam.h:194
struct h2_beam_proxy h2_beam_proxy
Definition: h2_bucket_beam.h:144
void h2_beam_abort(h2_bucket_beam *beam)
apr_bucket_brigade * bb
Definition: mod_dav.h:555
apr_size_t max_buf_size
Definition: h2_bucket_beam.h:176
Definition: apr_buckets.h:224
dav_error * src
Definition: mod_dav.h:186
void h2_register_bucket_beamer(h2_bucket_beamer *beamer)
apr_pool_t * pool
Definition: h2_bucket_beam.h:166
apr_off_t sent_bytes
Definition: h2_bucket_beam.h:179
apr_status_t h2_beam_receive(h2_bucket_beam *beam, apr_bucket_brigade *green_buckets, apr_read_type_e block, apr_off_t readbytes)
void h2_beam_buffer_size_set(h2_bucket_beam *beam, apr_size_t buffer_size)
struct apr_thread_mutex_t * lock
Definition: h2_bucket_beam.h:190
const char * tag
Definition: h2_bucket_beam.h:165
void h2_beam_on_produced(h2_bucket_beam *beam, h2_beam_io_callback *io_cb, void *ctx)
apr_pool_t * send_pool
Definition: h2_bucket_beam.h:173
int h2_beam_holds_proxies(h2_bucket_beam *beam)
apr_off_t cons_bytes_reported
Definition: h2_bucket_beam.h:193
h2_blist hold_list
Definition: h2_bucket_beam.h:169
unsigned int closed
Definition: h2_bucket_beam.h:186
apr_pool_t * p
apr_size_t files_beamed
Definition: h2_bucket_beam.h:183
void * prod_ctx
Definition: h2_bucket_beam.h:200
void h2_beam_on_file_beam(h2_bucket_beam *beam, h2_beam_can_beam_callback *cb, void *ctx)
apr_read_type_e
Definition: apr_buckets.h:57
void h2_beam_log(h2_bucket_beam *beam, conn_rec *c, int level, const char *msg)
apr_status_t h2_beam_send(h2_bucket_beam *beam, apr_bucket_brigade *bb, apr_read_type_e block)
apr_status_t h2_beam_wait_empty(h2_bucket_beam *beam, apr_read_type_e block)
unsigned int aborted
Definition: h2_bucket_beam.h:185
apr_status_t h2_beam_destroy(h2_bucket_beam *beam)
Definition: h2_bucket_beam.h:153
int h2_beam_report_consumption(h2_bucket_beam *beam)
apr_pool_t * recv_pool
Definition: h2_bucket_beam.h:174
h2_beam_io_callback * prod_io_cb
Definition: h2_bucket_beam.h:199
h2_beam_can_beam_callback * can_beam_fn
Definition: h2_bucket_beam.h:202
void * can_beam_ctx
Definition: h2_bucket_beam.h:203
apr_off_t h2_beam_get_mem_used(h2_bucket_beam *beam)
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
void h2_beam_io_callback(void *ctx, h2_bucket_beam *beam, apr_off_t bytes)
Definition: h2_bucket_beam.h:140
int apr_status_t
Definition: apr_errno.h:44
int h2_beam_empty(h2_bucket_beam *beam)
h2_beam_owner_t owner
Definition: h2_bucket_beam.h:167
apr_off_t prod_bytes_reported
Definition: h2_bucket_beam.h:198
apr_size_t h2_beam_buffer_size_get(h2_bucket_beam *beam)
Definition: apr_arch_thread_cond.h:34
apr_size_t h2_beam_get_files_beamed(h2_bucket_beam *beam)
apr_status_t h2_beam_mutex_enter(void *ctx, h2_beam_lock *pbl)
Definition: h2_bucket_beam.h:138
int id
Definition: h2_bucket_beam.h:164
APR_RING_HEAD(active_list, waiter_t) alist
int h2_beam_no_files(void *ctx, h2_bucket_beam *beam, apr_file_t *file)
struct apr_thread_cond_t * change
Definition: h2_bucket_beam.h:191
Definition: h2_bucket_beam.h:145
apr_status_t h2_beam_leave(h2_bucket_beam *beam)
Definition: h2_bucket_beam.h:31
void h2_beam_on_consumed(h2_bucket_beam *beam, h2_beam_ev_callback *ev_cb, h2_beam_io_callback *io_cb, void *ctx)
off_t apr_off_t
Definition: apr.h:395