apr_buckets_file.c (302408) | apr_buckets_file.c (362181) |
---|---|
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 --- 94 unchanged lines hidden (view full) --- 103 rv = apr_file_open(&f, fname, (flags & ~APR_FOPEN_XTHREAD), 0, a->readpool); 104 if (rv != APR_SUCCESS) 105 return rv; 106 107 a->fd = f; 108 } 109#endif 110 | 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 --- 94 unchanged lines hidden (view full) --- 103 rv = apr_file_open(&f, fname, (flags & ~APR_FOPEN_XTHREAD), 0, a->readpool); 104 if (rv != APR_SUCCESS) 105 return rv; 106 107 a->fd = f; 108 } 109#endif 110 |
111 *len = (filelength > APR_BUCKET_BUFF_SIZE) 112 ? APR_BUCKET_BUFF_SIZE 113 : filelength; | |
114 *str = NULL; /* in case we die prematurely */ | 111 *str = NULL; /* in case we die prematurely */ |
112 *len = (filelength > a->read_size) ? a->read_size : filelength; |
|
115 buf = apr_bucket_alloc(*len, e->list); 116 117 /* Handle offset ... */ 118 rv = apr_file_seek(f, APR_SET, &fileoffset); 119 if (rv != APR_SUCCESS) { 120 apr_bucket_free(buf); 121 return rv; 122 } --- 37 unchanged lines hidden (view full) --- 160 apr_bucket_file *f; 161 162 f = apr_bucket_alloc(sizeof(*f), b->list); 163 f->fd = fd; 164 f->readpool = p; 165#if APR_HAS_MMAP 166 f->can_mmap = 1; 167#endif | 113 buf = apr_bucket_alloc(*len, e->list); 114 115 /* Handle offset ... */ 116 rv = apr_file_seek(f, APR_SET, &fileoffset); 117 if (rv != APR_SUCCESS) { 118 apr_bucket_free(buf); 119 return rv; 120 } --- 37 unchanged lines hidden (view full) --- 158 apr_bucket_file *f; 159 160 f = apr_bucket_alloc(sizeof(*f), b->list); 161 f->fd = fd; 162 f->readpool = p; 163#if APR_HAS_MMAP 164 f->can_mmap = 1; 165#endif |
166 f->read_size = APR_BUCKET_BUFF_SIZE; |
|
168 169 b = apr_bucket_shared_make(b, f, offset, len); 170 b->type = &apr_bucket_type_file; 171 172 return b; 173} 174 175APU_DECLARE(apr_bucket *) apr_bucket_file_create(apr_file_t *fd, --- 16 unchanged lines hidden (view full) --- 192 apr_bucket_file *a = e->data; 193 a->can_mmap = enabled; 194 return APR_SUCCESS; 195#else 196 return APR_ENOTIMPL; 197#endif /* APR_HAS_MMAP */ 198} 199 | 167 168 b = apr_bucket_shared_make(b, f, offset, len); 169 b->type = &apr_bucket_type_file; 170 171 return b; 172} 173 174APU_DECLARE(apr_bucket *) apr_bucket_file_create(apr_file_t *fd, --- 16 unchanged lines hidden (view full) --- 191 apr_bucket_file *a = e->data; 192 a->can_mmap = enabled; 193 return APR_SUCCESS; 194#else 195 return APR_ENOTIMPL; 196#endif /* APR_HAS_MMAP */ 197} 198 |
199APU_DECLARE(apr_status_t) apr_bucket_file_set_buf_size(apr_bucket *e, 200 apr_size_t size) 201{ 202 apr_bucket_file *a = e->data; |
|
200 | 203 |
204 if (size <= APR_BUCKET_BUFF_SIZE) { 205 a->read_size = APR_BUCKET_BUFF_SIZE; 206 } 207 else { 208 apr_size_t floor = apr_bucket_alloc_aligned_floor(e->list, size); 209 a->read_size = (size < floor) ? size : floor; 210 } 211 212 return APR_SUCCESS; 213} 214 |
|
201static apr_status_t file_bucket_setaside(apr_bucket *data, apr_pool_t *reqpool) 202{ 203 apr_bucket_file *a = data->data; 204 apr_file_t *fd = NULL; 205 apr_file_t *f = a->fd; 206 apr_pool_t *curpool = apr_file_pool_get(f); 207 208 if (apr_pool_is_ancestor(curpool, reqpool)) { --- 20 unchanged lines hidden --- | 215static apr_status_t file_bucket_setaside(apr_bucket *data, apr_pool_t *reqpool) 216{ 217 apr_bucket_file *a = data->data; 218 apr_file_t *fd = NULL; 219 apr_file_t *f = a->fd; 220 apr_pool_t *curpool = apr_file_pool_get(f); 221 222 if (apr_pool_is_ancestor(curpool, reqpool)) { --- 20 unchanged lines hidden --- |