1 /* ====================================================================
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
18 * ====================================================================
21 #include <apr_pools.h>
24 #include "serf_bucket_util.h"
28 serf_bucket_t *stream;
32 serf_bucket_t *serf_bucket_barrier_create(
33 serf_bucket_t *stream,
34 serf_bucket_alloc_t *allocator)
36 barrier_context_t *ctx;
38 ctx = serf_bucket_mem_alloc(allocator, sizeof(*ctx));
41 return serf_bucket_create(&serf_bucket_type_barrier, allocator, ctx);
44 static apr_status_t serf_barrier_read(serf_bucket_t *bucket,
46 const char **data, apr_size_t *len)
48 barrier_context_t *ctx = bucket->data;
50 return serf_bucket_read(ctx->stream, requested, data, len);
53 static apr_status_t serf_barrier_read_iovec(serf_bucket_t *bucket,
55 int vecs_size, struct iovec *vecs,
58 barrier_context_t *ctx = bucket->data;
60 return serf_bucket_read_iovec(ctx->stream, requested, vecs_size, vecs,
64 static apr_status_t serf_barrier_readline(serf_bucket_t *bucket,
65 int acceptable, int *found,
66 const char **data, apr_size_t *len)
68 barrier_context_t *ctx = bucket->data;
70 return serf_bucket_readline(ctx->stream, acceptable, found, data, len);
73 static apr_status_t serf_barrier_peek(serf_bucket_t *bucket,
77 barrier_context_t *ctx = bucket->data;
79 return serf_bucket_peek(ctx->stream, data, len);
82 static void serf_barrier_destroy(serf_bucket_t *bucket)
84 /* The intent of this bucket is not to let our wrapped buckets be
87 /* The option is for us to go ahead and 'eat' this bucket now,
88 * or just ignore the deletion entirely.
90 serf_default_destroy_and_data(bucket);
93 const serf_bucket_type_t serf_bucket_type_barrier = {
96 serf_barrier_readline,
97 serf_barrier_read_iovec,
98 serf_default_read_for_sendfile,
99 serf_default_read_bucket,
101 serf_barrier_destroy,