[dovecot-cvs] dovecot/src/lib ostream-file.c, 1.40,
1.41 ostream-internal.h, 1.3, 1.4 ostream.c, 1.10,
1.11 ostream.h, 1.9, 1.10
cras at dovecot.org
cras at dovecot.org
Wed Oct 20 20:07:35 EEST 2004
Update of /var/lib/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv4344/lib
Modified Files:
ostream-file.c ostream-internal.h ostream.c ostream.h
Log Message:
Changed ostream's flush callback to have return value which can tell if
there are more bytes to be sent even if there is none in output buffer
itself. Fixes FETCH commands which used o_stream_send_istream() getting
stuck.
Index: ostream-file.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/ostream-file.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- ostream-file.c 16 Oct 2004 16:32:09 -0000 1.40
+++ ostream-file.c 20 Oct 2004 17:07:32 -0000 1.41
@@ -332,19 +332,20 @@
static void stream_send_io(void *context)
{
struct file_ostream *fstream = context;
+ int ret;
+ o_stream_ref(&fstream->ostream.ostream);
if (fstream->ostream.callback != NULL)
- fstream->ostream.callback(fstream->ostream.context);
- else {
- if (_flush(&fstream->ostream) <= 0)
- return;
- }
+ ret = fstream->ostream.callback(fstream->ostream.context);
+ else
+ ret = _flush(&fstream->ostream);
- if (IS_STREAM_EMPTY(fstream) && fstream->io != NULL) {
+ if (ret > 0 && IS_STREAM_EMPTY(fstream) && fstream->io != NULL) {
/* all sent */
io_remove(fstream->io);
fstream->io = NULL;
}
+ o_stream_unref(&fstream->ostream.ostream);
}
static size_t o_stream_add(struct file_ostream *fstream,
Index: ostream-internal.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/ostream-internal.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- ostream-internal.h 15 Aug 2004 03:40:31 -0000 1.3
+++ ostream-internal.h 20 Oct 2004 17:07:32 -0000 1.4
@@ -21,7 +21,7 @@
/* data: */
struct ostream ostream;
- io_callback_t *callback;
+ stream_flush_callback_t *callback;
void *context;
};
Index: ostream.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/ostream.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- ostream.c 22 Aug 2004 11:00:23 -0000 1.10
+++ ostream.c 20 Oct 2004 17:07:32 -0000 1.11
@@ -21,7 +21,8 @@
}
void o_stream_set_flush_callback(struct ostream *stream,
- io_callback_t *callback, void *context)
+ stream_flush_callback_t *callback,
+ void *context)
{
struct _ostream *_stream = stream->real_stream;
Index: ostream.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/ostream.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- ostream.h 15 Aug 2004 03:40:31 -0000 1.9
+++ ostream.h 20 Oct 2004 17:07:32 -0000 1.10
@@ -12,6 +12,11 @@
struct _ostream *real_stream;
};
+/* Returns 1 if all data is sent (not necessarily flushed), 0 if not.
+ Pretty much the only real reason to return 0 is if you wish to send more
+ data to client which isn't buffered, eg. o_stream_send_istream(). */
+typedef int stream_flush_callback_t(void *context);
+
/* Create new output stream from given file descriptor.
If max_buffer_size is 0, an "optimal" buffer size is used (max 128kB). */
struct ostream *
@@ -26,9 +31,11 @@
/* Mark the stream closed. Nothing will be sent after this call. */
void o_stream_close(struct ostream *stream);
-/* Set IO_WRITE callback. Default will just try to flush the output. */
+/* Set IO_WRITE callback. Default will just try to flush the output and
+ finishes when the buffer is empty. */
void o_stream_set_flush_callback(struct ostream *stream,
- io_callback_t *callback, void *context);
+ stream_flush_callback_t *callback,
+ void *context);
/* Change the maximum size for stream's output buffer to grow. */
void o_stream_set_max_buffer_size(struct ostream *stream, size_t max_size);
More information about the dovecot-cvs
mailing list