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(void *ctx, struct apr_thread_mutex_t *lock);
130 
131 typedef struct {
134  void *leave_ctx;
135 } h2_beam_lock;
136 
138 
140 
141 typedef void h2_beam_io_callback(void *ctx, h2_bucket_beam *beam,
142  apr_off_t bytes);
143 typedef void h2_beam_ev_callback(void *ctx, h2_bucket_beam *beam);
144 
146 typedef struct {
147  APR_RING_HEAD(h2_beam_proxy_list, h2_beam_proxy) list;
149 
150 typedef int h2_beam_can_beam_callback(void *ctx, h2_bucket_beam *beam,
151  apr_file_t *file);
152 
153 typedef enum {
157 
162 int h2_beam_no_files(void *ctx, h2_bucket_beam *beam, apr_file_t *file);
163 
165  int id;
166  const char *tag;
176 
179 
180  apr_off_t sent_bytes; /* amount of bytes send */
181  apr_off_t received_bytes; /* amount of bytes received */
182 
183  apr_size_t buckets_sent; /* # of beam buckets sent */
184  apr_size_t files_beamed; /* how many file handles have been set aside */
185 
186  unsigned int aborted : 1;
187  unsigned int closed : 1;
188  unsigned int close_sent : 1;
189  unsigned int tx_mem_limits : 1; /* only memory size counts on transfers */
190 
193 
194  apr_off_t cons_bytes_reported; /* amount of bytes reported as consumed */
197  void *cons_ctx;
198 
199  apr_off_t prod_bytes_reported; /* amount of bytes reported as produced */
201  void *prod_ctx;
202 
205 };
206 
225  apr_pool_t *pool,
226  int id, const char *tag,
228  apr_size_t buffer_size,
229  apr_interval_time_t timeout);
230 
235 
246  apr_read_type_e block);
247 
254 
264  apr_bucket_brigade *green_buckets,
265  apr_read_type_e block,
266  apr_off_t readbytes);
267 
271 int h2_beam_empty(h2_bucket_beam *beam);
272 
277 
284 void h2_beam_abort(h2_bucket_beam *beam);
285 
292 
300 
302 
314 
320  apr_interval_time_t timeout);
322 
327  apr_size_t buffer_size);
329 
343  h2_beam_ev_callback *ev_cb,
344  h2_beam_io_callback *io_cb, void *ctx);
345 
354 
366  h2_beam_io_callback *io_cb, void *ctx);
367 
379  h2_beam_can_beam_callback *cb, void *ctx);
380 
385 
390 
395 
397 
399  apr_bucket_brigade *dest,
400  const apr_bucket *src);
401 
403 
404 void h2_beam_log(h2_bucket_beam *beam, conn_rec *c, int level, const char *msg);
405 
406 #endif /* h2_bucket_beam_h */
void h2_beam_ev_callback(void *ctx, h2_bucket_beam *beam)
Definition: h2_bucket_beam.h:143
#define APR_RING_HEAD(head, elem)
Definition: apr_ring.h:91
size_t apr_size_t
Definition: apr.h:375
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:172
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:155
apr_status_t h2_beam_close(h2_bucket_beam *beam)
h2_bproxy_list proxies
Definition: h2_bucket_beam.h:173
apr_bucket_brigade request_rec apr_pool_t * pool
Definition: mod_dav.h:552
unsigned int tx_mem_limits
Definition: h2_bucket_beam.h:189
apr_size_t buckets_sent
Definition: h2_bucket_beam.h:183
void * cons_ctx
Definition: h2_bucket_beam.h:197
apr_interval_time_t h2_beam_timeout_get(h2_bucket_beam *beam)
h2_blist purge_list
Definition: h2_bucket_beam.h:171
apr_bucket * h2_bucket_beamer(h2_bucket_beam *beam, apr_bucket_brigade *dest, const apr_bucket *src)
Definition: h2_bucket_beam.h:398
unsigned int close_sent
Definition: h2_bucket_beam.h:188
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:164
h2_beam_io_callback * cons_io_cb
Definition: h2_bucket_beam.h:196
apr_off_t received_bytes
Definition: h2_bucket_beam.h:181
h2_blist send_list
Definition: h2_bucket_beam.h:169
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
void h2_beam_mutex_leave(void *ctx, struct apr_thread_mutex_t *lock)
Definition: h2_bucket_beam.h:129
Structure to store things which are per connection.
Definition: httpd.h:1116
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:150
h2_beam_owner_t
Definition: h2_bucket_beam.h:153
h2_beam_mutex_leave * leave
Definition: h2_bucket_beam.h:133
apr_interval_time_t timeout
Definition: h2_bucket_beam.h:178
h2_beam_ev_callback * cons_ev_cb
Definition: h2_bucket_beam.h:195
struct h2_beam_proxy h2_beam_proxy
Definition: h2_bucket_beam.h:145
void h2_beam_abort(h2_bucket_beam *beam)
apr_bucket_brigade * bb
Definition: mod_dav.h:552
apr_size_t max_buf_size
Definition: h2_bucket_beam.h:177
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:167
apr_off_t sent_bytes
Definition: h2_bucket_beam.h:180
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:191
const char * tag
Definition: h2_bucket_beam.h:166
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:174
int h2_beam_holds_proxies(h2_bucket_beam *beam)
apr_off_t cons_bytes_reported
Definition: h2_bucket_beam.h:194
h2_blist hold_list
Definition: h2_bucket_beam.h:170
unsigned int closed
Definition: h2_bucket_beam.h:187
apr_pool_t * p
apr_size_t files_beamed
Definition: h2_bucket_beam.h:184
void * prod_ctx
Definition: h2_bucket_beam.h:201
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:186
apr_status_t h2_beam_destroy(h2_bucket_beam *beam)
Definition: h2_bucket_beam.h:154
int h2_beam_report_consumption(h2_bucket_beam *beam)
apr_pool_t * recv_pool
Definition: h2_bucket_beam.h:175
h2_beam_io_callback * prod_io_cb
Definition: h2_bucket_beam.h:200
h2_beam_can_beam_callback * can_beam_fn
Definition: h2_bucket_beam.h:203
void * can_beam_ctx
Definition: h2_bucket_beam.h:204
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:141
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:168
apr_off_t prod_bytes_reported
Definition: h2_bucket_beam.h:199
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:139
int id
Definition: h2_bucket_beam.h:165
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:192
Definition: h2_bucket_beam.h:146
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:377
void * leave_ctx
Definition: h2_bucket_beam.h:134