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 /* Copyright 2015 greenbytes GmbH (https://www.greenbytes.de)
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8 
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef h2_bucket_beam_h
17 #define h2_bucket_beam_h
18 
19 struct apr_thread_mutex_t;
20 struct apr_thread_cond_t;
21 
22 /*******************************************************************************
23  * apr_bucket list without bells and whistles
24  ******************************************************************************/
25 
30 typedef struct {
31  APR_RING_HEAD(h2_bucket_list, apr_bucket) list;
32 } h2_blist;
33 
34 #define H2_BLIST_INIT(b) APR_RING_INIT(&(b)->list, apr_bucket, link);
35 #define H2_BLIST_SENTINEL(b) APR_RING_SENTINEL(&(b)->list, apr_bucket, link)
36 #define H2_BLIST_EMPTY(b) APR_RING_EMPTY(&(b)->list, apr_bucket, link)
37 #define H2_BLIST_FIRST(b) APR_RING_FIRST(&(b)->list)
38 #define H2_BLIST_LAST(b) APR_RING_LAST(&(b)->list)
39 #define H2_BLIST_INSERT_HEAD(b, e) do { \
40  apr_bucket *ap__b = (e); \
41  APR_RING_INSERT_HEAD(&(b)->list, ap__b, apr_bucket, link); \
42  } while (0)
43 #define H2_BLIST_INSERT_TAIL(b, e) do { \
44  apr_bucket *ap__b = (e); \
45  APR_RING_INSERT_TAIL(&(b)->list, ap__b, apr_bucket, link); \
46  } while (0)
47 #define H2_BLIST_CONCAT(a, b) do { \
48  APR_RING_CONCAT(&(a)->list, &(b)->list, apr_bucket, link); \
49  } while (0)
50 #define H2_BLIST_PREPEND(a, b) do { \
51  APR_RING_PREPEND(&(a)->list, &(b)->list, apr_bucket, link); \
52  } while (0)
53 
63 apr_size_t h2_util_bl_print(char *buffer, apr_size_t bmax,
64  const char *tag, const char *sep,
65  h2_blist *bl);
66 
67 /*******************************************************************************
68  * h2_bucket_beam
69  ******************************************************************************/
70 
143 typedef void h2_beam_mutex_leave(void *ctx, struct apr_thread_mutex_t *lock);
144 
145 typedef struct {
148  void *leave_ctx;
149 } h2_beam_lock;
150 
152 
154 
155 typedef void h2_beam_io_callback(void *ctx, h2_bucket_beam *beam,
156  apr_off_t bytes);
157 
159 typedef struct {
160  APR_RING_HEAD(h2_beam_proxy_list, h2_beam_proxy) list;
162 
163 typedef int h2_beam_can_beam_callback(void *ctx, h2_bucket_beam *beam,
164  apr_file_t *file);
165 
166 typedef enum {
170 
175 int h2_beam_no_files(void *ctx, h2_bucket_beam *beam, apr_file_t *file);
176 
178  int id;
179  const char *tag;
189 
192 
193  apr_off_t sent_bytes; /* amount of bytes send */
194  apr_off_t received_bytes; /* amount of bytes received */
195 
196  apr_size_t buckets_sent; /* # of beam buckets sent */
197  apr_size_t files_beamed; /* how many file handles have been set aside */
198  apr_file_t *last_beamed; /* last file beamed */
199 
200  unsigned int aborted : 1;
201  unsigned int closed : 1;
202  unsigned int close_sent : 1;
203 
204  void *m_ctx;
207 
208  apr_off_t reported_consumed_bytes; /* amount of bytes reported as consumed */
211  apr_off_t reported_produced_bytes; /* amount of bytes reported as produced */
216 };
217 
235  apr_pool_t *pool,
236  int id, const char *tag,
238  apr_size_t buffer_size);
239 
244 
255  apr_read_type_e block);
256 
266  apr_bucket_brigade *green_buckets,
267  apr_read_type_e block,
268  apr_off_t readbytes);
269 
273 int h2_beam_empty(h2_bucket_beam *beam);
274 
279 
286 void h2_beam_abort(h2_bucket_beam *beam);
287 
294 
306 
308  h2_beam_mutex_enter m_enter,
309  struct apr_thread_cond_t *cond,
310  void *m_ctx);
311 
317  apr_interval_time_t timeout);
319 
324  apr_size_t buffer_size);
326 
338  h2_beam_io_callback *cb, void *ctx);
339 
351  h2_beam_io_callback *cb, void *ctx);
352 
354  h2_beam_can_beam_callback *cb, void *ctx);
355 
360 
365 
370 
372 
374  apr_bucket_brigade *dest,
375  const apr_bucket *src);
376 
378 
379 #endif /* h2_bucket_beam_h */
NXCond_t * cond
Definition: apr_arch_thread_cond.h:25
#define APR_RING_HEAD(head, elem)
Definition: apr_ring.h:91
size_t apr_size_t
Definition: apr.h:375
void * consumed_ctx
Definition: h2_bucket_beam.h:210
void h2_beam_mutex_set(h2_bucket_beam *beam, h2_beam_mutex_enter m_enter, struct apr_thread_cond_t *cond, void *m_ctx)
struct apr_thread_cond_t * m_cond
Definition: h2_bucket_beam.h:206
int h2_beam_was_received(h2_bucket_beam *beam)
apr_bucket_brigade * recv_buffer
Definition: h2_bucket_beam.h:185
Definition: apr_arch_thread_mutex.h:28
Definition: apr_arch_file_io.h:107
Definition: h2_bucket_beam.h:145
Definition: h2_bucket_beam.h:168
apr_status_t h2_beam_close(h2_bucket_beam *beam)
h2_bproxy_list proxies
Definition: h2_bucket_beam.h:186
apr_bucket_brigade request_rec apr_pool_t * pool
Definition: mod_dav.h:556
apr_off_t reported_produced_bytes
Definition: h2_bucket_beam.h:211
apr_size_t buckets_sent
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:184
apr_bucket * h2_bucket_beamer(h2_bucket_beam *beam, apr_bucket_brigade *dest, const apr_bucket *src)
Definition: h2_bucket_beam.h:373
h2_beam_io_callback * consumed_fn
Definition: h2_bucket_beam.h:209
unsigned int close_sent
Definition: h2_bucket_beam.h:202
apr_thread_mutex_t * mutex
Definition: h2_bucket_beam.h:146
Definition: h2_bucket_beam.h:177
apr_off_t received_bytes
Definition: h2_bucket_beam.h:194
h2_blist send_list
Definition: h2_bucket_beam.h:182
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:143
thread_id owner
Definition: apr_arch_thread_cond.h:38
void h2_beam_timeout_set(h2_bucket_beam *beam, apr_interval_time_t timeout)
void h2_beam_on_produced(h2_bucket_beam *beam, h2_beam_io_callback *cb, void *ctx)
int h2_beam_can_beam_callback(void *ctx, h2_bucket_beam *beam, apr_file_t *file)
Definition: h2_bucket_beam.h:163
h2_beam_owner_t
Definition: h2_bucket_beam.h:166
h2_beam_mutex_leave * leave
Definition: h2_bucket_beam.h:147
apr_interval_time_t timeout
Definition: h2_bucket_beam.h:191
apr_size_t h2_util_bl_print(char *buffer, apr_size_t bmax, const char *tag, const char *sep, h2_blist *bl)
struct h2_beam_proxy h2_beam_proxy
Definition: h2_bucket_beam.h:158
void h2_beam_abort(h2_bucket_beam *beam)
apr_bucket_brigade * bb
Definition: mod_dav.h:556
apr_size_t max_buf_size
Definition: h2_bucket_beam.h:190
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:180
apr_off_t sent_bytes
Definition: h2_bucket_beam.h:193
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)
const char * tag
Definition: h2_bucket_beam.h:179
apr_pool_t * send_pool
Definition: h2_bucket_beam.h:187
h2_beam_io_callback * produced_fn
Definition: h2_bucket_beam.h:212
int h2_beam_holds_proxies(h2_bucket_beam *beam)
h2_blist hold_list
Definition: h2_bucket_beam.h:183
unsigned int closed
Definition: h2_bucket_beam.h:201
apr_off_t reported_consumed_bytes
Definition: h2_bucket_beam.h:208
apr_size_t files_beamed
Definition: h2_bucket_beam.h:197
apr_file_t * last_beamed
Definition: h2_bucket_beam.h:198
void h2_beam_on_file_beam(h2_bucket_beam *beam, h2_beam_can_beam_callback *cb, void *ctx)
void h2_beam_on_consumed(h2_bucket_beam *beam, h2_beam_io_callback *cb, void *ctx)
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_read_type_e
Definition: apr_buckets.h:57
void * m_ctx
Definition: h2_bucket_beam.h:204
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:200
apr_status_t h2_beam_destroy(h2_bucket_beam *beam)
Definition: h2_bucket_beam.h:167
void * produced_ctx
Definition: h2_bucket_beam.h:213
apr_pool_t * recv_pool
Definition: h2_bucket_beam.h:188
h2_beam_can_beam_callback * can_beam_fn
Definition: h2_bucket_beam.h:214
void * can_beam_ctx
Definition: h2_bucket_beam.h:215
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:155
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:181
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:153
h2_beam_mutex_enter * m_enter
Definition: h2_bucket_beam.h:205
int id
Definition: h2_bucket_beam.h:178
APR_RING_HEAD(active_list, waiter_t) alist
int h2_beam_no_files(void *ctx, h2_bucket_beam *beam, apr_file_t *file)
Definition: h2_bucket_beam.h:159
Definition: h2_bucket_beam.h:30
off_t apr_off_t
Definition: apr.h:377
void * leave_ctx
Definition: h2_bucket_beam.h:148