[balsa] Reduce the compressed IMAP stream flushing frequency.
- From: Pawel Salek <pawels src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [balsa] Reduce the compressed IMAP stream flushing frequency.
- Date: Fri, 5 Feb 2010 17:32:30 +0000 (UTC)
commit 3891da5ff013e3afa4ae52decd63b121b18401b6
Author: Pawel Salek <pawsa damage localdomain>
Date: Fri Feb 5 18:32:14 2010 +0100
Reduce the compressed IMAP stream flushing frequency.
ChangeLog | 6 ++++++
libbalsa/imap/imap_compress.c | 4 ++--
libbalsa/imap/siobuf.c | 36 +++++++++++++++++++++++++++++++-----
3 files changed, 39 insertions(+), 7 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 6bc3f0b..3335e55 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2010-02-05 Pawel Salek
+
+ * libbalsa/imap/imap_compress.c: reduce the compressed stream
+ flushing frequency.
+ * libbalsa/imap/siobuf.c: matching change on the buffering side.
+
2010-01-27 Pawel Salek
* configure.in, NEWS: release 2.4.6.
diff --git a/libbalsa/imap/imap_compress.c b/libbalsa/imap/imap_compress.c
index 54340be..50638a7 100644
--- a/libbalsa/imap/imap_compress.c
+++ b/libbalsa/imap/imap_compress.c
@@ -26,7 +26,7 @@
#include "imap_private.h"
/** Arbitrary. Current choice is as good as any other. */
-static const unsigned IMAP_COMPRESS_BUFFER_SIZE = 4096;
+static const unsigned IMAP_COMPRESS_BUFFER_SIZE = 8192;
static int
imap_compress_cb(char **dstbuf, int *dstlen,
@@ -46,7 +46,7 @@ imap_compress_cb(char **dstbuf, int *dstlen,
icb->out_stream.next_out = (Byte*)*dstbuf;
icb->out_stream.avail_out = IMAP_COMPRESS_BUFFER_SIZE;
- err = deflate(&icb->out_stream, Z_SYNC_FLUSH);
+ err = deflate(&icb->out_stream, srclen ? Z_NO_FLUSH : Z_SYNC_FLUSH);
if ( !(err == Z_OK || err == Z_STREAM_END || err == Z_BUF_ERROR) ) {
fprintf(stderr, "deflate error1 %d\n", err);
*dstlen = -1;
diff --git a/libbalsa/imap/siobuf.c b/libbalsa/imap/siobuf.c
index 225bc0d..b465483 100644
--- a/libbalsa/imap/siobuf.c
+++ b/libbalsa/imap/siobuf.c
@@ -85,6 +85,8 @@ struct siobuf
void *user_data;
};
+static void sio_flush_buffer (struct siobuf *sio);
+
/* Attach bi-directional buffering to the socket descriptor.
*/
struct siobuf *
@@ -375,7 +377,7 @@ sio_write (struct siobuf *sio, const void *bufp, int buflen)
buf += sio->write_available;
buflen -= sio->write_available;
}
- sio_flush (sio);
+ sio_flush_buffer (sio);
assert (sio->write_available > 0);
}
if (buflen > 0)
@@ -385,7 +387,7 @@ sio_write (struct siobuf *sio, const void *bufp, int buflen)
sio->write_available -= buflen;
/* If the buffer is exactly filled, flush it */
if (sio->write_available == 0)
- sio_flush (sio);
+ sio_flush_buffer (sio);
}
}
@@ -442,8 +444,8 @@ raw_write (struct siobuf *sio, const char *buf, int len)
}
}
-void
-sio_flush (struct siobuf *sio)
+static void
+sio_flush_buffer (struct siobuf *sio)
{
int length;
@@ -494,6 +496,30 @@ sio_flush (struct siobuf *sio)
}
void
+sio_flush (struct siobuf *sio)
+{
+ sio_flush_buffer (sio);
+ if (sio->encode_cb != NULL)
+ {
+ char *buf;
+ int len = 0;
+
+ /* Rules for the encode callback.
+
+ The output variables (here buf and len) may be set to the
+ write_buffer iff the encoding can be performed in place and
+ the result is shorter than the original data. Otherwise the
+ callback must maintain its own buffer which must persist until
+ the next call in the same thread. The secarg argument may be
+ used to maintain this buffer. */
+ while ((*sio->encode_cb) (&buf, &len, sio->write_buffer,
+ 0, sio->secarg) >0) {
+ raw_write (sio, buf, len);
+ }
+ }
+}
+
+void
sio_mark (struct siobuf *sio)
{
assert (sio != NULL);
@@ -583,7 +609,7 @@ sio_fill (struct siobuf *sio)
sio->read_buffer, sio->read_unread,
sio->secarg) == 0) {
sio->read_unread = raw_read (sio, sio->read_buffer, sio->buffer_size);
- if (sio->read_unread < 0)
+ if (sio->read_unread <= 0)
break;
}
sio->read_buffer_start = sio->read_position;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]