You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by yl...@apache.org on 2017/03/24 15:13:16 UTC
svn commit: r1788467 - in /apr/apr-util/branches/1.6.x: ./ CHANGES
buckets/apr_buckets_alloc.c buckets/apr_buckets_file.c include/apr_buckets.h
Author: ylavic
Date: Fri Mar 24 15:13:16 2017
New Revision: 1788467
URL: http://svn.apache.org/viewvc?rev=1788467&view=rev
Log:
Merge r1788335 from trunk:
apr_buckets: Add apr_bucket_file_set_buf_size() which allows to configure
the size of the buffer used to read files.
Modified:
apr/apr-util/branches/1.6.x/ (props changed)
apr/apr-util/branches/1.6.x/CHANGES
apr/apr-util/branches/1.6.x/buckets/apr_buckets_alloc.c
apr/apr-util/branches/1.6.x/buckets/apr_buckets_file.c
apr/apr-util/branches/1.6.x/include/apr_buckets.h
Propchange: apr/apr-util/branches/1.6.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Mar 24 15:13:16 2017
@@ -1,4 +1,4 @@
-/apr/apr/trunk:781403,781409,784519,784592,789965,794508,917837-917838,982408-982409,998533,1086937,1127053,1127648,1128838,1129433,1133587,1207704,1210524,1211987,1214516,1308087,1308131,1308318,1327636,1340286,1346865,1357761,1357772,1357780,1357966,1357968,1357979,1358295,1358480,1361811,1362241,1362248,1362252,1362255,1363076,1369681,1370626,1371811,1371817,1371919,1371923,1382174,1389154,1389169,1390461,1390477,1402870,1402897,1402903,1402907,1406088,1422413,1425356,1426442,1426448,1438960,1449308,1449314,1460185,1460243-1460244,1462219,1462224,1484271,1493715,1495887,1495889,1496407,1516261,1523479,1529554,1531009,1541054,1543399,1544846,1618843,1619438,1625247,1626561,1648830,1711657,1722547,1728958,1728963,1747941,1751567,1751806,1751898,1752008,1763665,1763667,1763669,1763672-1763673,1763842-1763843,1765378,1772414,1778153,1781391,1782042,1782045
+/apr/apr/trunk:781403,781409,784519,784592,789965,794508,917837-917838,982408-982409,998533,1086937,1127053,1127648,1128838,1129433,1133587,1207704,1210524,1211987,1214516,1308087,1308131,1308318,1327636,1340286,1346865,1357761,1357772,1357780,1357966,1357968,1357979,1358295,1358480,1361811,1362241,1362248,1362252,1362255,1363076,1369681,1370626,1371811,1371817,1371919,1371923,1382174,1389154,1389169,1390461,1390477,1402870,1402897,1402903,1402907,1406088,1422413,1425356,1426442,1426448,1438960,1449308,1449314,1460185,1460243-1460244,1462219,1462224,1484271,1493715,1495887,1495889,1496407,1516261,1523479,1529554,1531009,1541054,1543399,1544846,1618843,1619438,1625247,1626561,1648830,1711657,1722547,1728958,1728963,1747941,1751567,1751806,1751898,1752008,1763665,1763667,1763669,1763672-1763673,1763842-1763843,1765378,1772414,1778153,1781391,1782042,1782045,1788335
/apr/apr-util/branches/1.3.x:896410,1154885
/apr/apr-util/branches/1.4.x:1126217,1211211,1211219,1211223,1211330
/apr/apr-util/branches/1.5.x:1757430
Modified: apr/apr-util/branches/1.6.x/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.6.x/CHANGES?rev=1788467&r1=1788466&r2=1788467&view=diff
==============================================================================
--- apr/apr-util/branches/1.6.x/CHANGES [utf-8] (original)
+++ apr/apr-util/branches/1.6.x/CHANGES [utf-8] Fri Mar 24 15:13:16 2017
@@ -1,6 +1,9 @@
-*- coding: utf-8 -*-
Changes with APR-util 1.6.0
+ *) apr_buckets: Add apr_bucket_file_set_buf_size() which allows to configure
+ the size of the buffer used to read files. [Yann Ylavic]
+
*) apr_crypto: avoid excessive iteration in bcrypt hash.
[Hanno B�ck <hanno hboeck.de>]
Modified: apr/apr-util/branches/1.6.x/buckets/apr_buckets_alloc.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.6.x/buckets/apr_buckets_alloc.c?rev=1788467&r1=1788466&r2=1788467&view=diff
==============================================================================
--- apr/apr-util/branches/1.6.x/buckets/apr_buckets_alloc.c (original)
+++ apr/apr-util/branches/1.6.x/buckets/apr_buckets_alloc.c Fri Mar 24 15:13:16 2017
@@ -18,6 +18,7 @@
#include "apr_buckets.h"
#include "apr_allocator.h"
+#include "apr_version.h"
#define ALLOC_AMT (8192 - APR_MEMNODE_T_SIZE)
@@ -121,6 +122,35 @@ APU_DECLARE_NONSTD(void) apr_bucket_allo
#endif
}
+APU_DECLARE_NONSTD(apr_size_t) apr_bucket_alloc_aligned_floor(apr_size_t size)
+{
+ if (size <= SMALL_NODE_SIZE) {
+ size = SMALL_NODE_SIZE;
+ }
+ else {
+#if APR_VERSION_AT_LEAST(1,6,0)
+ if (size < APR_MEMNODE_T_SIZE) {
+ size = apr_allocator_align(0);
+ }
+ else {
+ size = apr_allocator_align(size - APR_MEMNODE_T_SIZE);
+ }
+#else
+ /* Assumes the minimum (default) allocator's boundary of 4K and
+ * minimum (immutable before APR-1.6.x) allocation size of 8K,
+ * hence possibly (yet unlikely) under-estimating the floor...
+ */
+ size = APR_ALIGN(size, 4096);
+ if (size < 8192) {
+ size = 8192;
+ }
+#endif
+ size -= APR_MEMNODE_T_SIZE;
+ }
+ size -= SIZEOF_NODE_HEADER_T;
+ return size;
+}
+
APU_DECLARE_NONSTD(void *) apr_bucket_alloc(apr_size_t size,
apr_bucket_alloc_t *list)
{
Modified: apr/apr-util/branches/1.6.x/buckets/apr_buckets_file.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.6.x/buckets/apr_buckets_file.c?rev=1788467&r1=1788466&r2=1788467&view=diff
==============================================================================
--- apr/apr-util/branches/1.6.x/buckets/apr_buckets_file.c (original)
+++ apr/apr-util/branches/1.6.x/buckets/apr_buckets_file.c Fri Mar 24 15:13:16 2017
@@ -108,10 +108,8 @@ static apr_status_t file_bucket_read(apr
}
#endif
- *len = (filelength > APR_BUCKET_BUFF_SIZE)
- ? APR_BUCKET_BUFF_SIZE
- : filelength;
*str = NULL; /* in case we die prematurely */
+ *len = (filelength > a->read_size) ? a->read_size : filelength;
buf = apr_bucket_alloc(*len, e->list);
/* Handle offset ... */
@@ -165,6 +163,7 @@ APU_DECLARE(apr_bucket *) apr_bucket_fil
#if APR_HAS_MMAP
f->can_mmap = 1;
#endif
+ f->read_size = APR_BUCKET_BUFF_SIZE;
b = apr_bucket_shared_make(b, f, offset, len);
b->type = &apr_bucket_type_file;
@@ -197,6 +196,21 @@ APU_DECLARE(apr_status_t) apr_bucket_fil
#endif /* APR_HAS_MMAP */
}
+APU_DECLARE(apr_status_t) apr_bucket_file_set_buf_size(apr_bucket *e,
+ apr_size_t size)
+{
+ apr_bucket_file *a = e->data;
+
+ if (size <= APR_BUCKET_BUFF_SIZE) {
+ a->read_size = APR_BUCKET_BUFF_SIZE;
+ }
+ else {
+ apr_size_t floor = apr_bucket_alloc_aligned_floor(size);
+ a->read_size = (size < floor) ? size : floor;
+ }
+
+ return APR_SUCCESS;
+}
static apr_status_t file_bucket_setaside(apr_bucket *data, apr_pool_t *reqpool)
{
Modified: apr/apr-util/branches/1.6.x/include/apr_buckets.h
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.6.x/include/apr_buckets.h?rev=1788467&r1=1788466&r2=1788467&view=diff
==============================================================================
--- apr/apr-util/branches/1.6.x/include/apr_buckets.h (original)
+++ apr/apr-util/branches/1.6.x/include/apr_buckets.h Fri Mar 24 15:13:16 2017
@@ -622,6 +622,8 @@ struct apr_bucket_file {
* a caller tries to read from it */
int can_mmap;
#endif /* APR_HAS_MMAP */
+ /** File read block size */
+ apr_size_t read_size;
};
/** @see apr_bucket_structs */
@@ -962,6 +964,15 @@ APU_DECLARE_NONSTD(apr_bucket_alloc_t *)
APU_DECLARE_NONSTD(void) apr_bucket_alloc_destroy(apr_bucket_alloc_t *list);
/**
+ * Get the aligned size corresponding to the requested size, but minus the
+ * allocator(s) overhead such that the allocation would remain in the
+ * same boundary.
+ * @param size The requested size.
+ * @return The corresponding aligned/floored size.
+ */
+APU_DECLARE_NONSTD(apr_size_t) apr_bucket_alloc_aligned_floor(apr_size_t size);
+
+/**
* Allocate memory for use by the buckets.
* @param size The amount to allocate.
* @param list The allocator from which to allocate the memory.
@@ -1563,6 +1574,19 @@ APU_DECLARE(apr_bucket *) apr_bucket_fil
APU_DECLARE(apr_status_t) apr_bucket_file_enable_mmap(apr_bucket *b,
int enabled);
+/**
+ * Set the size of the read buffer allocated by a FILE bucket (default
+ * is @a APR_BUCKET_BUFF_SIZE)
+ * memory-mapping is disabled only)
+ * @param b The bucket
+ * @param size Size of the allocated buffers
+ * @return APR_SUCCESS normally, or an error code if the operation fails
+ * @remark Relevant/used only when memory-mapping is disabled (@see
+ * apr_bucket_file_enable_mmap)
+ */
+APU_DECLARE(apr_status_t) apr_bucket_file_set_buf_size(apr_bucket *e,
+ apr_size_t size);
+
/** @} */
#ifdef __cplusplus
}
Re: svn commit: r1788467 - in /apr/apr-util/branches/1.6.x: ./
CHANGES buckets/apr_buckets_alloc.c buckets/apr_buckets_file.c include/apr_buckets.h
Posted by Yann Ylavic <yl...@gmail.com>.
On Fri, Mar 24, 2017 at 4:13 PM, <yl...@apache.org> wrote:
> Author: ylavic
> Date: Fri Mar 24 15:13:16 2017
> New Revision: 1788467
>
> URL: http://svn.apache.org/viewvc?rev=1788467&view=rev
> Log:
> Merge r1788335 from trunk:
>
> apr_buckets: Add apr_bucket_file_set_buf_size() which allows to configure
> the size of the buffer used to read files.
>
> Modified:
> apr/apr-util/branches/1.6.x/ (props changed)
> apr/apr-util/branches/1.6.x/CHANGES
> apr/apr-util/branches/1.6.x/buckets/apr_buckets_alloc.c
[]
> ==============================================================================
> --- apr/apr-util/branches/1.6.x/buckets/apr_buckets_alloc.c (original)
> +++ apr/apr-util/branches/1.6.x/buckets/apr_buckets_alloc.c Fri Mar 24 15:13:16 2017
> @@ -18,6 +18,7 @@
>
> #include "apr_buckets.h"
> #include "apr_allocator.h"
> +#include "apr_version.h"
>
> #define ALLOC_AMT (8192 - APR_MEMNODE_T_SIZE)
>
> @@ -121,6 +122,35 @@ APU_DECLARE_NONSTD(void) apr_bucket_allo
> #endif
> }
>
> +APU_DECLARE_NONSTD(apr_size_t) apr_bucket_alloc_aligned_floor(apr_size_t size)
> +{
> + if (size <= SMALL_NODE_SIZE) {
> + size = SMALL_NODE_SIZE;
> + }
> + else {
> +#if APR_VERSION_AT_LEAST(1,6,0)
> + if (size < APR_MEMNODE_T_SIZE) {
> + size = apr_allocator_align(0);
> + }
> + else {
> + size = apr_allocator_align(size - APR_MEMNODE_T_SIZE);
> + }
> +#else
> + /* Assumes the minimum (default) allocator's boundary of 4K and
> + * minimum (immutable before APR-1.6.x) allocation size of 8K,
> + * hence possibly (yet unlikely) under-estimating the floor...
> + */
> + size = APR_ALIGN(size, 4096);
> + if (size < 8192) {
> + size = 8192;
> + }
> +#endif
> + size -= APR_MEMNODE_T_SIZE;
> + }
> + size -= SIZEOF_NODE_HEADER_T;
> + return size;
> +}
I don't see any other decisional on APR_VERSION in apr-util code, does
it mean that an apr-util major.minor is bound to the same apr's
major.minor (e.g. apr-util-1.6.x is necessarily
distributed/to-be-linked with apr-1.6.x)?
If this is the case the above code could assume that
apr_allocator_align() exists and avoid the current (unwise?)
assumption otherwise...
Thanks for some enlightenments.
Regards,
Yann.