aboutsummaryrefslogtreecommitdiff
path: root/buffer.c
diff options
context:
space:
mode:
authorJames Yonan <james@openvpn.net>2010-04-16 07:04:45 +0000
committerJames Yonan <james@openvpn.net>2010-04-16 07:04:45 +0000
commit7e1c085d76ef452373e5e80273e07471582c2ae8 (patch)
tree24015a89e1d5159beb0e7e5360d602457ee95b12 /buffer.c
parentUpdated MSVC build scripts to Visual Studio 2008: (diff)
downloadopenvpn-7e1c085d76ef452373e5e80273e07471582c2ae8.tar.xz
Management interface performance optimizations:
* Added env-filter MI command to perform filtering on env vars passed through as a part of --management-client-auth * man_write will now try to aggregate output into larger blocks (up to 1024 bytes) for more efficient i/o Version 2.1.1f git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@5557 e7ae566f-a301-0410-adde-c780ea21d3b5
Diffstat (limited to '')
-rw-r--r--buffer.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/buffer.c b/buffer.c
index 485c696..e786b9b 100644
--- a/buffer.c
+++ b/buffer.c
@@ -945,7 +945,7 @@ buffer_list_push (struct buffer_list *ol, const unsigned char *str)
}
}
-const struct buffer *
+struct buffer *
buffer_list_peek (struct buffer_list *ol)
{
if (ol->head)
@@ -954,6 +954,45 @@ buffer_list_peek (struct buffer_list *ol)
return NULL;
}
+void
+buffer_list_aggregate (struct buffer_list *bl, const size_t max)
+{
+ if (bl->head)
+ {
+ struct buffer_entry *more = bl->head;
+ size_t size = 0;
+ int count = 0;
+ for (count = 0; more && size <= max; ++count)
+ {
+ size += BLEN(&more->buf);
+ more = more->next;
+ }
+
+ if (count >= 2)
+ {
+ int i;
+ struct buffer_entry *e = bl->head, *f;
+
+ ALLOC_OBJ_CLEAR (f, struct buffer_entry);
+ f->buf.data = malloc (size);
+ check_malloc_return (f->buf.data);
+ f->buf.capacity = size;
+ for (i = 0; e && i < count; ++i)
+ {
+ struct buffer_entry *next = e->next;
+ buf_copy (&f->buf, &e->buf);
+ free_buf (&e->buf);
+ free (e);
+ e = next;
+ }
+ bl->head = f;
+ f->next = more;
+ if (!more)
+ bl->tail = f;
+ }
+ }
+}
+
static void
buffer_list_pop (struct buffer_list *ol)
{