Re: [Evolution-hackers] Patch: Camel stream filter waits properly for slow streams



El mar, 20-05-2008 a las 17:03 +0200, Philip Van Hoof escribió:
> Please bring this upstream too, José
> 
> Response from Jeffrey:
> 
> jeff_ yea, you should compare against -1
> jeff_ as long as it returns >0, it wrote all the data
> jeff_ -1 is error
> jeff_ 0 is EOF maybe
> jeff_ if write even returns 0 ever

	Ok, prepared patch for camel (it applied without problems). The
changelog would be mostly the same:

* evolution-data-server/camel/camel-stream-filter.c:
  (do_write): if the camel_stream_write call does not write the
  full buffer but it's not due to an error, then loop to go on 
  writing the stream.


-- 
José Dapena Paz <jdapena igalia com>
Igalia
Index: camel/camel-stream-filter.c
===================================================================
--- camel/camel-stream-filter.c	(revisión: 8817)
+++ camel/camel-stream-filter.c	(copia de trabajo)
@@ -290,6 +290,7 @@
 	struct _filter *f;
 	size_t presize, len, left = n;
 	char *buffer, realbuffer[READ_SIZE+READ_PAD];
+	size_t written = 0;
 
 	p->last_was_read = FALSE;
 
@@ -321,8 +322,13 @@
 			f = f->next;
 		}
 
-		if (camel_stream_write(filter->source, buffer, len) != len)
-			return -1;
+		for (written = 0; written < len;) {
+			size_t just_written;
+			just_written = camel_stream_write (filter->source, buffer + written, len - written);
+			if (just_written == -1)
+				return -1;
+			written += just_written;
+		}
 	}
 
 	g_check(p->realbuffer);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]